Feature #4477 » mime_type_and_inlne_repo_files.patch
| app/controllers/repositories_controller.rb | ||
|---|---|---|
|
@content = @repository.cat(@path, @rev)
|
||
|
show_error_not_found and return unless @content
|
||
|
if 'raw' == params[:format] || @content.is_binary_data? || (@entry.size && @entry.size > Setting.file_max_size_displayed.to_i.kilobyte)
|
||
|
# Try to guess the content-type
|
||
|
en = @entry.name
|
||
|
mime = Mime::Type.lookup_by_extension(en[en.rindex('.')+1, en.size].downcase) unless en.rindex('.').nil?
|
||
|
options = { :filename => @path.split('/').last }
|
||
|
options.merge!( :type => mime, :disposition => "inline" ) unless mime.nil?
|
||
|
# Force the download
|
||
|
send_data @content, :filename => @path.split('/').last
|
||
|
send_data @content, options
|
||
|
else
|
||
|
# Prevent empty lines when displaying a file with Windows style eol
|
||
|
@content.gsub!("\r\n", "\n")
|
||