diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index b63f1071b..f976918d8 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -126,7 +126,7 @@ module ApplicationHelper
# Options:
# * :text - Link text (default to attachment filename)
# * :download - Force download (default: false)
- def link_to_attachment(attachment, options={})
+ def link_to_short_attachment(attachment, options={})
text = h(truncate(options.delete(:text) || attachment.filename, length: 25, omission: '...'))
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
html_options = options.slice!(:only_path)
@@ -134,6 +134,18 @@ module ApplicationHelper
link_to text, url, html_options
end
+ # Generates a link to an attachment.
+ # Options:
+ # * :text - Link text (default to attachment filename)
+ # * :download - Force download (default: false)
+ def link_to_attachment(attachment, options={})
+ text = options.delete(:text) || attachment.filename
+ route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
+ html_options = options.slice!(:only_path)
+ url = send(route_method, attachment, attachment.filename, options)
+ link_to text, url, html_options
+ end
+
def link_to_attachment_img(attachment, options={})
text = options.delete(:text) || attachment.filename
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path
diff --git a/app/views/attachments/_app_link.html.erb b/app/views/attachments/_app_link.html.erb
index 6934b76e1..263f51dc8 100644
--- a/app/views/attachments/_app_link.html.erb
+++ b/app/views/attachments/_app_link.html.erb
@@ -3,13 +3,15 @@
<% if attachments.count > 1 && attachment != attachments.first%>
<% end %>
- <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
+ <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments', :action => 'show',
:id => attachment, :filename => attachment.filename %>
<% end %>
- <%= h(" - #{attachment.description}") unless attachment.description.blank? %>
+
+ <%= h(truncate(" - #{attachment.description}", length: 20, omission: '...')) unless attachment.description.blank? %>
+
(<%= number_to_human_size attachment.filesize %>)
<% end -%>
diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb
index 2b12b21d1..de43dce4c 100644
--- a/app/views/attachments/_links.html.erb
+++ b/app/views/attachments/_links.html.erb
@@ -2,7 +2,7 @@
<% for attachment in attachments %>
- <%= @str_arr.shift %> -
++ <%= @str_arr.shift %> +
-