diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2018-03-26 12:16:01 +0300 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2018-03-26 12:16:01 +0300 |
commit | ef6b3e0271d226462bed5f899f3964cf5652978c (patch) | |
tree | 191638ae3a0ffbdf71290dc5f29c4aa868a0ea2f /app | |
parent | 1a9d80a139ea8de53fe32b7685daa696c1becbd0 (diff) |
Introduce #find_sidebar and use a constant to find the page
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/wikis_controller.rb | 2 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index cfb7d6fd941..cd7feaaf398 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -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)) diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 52e067cb44c..e70b7dc2325 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -1,3 +1,5 @@ +# 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 |