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