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
ef6b3e02
Commit
ef6b3e02
authored
Mar 26, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce #find_sidebar and use a constant to find the page
parent
1a9d80a1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
1 deletion
+24
-1
app/controllers/projects/wikis_controller.rb
app/controllers/projects/wikis_controller.rb
+1
-1
app/models/project_wiki.rb
app/models/project_wiki.rb
+7
-0
spec/models/project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+16
-0
No files found.
app/controllers/projects/wikis_controller.rb
View file @
ef6b3e02
...
...
@@ -107,7 +107,7 @@ class Projects::WikisController < Projects::ApplicationController
# Call #wiki to make sure the Wiki Repo is initialized
@project_wiki
.
wiki
@sidebar_page
=
@project_wiki
.
find_
page
(
'_sidebar'
,
params
[
:version_id
])
@sidebar_page
=
@project_wiki
.
find_
sidebar
(
params
[
:version_id
])
unless
@sidebar_page
# Fallback to default sidebar
@sidebar_wiki_entries
=
WikiPage
.
group_by_directory
(
@project_wiki
.
pages
(
limit:
15
))
...
...
app/models/project_wiki.rb
View file @
ef6b3e02
# frozen_string_literal: true
class
ProjectWiki
include
Gitlab
::
ShellAdapter
include
Storage
::
LegacyProjectWiki
...
...
@@ -9,6 +11,7 @@ class ProjectWiki
}.
freeze
unless
defined?
(
MARKUPS
)
CouldNotCreateWikiError
=
Class
.
new
(
StandardError
)
SIDEBAR
=
'_sidebar'
# Returns a string describing what went wrong after
# an operation fails.
...
...
@@ -95,6 +98,10 @@ class ProjectWiki
end
end
def
find_sidebar
(
version
=
nil
)
find_page
(
SIDEBAR
,
version
)
end
def
find_file
(
name
,
version
=
nil
)
wiki
.
file
(
name
,
version
)
end
...
...
spec/models/project_wiki_spec.rb
View file @
ef6b3e02
...
...
@@ -170,6 +170,22 @@ describe ProjectWiki do
end
end
describe
'#find_sidebar'
do
before
do
create_page
(
described_class
::
SIDEBAR
,
'This is an awesome Sidebar'
)
end
after
do
subject
.
pages
.
each
{
|
page
|
destroy_page
(
page
.
page
)
}
end
it
'finds the page defined as _sidebar'
do
page
=
subject
.
find_page
(
'_sidebar'
)
expect
(
page
.
content
).
to
eq
(
'This is an awesome Sidebar'
)
end
end
describe
'#find_file'
do
shared_examples
'finding a wiki file'
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