diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-07-06 22:21:08 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-07-07 00:19:10 +0300 |
commit | d195db17e9ff62c3dbfb8ba03dacadf965b1fb8b (patch) | |
tree | 58157f1909c4f04306d10be5b842f99a79f9b809 /app | |
parent | bb918a2fd98136c232baa34104c357f3716f8842 (diff) |
Don't show auxiliary blob viewer for README when there is no wiki
Diffstat (limited to 'app')
-rw-r--r-- | app/models/blob_viewer/readme.rb | 6 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 4 | ||||
-rw-r--r-- | app/views/projects/blob/viewers/_readme.html.haml | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/app/models/blob_viewer/readme.rb b/app/models/blob_viewer/readme.rb index 75c373a03bb..4604a9934a0 100644 --- a/app/models/blob_viewer/readme.rb +++ b/app/models/blob_viewer/readme.rb @@ -10,5 +10,11 @@ module BlobViewer def visible_to?(current_user) can?(current_user, :read_wiki, project) end + + def render_error + return if project.has_external_wiki? || (project.wiki_enabled? && project.wiki.has_home_page?) + + :no_wiki + end end end diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index beaadbbd1ab..dfca0031af8 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -63,6 +63,10 @@ class ProjectWiki !!repository.exists? end + def has_home_page? + !!find_page('home') + end + # Returns an Array of Gitlab WikiPage instances or an # empty Array if this Wiki has no pages. def pages diff --git a/app/views/projects/blob/viewers/_readme.html.haml b/app/views/projects/blob/viewers/_readme.html.haml index 507f44d4745..d8492abc638 100644 --- a/app/views/projects/blob/viewers/_readme.html.haml +++ b/app/views/projects/blob/viewers/_readme.html.haml @@ -1,4 +1,4 @@ = icon('info-circle fw') = succeed '.' do To learn more about this project, read - = link_to "the wiki", project_wikis_path(viewer.project) + = link_to "the wiki", get_project_wiki_path(viewer.project) |