From 855758ce15a3f485a34adbd6191e23119214def6 Mon Sep 17 00:00:00 2001 From: Jan Schulz-Hofen Date: Wed, 24 May 2017 18:44:42 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Add=20download=20link=20to=20=E2=80=9Cno=20?= =?UTF-8?q?preview=E2=80=9D=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/other.html.erb | 10 +++++++++- app/views/common/_other.html.erb | 8 +++++++- app/views/repositories/entry.html.erb | 10 +++++++++- config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ config/locales/fr.yml | 4 +++- test/functional/attachments_controller_test.rb | 4 ++-- 7 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/views/attachments/other.html.erb b/app/views/attachments/other.html.erb index e6244c1..608bbf2 100644 --- a/app/views/attachments/other.html.erb +++ b/app/views/attachments/other.html.erb @@ -1,3 +1,11 @@ <%= render :layout => 'layouts/file' do %> - <%= render :partial => 'common/other' %> + <%= render :partial => 'common/other', + :locals => { + :download_link => link_to_attachment( + @attachment, + :text => l(:label_no_preview_download), + :download => true, + :class => 'icon icon-download' + ) + } %> <% end %> diff --git a/app/views/common/_other.html.erb b/app/views/common/_other.html.erb index fe0228a..74d87a6 100644 --- a/app/views/common/_other.html.erb +++ b/app/views/common/_other.html.erb @@ -1 +1,7 @@ -

<%= l(:label_no_preview) %>

+

+ <% if defined? download_link %> + <%= t(:label_no_preview_alternative_html, link: download_link) %> + <% else %> + <%= l(:label_no_preview) %> + <% end %> +

diff --git a/app/views/repositories/entry.html.erb b/app/views/repositories/entry.html.erb index b495dd4..16bebc7 100644 --- a/app/views/repositories/entry.html.erb +++ b/app/views/repositories/entry.html.erb @@ -17,7 +17,15 @@ <% elsif @content %> <%= render :partial => 'common/file', :locals => {:filename => @path, :content => @content} %> <% else %> - <%= render :partial => 'common/other' %> + <%= render :partial => 'common/other', + :locals => { + :download_link => @repository.supports_cat? ? link_to( + l(:label_no_preview_download), + { :action => 'raw', :id => @project, + :repository_id => @repository.identifier_param, + :path => to_path_param(@path), + :rev => @rev }, + :class => 'icon icon-download') : nil } %> <% end %> <% content_for :header_tags do %> diff --git a/config/locales/de.yml b/config/locales/de.yml index 1d42b9b..b0b699a 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -654,6 +654,8 @@ de: label_no_change_option: (Keine Änderung) label_no_data: Nichts anzuzeigen label_no_preview: Keine Vorschau verfügbar + label_no_preview_alternative_html: Keine Vorschau verfügbar. Sie können die Datei stattdessen %{link}. + label_no_preview_download: herunterladen label_no_issues_in_project: keine Tickets im Projekt label_nobody: Niemand label_none: kein diff --git a/config/locales/en.yml b/config/locales/en.yml index a8eca2d..6881f8e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -638,6 +638,8 @@ en: label_attribute_plural: Attributes label_no_data: No data to display label_no_preview: No preview available + label_no_preview_alternative_html: No preview available. %{link} the file instead. + label_no_preview_download: Download label_change_status: Change status label_history: History label_attachment: File diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 653c49b..feb07fe 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1223,6 +1223,8 @@ fr: mail_body_security_notification_notify_enabled: Les notifications ont été activées pour l'adresse %{value} mail_body_security_notification_notify_disabled: Les notifications ont été désactivées pour l'adresse %{value} field_remote_ip: Adresse IP - label_no_preview: No preview available + label_no_preview: Aucun aperçu disponible + label_no_preview_alternative_html: Aucun aperçu disponible. Veuillez %{link} le fichier. + label_no_preview_download: télécharger label_user_mail_option_only_assigned: Only for things I watch or I am assigned to label_user_mail_option_only_owner: Only for things I watch or I am the owner of diff --git a/test/functional/attachments_controller_test.rb b/test/functional/attachments_controller_test.rb index 665eb1d..a530cc4 100644 --- a/test/functional/attachments_controller_test.rb +++ b/test/functional/attachments_controller_test.rb @@ -180,7 +180,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest get :show, :id => 4 assert_response :success assert_equal 'text/html', @response.content_type - assert_select '.nodata', :text => 'No preview available' + assert_select '.nodata', :text => 'No preview available. Download the file instead.' end set_tmp_attachments_directory end @@ -197,7 +197,7 @@ class AttachmentsControllerTest < Redmine::ControllerTest @request.session[:user_id] = 2 get :show, :id => 6 assert_equal 'text/html', @response.content_type - assert_select '.nodata', :text => 'No preview available' + assert_select '.nodata', :text => 'No preview available. Download the file instead.' set_tmp_attachments_directory end -- 2.7.2