Commit f448080023470bb1d799372920859902a94814c1

Authored by Rodrigo Souto
Committed by Antonio Terceiro
1 parent bf1a73c3

Lead field

* Adding the lead field to article's edition. This field fills the
    information that is displayed in the highlighted news.
(ActionItem1664)
app/views/cms/_textile_article.rhtml
... ... @@ -4,5 +4,15 @@
4 4  
5 5 <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64')) %>
6 6  
7   -<%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 64)) %>
  7 +<br style="clear: both;"/>
  8 +<%= button_to_function :edit, _("Lead"), nil, :id => "lead-link", :style => "margin-left: 0px;" %>
  9 +
  10 +<div id="article-lead">
  11 + <%= labelled_form_field(_('Lead'), text_area(:article, 'abstract', :cols => 64, :rows => 10)) %>
  12 +</div>
  13 +<div style="margin-top: 10px;">
  14 + <%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 64)) %>
  15 +</div>
  16 +
  17 +<%= javascript_include_tag 'article'%>
8 18  
... ...
app/views/cms/_tiny_mce_article.rhtml
... ... @@ -11,6 +11,16 @@
11 11 <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64')) %>
12 12 <% end %>
13 13  
14   - <%= labelled_form_field(_('Text'), text_area(:article, 'body', :cols => 40, :style => 'width:100%')) %>
  14 + <br style="clear: both;"/>
  15 + <%= button_to_function :edit, _("Lead"), nil, :id => "lead-link", :style => "margin-left: 0px;" %>
  16 +
  17 + <div id="article-lead">
  18 + <%= labelled_form_field(_('Lead'), text_area(:article, 'abstract', :style => 'width: 100%; height: 300px;')) %>
  19 + </div>
  20 + <div style="margin-top: 10px;">
  21 + <%= labelled_form_field(_('Text'), text_area(:article, 'body', :style => 'width:100%')) %>
  22 + </div>
15 23  
16 24 </div>
  25 +
  26 +<%= javascript_include_tag 'article' %>
... ...
app/views/home/index.rhtml
... ... @@ -10,8 +10,8 @@
10 10 <div class='highlighted-news-item post-<%= index + 1 %>'>
11 11 <div class='highlighted-news-item post-<%= index + 1 %>-inner'>
12 12 <h2><%= link_to(highlighted.title, highlighted.url, :class => 'post-title') %></h2>
13   - <span class="post-date"><%= show_date(highlighted.published_at, true) %> </span></p>
14   - <p class='headline'><%= highlighted.first_paragraph %></p>
  13 + <span class="post-date"><%= show_date(highlighted.published_at, true) %> </span>
  14 + <p class='headline'><%= !highlighted.abstract.blank? ? highlighted.abstract : highlighted.first_paragraph %></p>
15 15 <p class='highlighted-news-read-more'>
16 16 <%= link_to(_('Read more'), highlighted.url) %>
17 17 </p>
... ...
public/javascripts/article.js 0 → 100644
... ... @@ -0,0 +1,8 @@
  1 +(function($) {
  2 + $("#lead-link").click(function(){
  3 + if($('#article-lead').css('display') == 'none')
  4 + $('#article-lead').slideDown();
  5 + else
  6 + $('#article-lead').slideUp();
  7 + })
  8 +})(jQuery)
... ...
public/stylesheets/application.css
... ... @@ -1005,6 +1005,11 @@ code input {
1005 1005 font-weight: normal;
1006 1006 }
1007 1007  
  1008 +#article-lead {
  1009 + margin-top: 10px;
  1010 + display: none;
  1011 +}
  1012 +
1008 1013 /* * * Comments * * */
1009 1014  
1010 1015 .comments { }
... ...
test/functional/home_controller_test.rb
... ... @@ -53,6 +53,29 @@ all_fixtures
53 53 assert_tag :tag => 'div', :attributes => { :id => 'portal-news' } #, :descendant => {:tag => 'form', :attributes => {:action => '/account/activation_question'}}
54 54 end
55 55  
  56 + should 'display the news leads if there is any' do
  57 + env = Environment.default
  58 + env.enable('use_portal_community')
  59 + c = fast_create(Community)
  60 + a1 = TextileArticle.create!(:name => "Article 1",
  61 + :profile => c,
  62 + :abstract => "This is the article1 lead.",
  63 + :body => "This is the article1 body.",
  64 + :highlighted => true)
  65 + a2 = TextileArticle.create!(:name => "Article 2",
  66 + :profile => c,
  67 + :body => "This is the article2 body.",
  68 + :highlighted => true)
  69 + env.portal_community = c
  70 + env.save!
  71 +
  72 +
  73 + get :index
  74 + assert_tag :tag => 'p', :content => a1.abstract
  75 + assert_no_tag :tag => 'p', :content => a1.body
  76 + assert_tag :tag => 'p', :content => a2.body
  77 + end
  78 +
56 79 should 'display block in index page if it\'s configured to display on homepage and its an environment block' do
57 80 env = Environment.default
58 81 box = Box.create(:owner_type => 'Environment', :owner_id => env.id)
... ...