diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index bbc1a98..054bac8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -263,6 +263,16 @@ module ApplicationHelper def truncate_single_line(string, *args) truncate(string.to_s, *args).gsub(%r{[\r\n]+}m, ' ') end + + # Truncates at line break after 250 characters or options[:length] + def truncate_lines(string, options={}) + length = options[:length] || 250 + if string.to_s =~ /\A(.{#{length}}.*?)$/m + "#{$1}..." + else + string + end + end def html_hours(text) text.gsub(%r{(\d+)\.(\d+)}, '\1.\2') diff --git a/app/views/documents/_document.rhtml b/app/views/documents/_document.rhtml index 94a64ac..644cf2f 100644 --- a/app/views/documents/_document.rhtml +++ b/app/views/documents/_document.rhtml @@ -1,3 +1,6 @@ -

<%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %>
-<% unless document.description.blank? %><%=h(truncate(document.description, :length => 250)) %>
<% end %> -<%= format_time(document.updated_on) %>

\ No newline at end of file +

<%= link_to h(document.title), :controller => 'documents', :action => 'show', :id => document %>

+

<%= format_time(document.updated_on) %>

+ +
+ <%= textilizable(truncate_lines(document.description)) %> +