Serve a file if in wiki.

This commit is contained in:
Marin Jankovski 2014-04-24 15:00:18 +02:00
parent 1feaa336ed
commit 0050c07fdd
1 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,17 @@ class Projects::WikisController < Projects::ApplicationController
if @page
render 'show'
elsif file = @project_wiki.wiki.file(params[:id], @project_wiki.wiki.ref, true)
if file.on_disk?
send_file file.on_disk_path, :disposition => 'inline'
else
send_data(
file.raw_data,
type: file.mime_type,
disposition: 'inline',
filename: file.name
)
end
else
return render('empty') unless can?(current_user, :write_wiki, @project)
@page = WikiPage.new(@project_wiki)