@@ -59,7 +59,7 class AttachmentsController < ApplicationController | |||||
59 | # images are sent inline |
|
59 | # images are sent inline | |
60 | send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), |
|
60 | send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), | |
61 | :type => detect_content_type(@attachment), |
|
61 | :type => detect_content_type(@attachment), | |
62 |
:disposition => (@attachment |
|
62 | :disposition => disposition(@attachment) | |
63 | end |
|
63 | end | |
64 | end |
|
64 | end | |
65 |
|
65 | |||
@@ -191,4 +191,12 class AttachmentsController < ApplicationController | |||||
191 | end |
|
191 | end | |
192 | content_type.to_s |
|
192 | content_type.to_s | |
193 | end |
|
193 | end | |
|
194 | ||||
|
195 | def disposition(attachment) | |||
|
196 | if attachment.is_image? || attachment.is_pdf? | |||
|
197 | 'inline' | |||
|
198 | else | |||
|
199 | 'attachment' | |||
|
200 | end | |||
|
201 | end | |||
194 | end |
|
202 | end |
@@ -173,7 +173,7 class RepositoriesController < ApplicationController | |||||
173 | send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) } |
|
173 | send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) } | |
174 | send_type = Redmine::MimeType.of(@path) |
|
174 | send_type = Redmine::MimeType.of(@path) | |
175 | send_opt[:type] = send_type.to_s if send_type |
|
175 | send_opt[:type] = send_type.to_s if send_type | |
176 | send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) ? 'inline' : 'attachment') |
|
176 | send_opt[:disposition] = disposition(@path) | |
177 | send_data @repository.cat(@path, @rev), send_opt |
|
177 | send_data @repository.cat(@path, @rev), send_opt | |
178 | else |
|
178 | else | |
179 | if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte |
|
179 | if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte | |
@@ -441,4 +441,12 class RepositoriesController < ApplicationController | |||||
441 | ) |
|
441 | ) | |
442 | graph.burn |
|
442 | graph.burn | |
443 | end |
|
443 | end | |
|
444 | ||||
|
445 | def disposition(path) | |||
|
446 | if Redmine::MimeType.is_type?('image', @path) || Redmine::MimeType.of(@path) == "application/pdf" | |||
|
447 | 'inline' | |||
|
448 | else | |||
|
449 | 'attachment' | |||
|
450 | end | |||
|
451 | end | |||
444 | end |
|
452 | end |
@@ -245,6 +245,10 class Attachment < ActiveRecord::Base | |||||
245 | self.filename =~ /\.(patch|diff)$/i |
|
245 | self.filename =~ /\.(patch|diff)$/i | |
246 | end |
|
246 | end | |
247 |
|
247 | |||
|
248 | def is_pdf? | |||
|
249 | Redmine::MimeType.of(filename) == "application/pdf" | |||
|
250 | end | |||
|
251 | ||||
248 | # Returns true if the file is readable |
|
252 | # Returns true if the file is readable | |
249 | def readable? |
|
253 | def readable? | |
250 | File.readable?(diskfile) |
|
254 | File.readable?(diskfile) |
General Comments 0
You need to be logged in to leave comments.
Login now