From 5428161e0fb45c8059451411f56316107699826c Mon Sep 17 00:00:00 2001 From: Charles Pence Date: Tue, 18 Jun 2013 21:49:38 -0400 Subject: [PATCH 1/2] Add support for on-disk file streaming. --- lib/gollum/app.rb | 10 +++++++--- test/test_app.rb | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/gollum/app.rb b/lib/gollum/app.rb index a8b9abab..516ba9ea 100644 --- a/lib/gollum/app.rb +++ b/lib/gollum/app.rb @@ -403,9 +403,13 @@ module Precious @bar_side = wiki.bar_side mustache :page - elsif file = wiki.file(fullpath) - content_type file.mime_type - file.raw_data + 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 else page_path = [path, name].compact.join('/') redirect to("/create/#{clean_url(encodeURIComponent(page_path))}") diff --git a/test/test_app.rb b/test/test_app.rb index c7fb3aad..e5212dbd 100644 --- a/test/test_app.rb +++ b/test/test_app.rb @@ -578,6 +578,12 @@ context "Frontend with lotr" do assert_match /Bilbo Baggins/, last_response.body end + test "streaming files to browser" do + get "/Data.csv" + assert last_response.ok? + assert last_response.headers.include? 'Content-Disposition' + end + # base path requires 'map' in a config.ru to work correctly. test "create pages within sub-directories using base path" do Precious::App.set(:wiki_options, { :base_path => 'wiki' }) From 433865e927f0f0f0bef74579cd3cf9354a640f20 Mon Sep 17 00:00:00 2001 From: Charles Pence Date: Tue, 18 Jun 2013 22:10:02 -0400 Subject: [PATCH 2/2] Require newer gollum-lib. --- gollum.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gollum.gemspec b/gollum.gemspec index a96721a9..547786bf 100644 --- a/gollum.gemspec +++ b/gollum.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |s| s.rdoc_options = ["--charset=UTF-8"] s.extra_rdoc_files = %w[README.md LICENSE] - s.add_dependency 'gollum-lib', '~> 1.0.2' + s.add_dependency 'gollum-lib', '~> 1.0.3' s.add_dependency 'sinatra', '~> 1.4.2' s.add_dependency 'mustache', ['>= 0.99.4', '< 1.0.0'] s.add_dependency 'useragent', '~> 0.6.0'