From e0d234c255afcb438801d18a0fade654af1f48a2 Mon Sep 17 00:00:00 2001 From: rick Date: Mon, 30 Aug 2010 18:25:48 -0700 Subject: [PATCH] use grit to get the file's mime type, as suggested. http://github.com/github/gollum/commit/6de9ddfd3f79a9cb320aab3c43b8e0a912107b2e#commitcomment-137656 --- HISTORY.md | 1 + lib/gollum/file.rb | 5 +++++ lib/gollum/frontend/app.rb | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 37752ff0..29a7344d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -8,6 +8,7 @@ * Minor Enhancements * Support a `:gollum_path` Sinatra setting for `Precious::App` * Add Wiki#size to efficiently count pages without loading them. + * Add the correct content type when serving files from the frontend. * Bug Fixes * Increase minimum Sanitize version requirement to 1.1.0. 1.0.x versions of Sanitize require Hpricot instead of Nokogiri diff --git a/lib/gollum/file.rb b/lib/gollum/file.rb index 0f1f58fd..8e7c33d3 100644 --- a/lib/gollum/file.rb +++ b/lib/gollum/file.rb @@ -33,6 +33,11 @@ module Gollum # Public: The String path of the file. attr_reader :path + # Public: The String mime type of the file. + def mime_type + @blob.mime_type + end + ######################################################################### # # Internal Methods diff --git a/lib/gollum/frontend/app.rb b/lib/gollum/frontend/app.rb index 0c88a8f0..31bbaf5c 100644 --- a/lib/gollum/frontend/app.rb +++ b/lib/gollum/frontend/app.rb @@ -141,7 +141,7 @@ module Precious @content = page.formatted_data mustache :page elsif file = wiki.file(name) - content_type MIME::Types.type_for(name).to_s + content_type file.mime_type file.raw_data else @name = name