diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-05-08 08:02:23 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-05-08 08:02:23 +0000 |
commit | 3d2c198c0f889e73ae2a16a068c41948b40cefff (patch) | |
tree | c764f9e787428d113cc37201f93e2c0e719e259d /app/controllers | |
parent | d8d23fbb6b23f15c6c5cc0a65ebfdf99c06e1a9b (diff) | |
download | redmine-3d2c198c0f889e73ae2a16a068c41948b40cefff.tar.gz redmine-3d2c198c0f889e73ae2a16a068c41948b40cefff.zip |
Add view for "no preview" repository files (#22482).
Patch by Gregor Schmidt.
git-svn-id: http://svn.redmine.org/redmine/trunk@15397 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/repositories_controller.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 8f34c0034..9c39ad075 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -168,24 +168,26 @@ class RepositoriesController < ApplicationController # If the entry is a dir, show the browser (show; return) if @entry.is_dir? - @content = @repository.cat(@path, @rev) - (show_error_not_found; return) unless @content - if !is_raw && Redmine::MimeType.is_type?('image', @path) - # simply render - elsif is_raw || - (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || - ! is_entry_text_data?(@content, @path) + if is_raw # Force the download 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) && !is_raw ? 'inline' : 'attachment') - send_data @content, send_opt + send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) ? 'inline' : 'attachment') + send_data @repository.cat(@path, @rev), send_opt else - # Prevent empty lines when displaying a file with Windows style eol - # TODO: UTF-16 - # Is this needs? AttachmentsController reads file simply. - @content.gsub!("\r\n", "\n") + if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte + content = @repository.cat(@path, @rev) + (show_error_not_found; return) unless content + + if content.size <= Setting.file_max_size_displayed.to_i.kilobyte && + is_entry_text_data?(content, @path) + # TODO: UTF-16 + # Prevent empty lines when displaying a file with Windows style eol + # Is this needed? AttachmentsController simply reads file. + @content = content.gsub("\r\n", "\n") + end + end @changeset = @repository.find_changeset_by_name(@rev) end end |