summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-06-10 10:30:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-06-10 10:30:59 +0000
commit8a3c24762d91ecaea4d55734173da6b9fa7aa3ea (patch)
tree992648bfeb905b64ce20e24fbf31a33dd4e5e1ea /app
parent30ff1ac451ab9e4eeb4612cd4f3a340f2c5ae7ad (diff)
downloadredmine-8a3c24762d91ecaea4d55734173da6b9fa7aa3ea.tar.gz
redmine-8a3c24762d91ecaea4d55734173da6b9fa7aa3ea.zip
Preview files by default instead of downloading them (#25988).
Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@16651 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/issues_helper.rb10
-rw-r--r--app/models/attachment.rb6
-rw-r--r--app/views/attachments/_links.html.erb45
-rw-r--r--app/views/files/index.html.erb5
4 files changed, 35 insertions, 31 deletions
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 703607999..70fea91ce 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -468,14 +468,10 @@ module IssuesHelper
if detail.property == 'attachment' && value.present? &&
atta = detail.journal.journalized.attachments.detect {|a| a.id == detail.prop_key.to_i}
# Link to the attachment if it has not been removed
- value = link_to_attachment(atta, :download => true, :only_path => options[:only_path])
- if options[:only_path] != false && (atta.is_text? || atta.is_image?)
+ value = link_to_attachment(atta, only_path: options[:only_path])
+ if options[:only_path] != false
value += ' '
- value += link_to(l(:button_view),
- { :controller => 'attachments', :action => 'show',
- :id => atta, :filename => atta.filename },
- :class => 'icon-only icon-magnifier',
- :title => l(:button_view))
+ value += link_to_attachment atta, class: 'icon-only icon-download', title: l(:button_download), download: true
end
else
value = content_tag("i", h(value)) if value
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index 89b9f8a7c..e2bc570e2 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -31,7 +31,7 @@ class Attachment < ActiveRecord::Base
attr_protected :id
acts_as_event :title => :filename,
- :url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}}
+ :url => Proc.new {|o| {:controller => 'attachments', :action => 'show', :id => o.id, :filename => o.filename}}
acts_as_activity_provider :type => 'files',
:permission => :view_files,
@@ -251,6 +251,10 @@ class Attachment < ActiveRecord::Base
Redmine::MimeType.of(filename) == "application/pdf"
end
+ def previewable?
+ is_text? || is_image?
+ end
+
# Returns true if the file is readable
def readable?
disk_filename.present? && File.readable?(diskfile)
diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb
index 797f8bb43..0a9f5e3eb 100644
--- a/app/views/attachments/_links.html.erb
+++ b/app/views/attachments/_links.html.erb
@@ -6,29 +6,32 @@
:class => 'icon-only icon-edit'
) if options[:editable] %>
</div>
+<table>
<% for attachment in attachments %>
-<p><%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
- <% if attachment.is_text? || attachment.is_image? %>
- <%= link_to l(:button_view),
- { :controller => 'attachments', :action => 'show',
- :id => attachment, :filename => attachment.filename },
- :class => 'icon-only icon-magnifier',
- :title => l(:button_view) %>
- <% end %>
- <%= " - #{attachment.description}" unless attachment.description.blank? %>
- <span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
- <% if options[:deletable] %>
- <%= link_to l(:button_delete), attachment_path(attachment),
- :data => {:confirm => l(:text_are_you_sure)},
- :method => :delete,
- :class => 'delete icon-only icon-del',
- :title => l(:button_delete) %>
- <% end %>
- <% if options[:author] %>
- <span class="author"><%= attachment.author %>, <%= format_time(attachment.created_on) %></span>
- <% end %>
- </p>
+<tr>
+ <td>
+ <%= link_to_attachment attachment, class: 'icon icon-attachment' -%>
+ <span class="size">(<%= number_to_human_size attachment.filesize %>)</span>
+ <%= link_to_attachment attachment, class: 'icon-only icon-download', title: l(:button_download), download: true -%>
+ </td>
+ <td><%= attachment.description unless attachment.description.blank? %></td>
+ <td>
+ <% if options[:author] %>
+ <span class="author"><%= attachment.author %>, <%= format_time(attachment.created_on) %></span>
+ <% end %>
+ </td>
+ <td>
+ <% if options[:deletable] %>
+ <%= link_to l(:button_delete), attachment_path(attachment),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :method => :delete,
+ :class => 'delete icon-only icon-del',
+ :title => l(:button_delete) %>
+ <% end %>
+ </td>
+</tr>
<% end %>
+</table>
<% if defined?(thumbnails) && thumbnails %>
<% images = attachments.select(&:thumbnailable?) %>
<% if images.any? %>
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index 5c827c195..a1149bfbe 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -27,13 +27,14 @@
<% end -%>
<% container.attachments.each do |file| %>
<tr class="file">
- <td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %></td>
+ <td class="filename"><%= link_to_attachment file, :title => file.description -%></td>
<td class="created_on"><%= format_time(file.created_on) %></td>
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
<td class="downloads"><%= file.downloads %></td>
<td class="digest"><%= file.digest_type %>: <%= file.digest %></td>
<td class="buttons">
- <%= link_to(image_tag('delete.png'), attachment_path(file),
+ <%= link_to_attachment file, class: 'icon-only icon-download', title: l(:button_download), download: true %>
+ <%= link_to(l(:button_delete), attachment_path(file), :class => 'icon-only icon-del',
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td>
</tr>