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
5bbe6559
Commit
5bbe6559
authored
Dec 18, 2016
by
Alex Braha Stoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add component to show the full path of a wiki page when viewing its content
parent
294acf1c
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
2 deletions
+54
-2
app/assets/stylesheets/pages/wiki.scss
app/assets/stylesheets/pages/wiki.scss
+2
-1
app/models/wiki_page.rb
app/models/wiki_page.rb
+11
-0
app/views/projects/wikis/show.html.haml
app/views/projects/wikis/show.html.haml
+1
-1
spec/models/wiki_page_spec.rb
spec/models/wiki_page_spec.rb
+40
-0
No files found.
app/assets/stylesheets/pages/wiki.scss
View file @
5bbe6559
...
...
@@ -14,7 +14,8 @@
font-size
:
22px
;
}
.wiki-last-edit-by
{
.wiki-last-edit-by
,
.wiki-page-full-path
{
display
:
block
;
color
:
$gl-gray-light
;
strong
{
...
...
app/models/wiki_page.rb
View file @
5bbe6559
...
...
@@ -88,6 +88,12 @@ class WikiPage
end
end
# The hierarchy of the directory this page is contained in.
def
directory
dir
=
wiki
.
page_title_and_dir
(
slug
).
last
dir
.
present?
?
dir
:
'/'
end
# The processed/formatted content of this page.
def
formatted_content
@attributes
[
:formatted_content
]
||=
if
@page
...
...
@@ -100,6 +106,11 @@ class WikiPage
@attributes
[
:format
]
||
:markdown
end
# The full path for this page, including its filename and extension.
def
full_path
"/
#{
directory
}
/
#{
page
.
filename
}
"
.
gsub
(
/\/+/
,
'/'
)
end
# The commit message for this page version.
def
message
version
.
try
(
:message
)
...
...
app/views/projects/wikis/show.html.haml
View file @
5bbe6559
...
...
@@ -8,7 +8,7 @@
.nav-text
%h2
.wiki-page-title
=
@page
.
title
.
capitalize
%span
.wiki-page-full-path
=
"(
#{
@page
.
full_path
}
)"
%span
.wiki-last-edit-by
Last edited by
%strong
...
...
spec/models/wiki_page_spec.rb
View file @
5bbe6559
...
...
@@ -224,6 +224,46 @@ describe WikiPage, models: true do
end
end
describe
'#directory'
do
context
'when the page is at the root directory'
do
it
'returns /'
do
create_page
(
'file'
,
'content'
)
page
=
wiki
.
find_page
(
'file'
)
expect
(
page
.
directory
).
to
eq
(
'/'
)
end
end
context
'when the page is inside an actual directory'
do
it
'returns the full directory hierarchy'
do
create_page
(
'dir_1/dir_1_1/file'
,
'content'
)
page
=
wiki
.
find_page
(
'dir_1/dir_1_1/file'
)
expect
(
page
.
directory
).
to
eq
(
'dir_1/dir_1_1'
)
end
end
end
describe
'#full_path'
do
context
'when the page is at the root directory'
do
it
'returns /filename.fileextension'
do
create_page
(
'file'
,
'content'
)
page
=
wiki
.
find_page
(
'file'
)
expect
(
page
.
full_path
).
to
eq
(
'/file.md'
)
end
end
context
'when the page is inside an actual directory'
do
it
'returns /directory/filename.fileextension'
do
create_page
(
'dir/file'
,
'content'
)
page
=
wiki
.
find_page
(
'dir/file'
)
expect
(
page
.
full_path
).
to
eq
(
'/dir/file.md'
)
end
end
end
describe
'#historical?'
do
before
do
create_page
(
'Update'
,
'content'
)
...
...
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