Route /filename/[commit-sha] will display specific revision of a file. Resolves #892.

This commit is contained in:
Dawa Ometto
2014-11-06 19:41:04 +01:00
parent 0965269ee9
commit 2c80db6678
3 changed files with 37 additions and 6 deletions
+13 -6
View File
@@ -402,6 +402,8 @@ module Precious
@content = page.formatted_data
@version = version
mustache :page
elsif file = wikip.wiki.file("#{file_path}", version, true)
show_file(file)
else
halt 404
end
@@ -472,18 +474,23 @@ module Precious
mustache :page
elsif file = wiki.file(fullpath, wiki.ref, true)
if file.on_disk?
send_file file.on_disk_path, :disposition => 'inline'
else
content_type file.mime_type
file.raw_data
end
show_file(file)
else
page_path = [path, name].compact.join('/')
redirect to("/create/#{clean_url(encodeURIComponent(page_path))}")
end
end
def show_file(file)
return unless file
if file.on_disk?
send_file file.on_disk_path, :disposition => 'inline'
else
content_type file.mime_type
file.raw_data
end
end
def update_wiki_page(wiki, page, content, commit, name = nil, format = nil)
return if !page ||
((!content || page.raw_data == content) && page.format == format)