Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
68309766
Commit
68309766
authored
Jan 30, 2017
by
Alex Braha Stoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add WikiPage.unhyphenize
parent
4c57fa42
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
+14
-2
app/helpers/wiki_helper.rb
app/helpers/wiki_helper.rb
+1
-1
app/models/wiki_page.rb
app/models/wiki_page.rb
+5
-1
spec/models/wiki_page_spec.rb
spec/models/wiki_page_spec.rb
+8
-0
No files found.
app/helpers/wiki_helper.rb
View file @
68309766
...
...
@@ -7,7 +7,7 @@ module WikiHelper
# capitalized name of the page itself.
def
breadcrumb
(
page_slug
)
page_slug
.
split
(
'/'
).
map
{
|
dir_or_page
|
dir_or_page
.
gsub
(
/-+/
,
' '
).
capitalize
}.
map
{
|
dir_or_page
|
WikiPage
.
unhyphenize
(
dir_or_page
).
capitalize
}.
join
(
' / '
)
end
end
app/models/wiki_page.rb
View file @
68309766
...
...
@@ -34,6 +34,10 @@ class WikiPage
flatten
end
def
self
.
unhyphenize
(
name
)
name
.
gsub
(
/-+/
,
' '
)
end
def
to_key
[
:slug
]
end
...
...
@@ -78,7 +82,7 @@ class WikiPage
# The formatted title of this page.
def
title
if
@attributes
[
:title
]
@attributes
[
:title
].
gsub
(
/-+/
,
' '
)
self
.
class
.
unhyphenize
(
@attributes
[
:title
]
)
else
""
end
...
...
spec/models/wiki_page_spec.rb
View file @
68309766
...
...
@@ -68,6 +68,14 @@ describe WikiPage, models: true do
end
end
describe
'.unhyphenize'
do
it
'removes hyphens from a name'
do
name
=
'a-name--with-hyphens'
expect
(
WikiPage
.
unhyphenize
(
name
)).
to
eq
(
'a name with hyphens'
)
end
end
describe
"#initialize"
do
context
"when initialized with an existing gollum page"
do
before
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment