Commit 94196aae8adacf35724b493160a8cd57f46231cd

Authored by Victor Costa
1 parent 5e223b92

rails3: fix recent_content plugin

plugins/recent_content/features/add_recent_content.feature
@@ -13,6 +13,9 @@ Background: @@ -13,6 +13,9 @@ Background:
13 And the following blocks 13 And the following blocks
14 | owner | type | 14 | owner | type |
15 | joaosilva | RecentContentBlock | 15 | joaosilva | RecentContentBlock |
  16 + And the following blogs
  17 + | owner | name |
  18 + | joaosilva | JSilva blog |
16 And the following articles 19 And the following articles
17 | owner | parent | name | body | abstract | 20 | owner | parent | name | body | abstract |
18 | joaosilva | JSilva blog | post #1 | Primeiro post do joao silva | Resumo 1 | 21 | joaosilva | JSilva blog | post #1 | Primeiro post do joao silva | Resumo 1 |
plugins/recent_content/lib/recent_content_block.rb
@@ -5,6 +5,8 @@ class RecentContentBlock < Block @@ -5,6 +5,8 @@ class RecentContentBlock < Block
5 settings_items :show_blog_picture, :type => :boolean, :default => false 5 settings_items :show_blog_picture, :type => :boolean, :default => false
6 settings_items :selected_folder, :type => Integer 6 settings_items :selected_folder, :type => Integer
7 7
  8 + attr_accessible :presentation_mode, :total_items, :show_blog_picture, :selected_folder
  9 +
8 VALID_CONTENT = ['RawHTMLArticle', 'TextArticle', 'TextileArticle', 'TinyMceArticle'] 10 VALID_CONTENT = ['RawHTMLArticle', 'TextArticle', 'TextileArticle', 'TinyMceArticle']
9 11
10 def self.description 12 def self.description
@@ -41,12 +43,11 @@ class RecentContentBlock < Block @@ -41,12 +43,11 @@ class RecentContentBlock < Block
41 end 43 end
42 end 44 end
43 45
44 - include ActionController::UrlWriter  
45 include DatesHelper 46 include DatesHelper
46 47
47 def content(args={}) 48 def content(args={})
48 block = self 49 block = self
49 - lambda do 50 + proc do
50 render :file => 'blocks/recent_content_block', :locals => {:root => block.root, :block => block} 51 render :file => 'blocks/recent_content_block', :locals => {:root => block.root, :block => block}
51 end 52 end
52 end 53 end
plugins/recent_content/views/blocks/recent_content_block.html.erb 0 → 100644
@@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
  1 +<% unless root.nil? %>
  2 + <div id="recent-content-block">
  3 + <% children = block.articles_of_folder(root, block.total_items)%>
  4 + <div class="recent-content">
  5 + <%= block_title(block.title.blank? ? _("Recent content") : block.title ) %>
  6 + <% if block.show_blog_picture and !root.image.nil? %>
  7 + <div class="recent-content-cover">
  8 + <%= image_tag(root.image.public_filename(:big)) %>
  9 + </div>
  10 + <% end %>
  11 + </div>
  12 + <% if block.mode?('title_only') %>
  13 + <div class="recent-content-title">
  14 + <ul>
  15 + <% children.each do |item| %>
  16 + <li> <%= link_to(h(item.title), item.url)%></li>
  17 + <% end %>
  18 + </ul>
  19 + </div>
  20 + <% elsif block.mode?('title_and_abstract') %>
  21 + <div class="recent-content-abstract">
  22 + <% children.each do |item| %>
  23 + <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2>
  24 + <span class="post-date"><%= show_date(item.published_at, true)%></span>
  25 + <div class="headline"><%=item.lead%></div>
  26 + <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p>
  27 + <% end %>
  28 + </div>
  29 + <% else %>
  30 + <div class="recent-content-full">
  31 + <% children.each do |item| %>
  32 + <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2>
  33 + <span class="post-date"><%= show_date(item.published_at, true)%></span>
  34 + <div class="headline"><%=item.body%></div>
  35 + <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p>
  36 + <% end %>
  37 + </div>
  38 + <% end %>
  39 + <%= link_to _('View All'), :profile => profile.identifier, :controller => 'content_viewer', :action => 'view_page', :page => block.root.path %>
  40 + </div>
  41 +<% else %>
  42 + <span class="alert-block">
  43 + <%= _('This is the recent content block. Please edit it to show the content you want.') %>
  44 + </span>
  45 +<% end %>
plugins/recent_content/views/blocks/recent_content_block.rhtml
@@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
1 -<% unless root.nil? %>  
2 - <div id="recent-content-block">  
3 - <% children = block.articles_of_folder(root, block.total_items)%>  
4 - <div class="recent-content">  
5 - <%= block_title(block.title.blank? ? _("Recent content") : block.title ) %>  
6 - <% if block.show_blog_picture and !root.image.nil? %>  
7 - <div class="recent-content-cover">  
8 - <%= image_tag(root.image.public_filename(:big)) %>  
9 - </div>  
10 - <% end %>  
11 - </div>  
12 - <% if block.mode?('title_only') %>  
13 - <div class="recent-content-title">  
14 - <ul>  
15 - <% children.each do |item| %>  
16 - <li> <%= link_to(h(item.title), item.url)%></li>  
17 - <% end %>  
18 - </ul>  
19 - </div>  
20 - <% elsif block.mode?('title_and_abstract') %>  
21 - <div class="recent-content-abstract">  
22 - <% children.each do |item| %>  
23 - <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2>  
24 - <span class="post-date"><%= show_date(item.published_at, true)%></span>  
25 - <div class="headline"><%=item.lead%></div>  
26 - <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p>  
27 - <% end %>  
28 - </div>  
29 - <% else %>  
30 - <div class="recent-content-full">  
31 - <% children.each do |item| %>  
32 - <h2><%= link_to(item.title,item.url, :class => 'post-title')%></h2>  
33 - <span class="post-date"><%= show_date(item.published_at, true)%></span>  
34 - <div class="headline"><%=item.body%></div>  
35 - <p class="highlighted-news-read-more"><%= link_to(_('Read more'), item.url) %></p>  
36 - <% end %>  
37 - </div>  
38 - <% end %>  
39 - <%= link_to _('View All'), :profile => profile.identifier, :controller => 'content_viewer', :action => 'view_page', :page => block.root.path %>  
40 - </div>  
41 -<% else %>  
42 - <span class="alert-block">  
43 - <%= _('This is the recent content block. Please edit it to show the content you want.') %>  
44 - </span>  
45 -<% end %>  
plugins/recent_content/views/box_organizer/_recent_content_block.html.erb 0 → 100644
@@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
  1 +<% blogs = @block.parents %>
  2 +<% if blogs.empty? %>
  3 + <h3><%= _('No blogs found. Please add a blog in order to configure this block.') %></h3>
  4 +<% end %>
  5 +<%=
  6 +labelled_form_field(_('Choose which blog should be displayed'),
  7 + select_tag(
  8 + 'block[selected_folder]',
  9 + options_for_select(blogs.map {|node| [node.title, node.id]}, @block.selected_folder)
  10 + )
  11 +)
  12 +%>
  13 +<%=
  14 +labelled_form_field(_('Choose how the content should be displayed'),
  15 + select_tag(
  16 + 'block[presentation_mode]',
  17 + options_for_select(
  18 + {
  19 + _("Title only") => "title_only",
  20 + _("Title and abstract") => "title_and_abstract",
  21 + _("Full content") => "full_content"
  22 + },
  23 + @block.presentation_mode
  24 + )
  25 + )
  26 +)
  27 +%>
  28 +<%= labelled_form_field(_('Choose how many items will be displayed'),
  29 + text_field_tag('block[total_items]',
  30 + @block.total_items, :size => 3, :maxlength => 5)
  31 + )
  32 +%>
  33 +<%= labelled_check_box _('Display blog cover image'), 'block[show_blog_picture]', true, @block.show_blog_picture %>
plugins/recent_content/views/box_organizer/_recent_content_block.rhtml
@@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
1 -<% blogs = @block.parents %>  
2 -<% if blogs.empty? %>  
3 - <h3><%= _('No blogs found. Please add a blog in order to configure this block.') %></h3>  
4 -<% end %>  
5 -<%=  
6 -labelled_form_field(_('Choose which blog should be displayed'),  
7 - select_tag(  
8 - 'block[selected_folder]',  
9 - options_for_select(blogs.map {|node| [node.title, node.id]}, @block.selected_folder)  
10 - )  
11 -)  
12 -%>  
13 -<%=  
14 -labelled_form_field(_('Choose how the content should be displayed'),  
15 - select_tag(  
16 - 'block[presentation_mode]',  
17 - options_for_select(  
18 - {  
19 - _("Title only") => "title_only",  
20 - _("Title and abstract") => "title_and_abstract",  
21 - _("Full content") => "full_content"  
22 - },  
23 - @block.presentation_mode  
24 - )  
25 - )  
26 -)  
27 -%>  
28 -<%= labelled_form_field(_('Choose how many items will be displayed'),  
29 - text_field_tag('block[total_items]',  
30 - @block.total_items, :size => 3, :maxlength => 5)  
31 - )  
32 -%>  
33 -<%= labelled_check_box _('Display blog cover image'), 'block[show_blog_picture]', true, @block.show_blog_picture %>