Commit 7bc3b2b3d7631da4d65889160e72de137061ee2f
1 parent
27f11bf7
Exists in
staging
and in
31 other branches
Refactor RecentContentBlock plugin
The view rendering has been removed from the model and now relies on the structure at BoxesHelper. This improves MVC compliance.
Showing
3 changed files
with
45 additions
and
52 deletions
Show diff stats
plugins/recent_content/lib/recent_content_block.rb
... | ... | @@ -44,13 +44,6 @@ class RecentContentBlock < Block |
44 | 44 | |
45 | 45 | include DatesHelper |
46 | 46 | |
47 | - def content(args={}) | |
48 | - block = self | |
49 | - proc do | |
50 | - render :file => 'blocks/recent_content_block', :locals => {:root => block.root, :block => block} | |
51 | - end | |
52 | - end | |
53 | - | |
54 | 47 | def mode?(attr) |
55 | 48 | attr == self.presentation_mode |
56 | 49 | end | ... | ... |
plugins/recent_content/views/blocks/recent_content.html.erb
0 → 100644
... | ... | @@ -0,0 +1,45 @@ |
1 | +<% unless block.root.nil? %> | |
2 | + <div id="recent-content-block"> | |
3 | + <% children = block.articles_of_folder(block.root, block.total_items)%> | |
4 | + <div class="recent-content"> | |
5 | + <%= block_title(block.title.blank? ? c_("Recent content") : block.title, block.subtitle ) %> | |
6 | + <% if block.show_blog_picture and !block.root.image.nil? %> | |
7 | + <div class="recent-content-cover"> | |
8 | + <%= image_tag(block.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.html.erb
... | ... | @@ -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? ? c_("Recent content") : block.title, block.subtitle ) %> | |
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 %> |