# 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
--- /dev/null
+<p class="nodata"><%= l(:label_no_preview) %></p>
<% if Redmine::MimeType.is_type?('image', @path) %>
<%= render :partial => 'common/image', :locals => {:path => url_for(params.merge(:action => 'raw')), :alt => @path} %>
-<% else %>
+<% elsif @content %>
<%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %>
+<% else %>
+ <%= render :partial => 'common/other' %>
<% end %>
<% content_for :header_tags do %>
label_next: Weiter
label_no_change_option: (Keine Änderung)
label_no_data: Nichts anzuzeigen
+ label_no_preview: Keine Vorschau verfügbar
label_no_issues_in_project: keine Tickets im Projekt
label_nobody: Niemand
label_none: kein
label_attribute: Attribute
label_attribute_plural: Attributes
label_no_data: No data to display
+ label_no_preview: No preview available
label_change_status: Change status
label_history: History
label_attachment: File
label_attribute: Attribute
label_attribute_plural: Attributes
label_no_data: No data to display
+ label_no_preview: No preview available
label_change_status: Change status
label_history: History
label_attachment: File
end
end
- def test_show_text_file_should_send_if_too_big
+ def test_show_text_file_should_show_other_if_too_big
with_settings :file_max_size_displayed => 1 do
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['japanese', 'big-file.txt'])[:param]
assert_response :success
- assert_equal 'text/plain', @response.content_type
+ assert_equal 'text/html', @response.content_type
+ assert_select 'p.nodata'
end
end
assert_template 'entry'
end
- def test_entry_should_send_if_too_big
+ def test_entry_should_show_other_if_too_big
assert_equal 0, @repository.changesets.count
@repository.fetch_changesets
@project.reload
get :entry, :id => PRJ_ID,
:path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
assert_response :success
- assert_equal 'attachment; filename="helloworld.c"',
- @response.headers['Content-Disposition']
+ assert_equal 'text/html', @response.content_type
+ assert_select 'p.nodata'
end
end