##// END OF EJS Templates
Add view for "no preview" repository files (#22482)....
Jean-Philippe Lang -
r15015:3d2c198c0f88
parent child
Show More
@@ -0,0 +1,1
1 <p class="nodata"><%= l(:label_no_preview) %></p>
@@ -168,24 +168,26 class RepositoriesController < ApplicationController
168 168 # If the entry is a dir, show the browser
169 169 (show; return) if @entry.is_dir?
170 170
171 @content = @repository.cat(@path, @rev)
172 (show_error_not_found; return) unless @content
173 if !is_raw && Redmine::MimeType.is_type?('image', @path)
174 # simply render
175 elsif is_raw ||
176 (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
177 ! is_entry_text_data?(@content, @path)
171 if is_raw
178 172 # Force the download
179 173 send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
180 174 send_type = Redmine::MimeType.of(@path)
181 175 send_opt[:type] = send_type.to_s if send_type
182 send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) && !is_raw ? 'inline' : 'attachment')
183 send_data @content, send_opt
176 send_opt[:disposition] = (Redmine::MimeType.is_type?('image', @path) ? 'inline' : 'attachment')
177 send_data @repository.cat(@path, @rev), send_opt
184 178 else
185 # Prevent empty lines when displaying a file with Windows style eol
186 # TODO: UTF-16
187 # Is this needs? AttachmentsController reads file simply.
188 @content.gsub!("\r\n", "\n")
179 if !@entry.size || @entry.size <= Setting.file_max_size_displayed.to_i.kilobyte
180 content = @repository.cat(@path, @rev)
181 (show_error_not_found; return) unless content
182
183 if content.size <= Setting.file_max_size_displayed.to_i.kilobyte &&
184 is_entry_text_data?(content, @path)
185 # TODO: UTF-16
186 # Prevent empty lines when displaying a file with Windows style eol
187 # Is this needed? AttachmentsController simply reads file.
188 @content = content.gsub("\r\n", "\n")
189 end
190 end
189 191 @changeset = @repository.find_changeset_by_name(@rev)
190 192 end
191 193 end
@@ -10,8 +10,10
10 10
11 11 <% if Redmine::MimeType.is_type?('image', @path) %>
12 12 <%= render :partial => 'common/image', :locals => {:path => url_for(params.merge(:action => 'raw')), :alt => @path} %>
13 <% else %>
13 <% elsif @content %>
14 14 <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %>
15 <% else %>
16 <%= render :partial => 'common/other' %>
15 17 <% end %>
16 18
17 19 <% content_for :header_tags do %>
@@ -655,6 +655,7 de:
655 655 label_next: Weiter
656 656 label_no_change_option: (Keine Änderung)
657 657 label_no_data: Nichts anzuzeigen
658 label_no_preview: Keine Vorschau verfügbar
658 659 label_no_issues_in_project: keine Tickets im Projekt
659 660 label_nobody: Niemand
660 661 label_none: kein
@@ -531,6 +531,7 en-GB:
531 531 label_attribute: Attribute
532 532 label_attribute_plural: Attributes
533 533 label_no_data: No data to display
534 label_no_preview: No preview available
534 535 label_change_status: Change status
535 536 label_history: History
536 537 label_attachment: File
@@ -617,6 +617,7 en:
617 617 label_attribute: Attribute
618 618 label_attribute_plural: Attributes
619 619 label_no_data: No data to display
620 label_no_preview: No preview available
620 621 label_change_status: Change status
621 622 label_history: History
622 623 label_attachment: File
@@ -107,12 +107,13 class RepositoriesFilesystemControllerTest < ActionController::TestCase
107 107 end
108 108 end
109 109
110 def test_show_text_file_should_send_if_too_big
110 def test_show_text_file_should_show_other_if_too_big
111 111 with_settings :file_max_size_displayed => 1 do
112 112 get :entry, :id => PRJ_ID,
113 113 :path => repository_path_hash(['japanese', 'big-file.txt'])[:param]
114 114 assert_response :success
115 assert_equal 'text/plain', @response.content_type
115 assert_equal 'text/html', @response.content_type
116 assert_select 'p.nodata'
116 117 end
117 118 end
118 119
@@ -168,7 +168,7 class RepositoriesSubversionControllerTest < ActionController::TestCase
168 168 assert_template 'entry'
169 169 end
170 170
171 def test_entry_should_send_if_too_big
171 def test_entry_should_show_other_if_too_big
172 172 assert_equal 0, @repository.changesets.count
173 173 @repository.fetch_changesets
174 174 @project.reload
@@ -178,8 +178,8 class RepositoriesSubversionControllerTest < ActionController::TestCase
178 178 get :entry, :id => PRJ_ID,
179 179 :path => repository_path_hash(['subversion_test', 'helloworld.c'])[:param]
180 180 assert_response :success
181 assert_equal 'attachment; filename="helloworld.c"',
182 @response.headers['Content-Disposition']
181 assert_equal 'text/html', @response.content_type
182 assert_select 'p.nodata'
183 183 end
184 184 end
185 185
General Comments 0
You need to be logged in to leave comments. Login now