Adds a setting to limit the size of text attachments that can be displayed by the file viewer (default set to 512KB). Larger files are sent for download.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2503 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
2bd419f23b
commit
66afc8c054
|
@ -26,7 +26,7 @@ class AttachmentsController < ApplicationController
|
|||
if @attachment.is_diff?
|
||||
@diff = File.new(@attachment.diskfile, "rb").read
|
||||
render :action => 'diff'
|
||||
elsif @attachment.is_text?
|
||||
elsif @attachment.is_text? && @attachment.filesize <= Setting.setting_file_max_size_displayed.to_i.kilobyte
|
||||
@content = File.new(@attachment.diskfile, "rb").read
|
||||
render :action => 'file'
|
||||
else
|
||||
|
|
|
@ -33,6 +33,9 @@
|
|||
<p><label><%= l(:setting_feeds_limit) %></label>
|
||||
<%= text_field_tag 'settings[feeds_limit]', Setting.feeds_limit, :size => 6 %></p>
|
||||
|
||||
<p><label><%= l(:setting_file_max_size_displayed) %></label>
|
||||
<%= text_field_tag 'settings[setting_file_max_size_displayed]', Setting.setting_file_max_size_displayed, :size => 6 %> KB</p>
|
||||
|
||||
<p><label><%= l(:setting_diff_max_lines_displayed) %></label>
|
||||
<%= text_field_tag 'settings[diff_max_lines_displayed]', Setting.diff_max_lines_displayed, :size => 6 %></p>
|
||||
</div>
|
||||
|
|
|
@ -771,3 +771,4 @@ bg:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -772,3 +772,4 @@ ca:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -776,3 +776,4 @@ cs:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -803,3 +803,4 @@ da:
|
|||
general_csv_decimal_separator: '.'
|
||||
permission_edit_own_time_entries: Edit own time logs
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -804,3 +804,4 @@ de:
|
|||
button_create_and_continue: Create and continue
|
||||
text_custom_field_possible_values_info: 'One line for each value'
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -278,6 +278,7 @@ en:
|
|||
setting_sequential_project_identifiers: Generate sequential project identifiers
|
||||
setting_gravatar_enabled: Use Gravatar user icons
|
||||
setting_diff_max_lines_displayed: Max number of diff lines displayed
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
|
||||
permission_edit_project: Edit project
|
||||
|
|
|
@ -824,3 +824,4 @@ es:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -814,3 +814,4 @@ fi:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -311,6 +311,7 @@ fr:
|
|||
setting_sequential_project_identifiers: Générer des identifiants de projet séquentiels
|
||||
setting_gravatar_enabled: Afficher les Gravatar des utilisateurs
|
||||
setting_diff_max_lines_displayed: Nombre maximum de lignes de diff affichées
|
||||
setting_file_max_size_displayed: Taille maximum des fichiers texte affichés en ligne
|
||||
setting_repository_log_display_limit: "Nombre maximum de revisions affichées sur l'historique d'un fichier"
|
||||
|
||||
permission_edit_project: Modifier le projet
|
||||
|
|
|
@ -804,3 +804,4 @@ gl:
|
|||
button_create_and_continue: Create and continue
|
||||
text_custom_field_possible_values_info: 'One line for each value'
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -787,3 +787,4 @@ he:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -809,3 +809,4 @@
|
|||
label_display: Megmutat
|
||||
field_editable: Szerkeszthető
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -790,3 +790,4 @@ it:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -802,3 +802,4 @@ ja:
|
|||
label_display: 表示
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -833,3 +833,4 @@ ko:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -814,3 +814,4 @@ lt:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -759,3 +759,4 @@ nl:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -777,3 +777,4 @@
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -807,3 +807,4 @@ pl:
|
|||
button_create_and_continue: Create and continue
|
||||
text_custom_field_possible_values_info: 'One line for each value'
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -810,3 +810,4 @@ pt-BR:
|
|||
label_display: Exibição
|
||||
field_editable: Editável
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -795,3 +795,4 @@ pt:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -817,3 +817,4 @@ ro:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -902,3 +902,4 @@ ru:
|
|||
field_editable: Редактируемый
|
||||
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -775,3 +775,4 @@ sk:
|
|||
button_create_and_continue: Create and continue
|
||||
text_custom_field_possible_values_info: 'One line for each value'
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -773,3 +773,4 @@ sl:
|
|||
button_create_and_continue: Create and continue
|
||||
text_custom_field_possible_values_info: 'One line for each value'
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -798,3 +798,4 @@
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -831,3 +831,4 @@ sv:
|
|||
enumeration_doc_categories: Dokumentkategorier
|
||||
enumeration_activities: Aktiviteter (tidsuppföljning)
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -774,3 +774,4 @@ th:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -811,3 +811,4 @@ tr:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -773,3 +773,4 @@ uk:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -843,3 +843,4 @@ vi:
|
|||
label_display: Display
|
||||
field_editable: Editable
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -805,3 +805,4 @@
|
|||
enumeration_doc_categories: 文件分類
|
||||
enumeration_activities: 活動 (時間追蹤)
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -805,3 +805,4 @@ zh:
|
|||
enumeration_doc_categories: 文档类别
|
||||
enumeration_activities: 活动(时间跟踪)
|
||||
setting_repository_log_display_limit: Maximum number of revisions displayed on file log
|
||||
setting_file_max_size_displayed: Max size of text files displayed inline
|
||||
|
|
|
@ -61,6 +61,11 @@ protocol:
|
|||
feeds_limit:
|
||||
format: int
|
||||
default: 15
|
||||
# Maximum size of files that can be displayed
|
||||
# inline through the file viewer (in KB)
|
||||
setting_file_max_size_displayed:
|
||||
format: int
|
||||
default: 512
|
||||
diff_max_lines_displayed:
|
||||
format: int
|
||||
default: 1500
|
||||
|
|
|
@ -53,12 +53,23 @@ class AttachmentsControllerTest < Test::Unit::TestCase
|
|||
get :show, :id => 5
|
||||
assert_response :success
|
||||
assert_template 'diff'
|
||||
assert_equal 'text/html', @response.content_type
|
||||
end
|
||||
|
||||
def test_show_text_file
|
||||
get :show, :id => 4
|
||||
assert_response :success
|
||||
assert_template 'file'
|
||||
assert_equal 'text/html', @response.content_type
|
||||
end
|
||||
|
||||
def test_show_text_file_should_send_if_too_big
|
||||
Setting.setting_file_max_size_displayed = 512
|
||||
Attachment.find(4).update_attribute :filesize, 754.kilobyte
|
||||
|
||||
get :show, :id => 4
|
||||
assert_response :success
|
||||
assert_equal 'application/x-ruby', @response.content_type
|
||||
end
|
||||
|
||||
def test_show_other
|
||||
|
|
Loading…
Reference in New Issue