comparison app/controllers/repositories_controller.rb @ 1082:997f6d7738f7 bug_531

In repo controller entry action, show the page for the file even if it's binary (so user still has access to history etc links). This makes it possible to use the entry action as the default when a file is clicked on
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 22 Nov 2012 18:04:17 +0000
parents 5e80956cc792
children bb32da3bea34
comparison
equal deleted inserted replaced
1081:b56a4c5afa35 1082:997f6d7738f7
141 # If the entry is a dir, show the browser 141 # If the entry is a dir, show the browser
142 (show; return) if @entry.is_dir? 142 (show; return) if @entry.is_dir?
143 143
144 @content = @repository.cat(@path, @rev) 144 @content = @repository.cat(@path, @rev)
145 (show_error_not_found; return) unless @content 145 (show_error_not_found; return) unless @content
146 if 'raw' == params[:format] || 146 if 'raw' == params[:format]
147 (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
148 ! is_entry_text_data?(@content, @path)
149 # Force the download 147 # Force the download
150 send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) } 148 send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
151 send_type = Redmine::MimeType.of(@path) 149 send_type = Redmine::MimeType.of(@path)
152 send_opt[:type] = send_type.to_s if send_type 150 send_opt[:type] = send_type.to_s if send_type
153 send_data @content, send_opt 151 send_data @content, send_opt
154 else 152 else
153 @display_raw = ((@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || !is_entry_text_data?(@content, @path))
155 # Prevent empty lines when displaying a file with Windows style eol 154 # Prevent empty lines when displaying a file with Windows style eol
156 # TODO: UTF-16 155 # TODO: UTF-16
157 # Is this needs? AttachmentsController reads file simply. 156 # Is this needs? AttachmentsController reads file simply.
158 @content.gsub!("\r\n", "\n") 157 @content.gsub!("\r\n", "\n")
159 @changeset = @repository.find_changeset_by_name(@rev) 158 @changeset = @repository.find_changeset_by_name(@rev)