Commit 53c76729fced2e974abfafb065ac2397d7ef6faa

Authored by Rodrigo Souto
1 parent 5ddb93d8

content-viewer: use lead instead of straight abstract

app/models/article.rb
... ... @@ -724,8 +724,9 @@ class Article < ActiveRecord::Base
724 724 paragraphs.empty? ? '' : paragraphs.first.to_html
725 725 end
726 726  
727   - def lead
728   - abstract.blank? ? first_paragraph.html_safe : abstract.html_safe
  727 + def lead(length = nil)
  728 + content = abstract.blank? ? first_paragraph.html_safe : abstract.html_safe
  729 + length.present? ? content.truncate(length) : content
729 730 end
730 731  
731 732 def short_lead
... ...
app/views/content_viewer/_article_title.html.erb
1 1 <% if @page.belongs_to_blog? || @page.belongs_to_forum?%>
2 2 <h1 class="title">
3   - <% if no_link %>
  3 + <% if no_link %>
4 4 <%= h(@page.title) %>
5   - <% else %>
  5 + <% else %>
6 6 <%= link_to(@page.name, @page.url) %>
7   - <% end %>
  7 + <% end %>
8 8 </h1>
9 9 <%= render :partial => "publishing_info" %>
10 10 <% unless @page.abstract.blank? %>
... ...
app/views/content_viewer/_display_compact_format.html.erb
... ... @@ -16,6 +16,6 @@
16 16 </div>
17 17 <% end %>
18 18 <div class = <%= className %> >
19   - <%= article.abstract.truncate(400) %>
  19 + <%= article.lead(400) %>
20 20 </div>
21 21 </div>
... ...