summaryrefslogtreecommitdiffstats
path: root/app/controllers
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-05-09 17:22:23 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-05-09 17:22:23 +0000
commit3e776af8066e478beb5d2bc9bd26e81d2bef2542 (patch)
tree4aa73b256f1a451e1fc2de06512ca1f1fd9badc8 /app/controllers
parent3bdf6e995a35299c3e96cc7b0cbbd6a9baed0a98 (diff)
downloadredmine-3e776af8066e478beb5d2bc9bd26e81d2bef2542.tar.gz
redmine-3e776af8066e478beb5d2bc9bd26e81d2bef2542.zip
Don't force download of PDF (#22483).
Patch by Gregor Schmidt. git-svn-id: http://svn.redmine.org/redmine/trunk@15409 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/attachments_controller.rb10
-rw-r--r--app/controllers/repositories_controller.rb10
2 files changed, 18 insertions, 2 deletions
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index 14025cb86..ea45397ef 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -59,7 +59,7 @@ class AttachmentsController < ApplicationController
# images are sent inline
send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),
:type => detect_content_type(@attachment),
- :disposition => (@attachment.image? ? 'inline' : 'attachment')
+ :disposition => disposition(@attachment)
end
end
@@ -191,4 +191,12 @@ class AttachmentsController < ApplicationController
end
content_type.to_s
end
+
+ def disposition(attachment)
+ if attachment.is_image? || attachment.is_pdf?
+ 'inline'
+ else
+ 'attachment'
+ end
+ end
end
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 9c39ad075..c963ee00f 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -173,7 +173,7 @@ class RepositoriesController < ApplicationController
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
send_type = Redmine::MimeType.of(@path)
send_opt[:type] = send_type.to_s if send_type
- send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) ? 'inline' : 'attachment')
+ send_opt[:disposition] = disposition(@path)
send_data @repository.cat(@path, @rev), send_opt
else
if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte
@@ -441,4 +441,12 @@ class RepositoriesController < ApplicationController
)
graph.burn
end
+
+ def disposition(path)
+ if Redmine::MimeType.is_type?('image', @path) || Redmine::MimeType.of(@path) == "application/pdf"
+ 'inline'
+ else
+ 'attachment'
+ end
+ end
end