diff options
author | Loic Nageleisen <loic.nageleisen@gmail.com> | 2014-03-28 21:15:25 +0100 |
---|---|---|
committer | Loic Nageleisen <loic.nageleisen@gmail.com> | 2014-06-07 11:14:33 +0200 |
commit | c1ccc3a57b8e335c014e3176f3255ed74703572f (patch) | |
tree | 66eeeffeb0bb55d60eefde0d441001d63875098c /app | |
parent | ab094e67eed54f5c29a33d2114cc91908e543972 (diff) | |
download | gitlab-ce-c1ccc3a57b8e335c014e3176f3255ed74703572f.tar.gz |
Added ability to serve files in wiki repository
From #6168.
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/wikis_controller.rb | 4 | ||||
-rw-r--r-- | app/models/project_wiki.rb | 9 |
2 files changed, 10 insertions, 3 deletions
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 496064c9a65..0e03956e738 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -12,12 +12,10 @@ class Projects::WikisController < Projects::ApplicationController def show @page = @project_wiki.find_page(params[:id], params[:version_id]) - gollum_wiki = @project_wiki.wiki - file = gollum_wiki.file(params[:id], gollum_wiki.ref, true) if @page render 'show' - elsif file + elsif file = @project_wiki.find_file(params[:id], params[:version_id]) if file.on_disk? send_file file.on_disk_path, disposition: 'inline' else diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 08a52782475..a8ba5efcc7c 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -72,6 +72,15 @@ class ProjectWiki end end + def find_file(name, version = nil, try_on_disk = true) + version = wiki.ref if version.nil? # Gollum::Wiki#file ? + if wiki_file = wiki.file(name, version, try_on_disk) + wiki_file + else + nil + end + end + def create_page(title, content, format = :markdown, message = nil) commit = commit_details(:created, message, title) |