diff --git a/plugins/recent_content/features/add_recent_content.feature b/plugins/recent_content/features/add_recent_content.feature index 730bd3a..cf87137 100644 --- a/plugins/recent_content/features/add_recent_content.feature +++ b/plugins/recent_content/features/add_recent_content.feature @@ -13,6 +13,9 @@ Background: And the following blocks | owner | type | | joaosilva | RecentContentBlock | + And the following blogs + | owner | name | + | joaosilva | JSilva blog | And the following articles | owner | parent | name | body | abstract | | joaosilva | JSilva blog | post #1 | Primeiro post do joao silva | Resumo 1 | diff --git a/plugins/recent_content/lib/recent_content_block.rb b/plugins/recent_content/lib/recent_content_block.rb index 200a9ca..d7a1ce7 100644 --- a/plugins/recent_content/lib/recent_content_block.rb +++ b/plugins/recent_content/lib/recent_content_block.rb @@ -5,6 +5,8 @@ class RecentContentBlock < Block settings_items :show_blog_picture, :type => :boolean, :default => false settings_items :selected_folder, :type => Integer + attr_accessible :presentation_mode, :total_items, :show_blog_picture, :selected_folder + VALID_CONTENT = ['RawHTMLArticle', 'TextArticle', 'TextileArticle', 'TinyMceArticle'] def self.description @@ -41,12 +43,11 @@ class RecentContentBlock < Block end end - include ActionController::UrlWriter include DatesHelper def content(args={}) block = self - lambda do + proc do render :file => 'blocks/recent_content_block', :locals => {:root => block.root, :block => block} end end diff --git a/plugins/recent_content/views/blocks/recent_content_block.html.erb b/plugins/recent_content/views/blocks/recent_content_block.html.erb new file mode 100644 index 0000000..8668d64 --- /dev/null +++ b/plugins/recent_content/views/blocks/recent_content_block.html.erb @@ -0,0 +1,45 @@ +<% unless root.nil? %> +
+ <% children = block.articles_of_folder(root, block.total_items)%> +
+ <%= block_title(block.title.blank? ? _("Recent content") : block.title ) %> + <% if block.show_blog_picture and !root.image.nil? %> +
+ <%= image_tag(root.image.public_filename(:big)) %> +
+ <% end %> +
+ <% if block.mode?('title_only') %> +
+ +
+ <% elsif block.mode?('title_and_abstract') %> +
+ <% children.each do |item| %> +

<%= link_to(item.title,item.url, :class => 'post-title')%>

+ +
<%=item.lead%>
+

<%= link_to(_('Read more'), item.url) %>

+ <% end %> +
+ <% else %> +
+ <% children.each do |item| %> +

<%= link_to(item.title,item.url, :class => 'post-title')%>

+ +
<%=item.body%>
+

<%= link_to(_('Read more'), item.url) %>

+ <% end %> +
+ <% end %> + <%= link_to _('View All'), :profile => profile.identifier, :controller => 'content_viewer', :action => 'view_page', :page => block.root.path %> +
+<% else %> + + <%= _('This is the recent content block. Please edit it to show the content you want.') %> + +<% end %> diff --git a/plugins/recent_content/views/blocks/recent_content_block.rhtml b/plugins/recent_content/views/blocks/recent_content_block.rhtml deleted file mode 100644 index 8668d64..0000000 --- a/plugins/recent_content/views/blocks/recent_content_block.rhtml +++ /dev/null @@ -1,45 +0,0 @@ -<% unless root.nil? %> -
- <% children = block.articles_of_folder(root, block.total_items)%> -
- <%= block_title(block.title.blank? ? _("Recent content") : block.title ) %> - <% if block.show_blog_picture and !root.image.nil? %> -
- <%= image_tag(root.image.public_filename(:big)) %> -
- <% end %> -
- <% if block.mode?('title_only') %> -
- -
- <% elsif block.mode?('title_and_abstract') %> -
- <% children.each do |item| %> -

<%= link_to(item.title,item.url, :class => 'post-title')%>

- -
<%=item.lead%>
-

<%= link_to(_('Read more'), item.url) %>

- <% end %> -
- <% else %> -
- <% children.each do |item| %> -

<%= link_to(item.title,item.url, :class => 'post-title')%>

- -
<%=item.body%>
-

<%= link_to(_('Read more'), item.url) %>

- <% end %> -
- <% end %> - <%= link_to _('View All'), :profile => profile.identifier, :controller => 'content_viewer', :action => 'view_page', :page => block.root.path %> -
-<% else %> - - <%= _('This is the recent content block. Please edit it to show the content you want.') %> - -<% end %> diff --git a/plugins/recent_content/views/box_organizer/_recent_content_block.html.erb b/plugins/recent_content/views/box_organizer/_recent_content_block.html.erb new file mode 100644 index 0000000..1b59e22 --- /dev/null +++ b/plugins/recent_content/views/box_organizer/_recent_content_block.html.erb @@ -0,0 +1,33 @@ +<% blogs = @block.parents %> +<% if blogs.empty? %> +

<%= _('No blogs found. Please add a blog in order to configure this block.') %>

+<% end %> +<%= +labelled_form_field(_('Choose which blog should be displayed'), + select_tag( + 'block[selected_folder]', + options_for_select(blogs.map {|node| [node.title, node.id]}, @block.selected_folder) + ) +) +%> +<%= +labelled_form_field(_('Choose how the content should be displayed'), + select_tag( + 'block[presentation_mode]', + options_for_select( + { + _("Title only") => "title_only", + _("Title and abstract") => "title_and_abstract", + _("Full content") => "full_content" + }, + @block.presentation_mode + ) + ) +) +%> +<%= labelled_form_field(_('Choose how many items will be displayed'), + text_field_tag('block[total_items]', + @block.total_items, :size => 3, :maxlength => 5) + ) +%> +<%= labelled_check_box _('Display blog cover image'), 'block[show_blog_picture]', true, @block.show_blog_picture %> diff --git a/plugins/recent_content/views/box_organizer/_recent_content_block.rhtml b/plugins/recent_content/views/box_organizer/_recent_content_block.rhtml deleted file mode 100644 index 1b59e22..0000000 --- a/plugins/recent_content/views/box_organizer/_recent_content_block.rhtml +++ /dev/null @@ -1,33 +0,0 @@ -<% blogs = @block.parents %> -<% if blogs.empty? %> -

<%= _('No blogs found. Please add a blog in order to configure this block.') %>

-<% end %> -<%= -labelled_form_field(_('Choose which blog should be displayed'), - select_tag( - 'block[selected_folder]', - options_for_select(blogs.map {|node| [node.title, node.id]}, @block.selected_folder) - ) -) -%> -<%= -labelled_form_field(_('Choose how the content should be displayed'), - select_tag( - 'block[presentation_mode]', - options_for_select( - { - _("Title only") => "title_only", - _("Title and abstract") => "title_and_abstract", - _("Full content") => "full_content" - }, - @block.presentation_mode - ) - ) -) -%> -<%= labelled_form_field(_('Choose how many items will be displayed'), - text_field_tag('block[total_items]', - @block.total_items, :size => 3, :maxlength => 5) - ) -%> -<%= labelled_check_box _('Display blog cover image'), 'block[show_blog_picture]', true, @block.show_blog_picture %> -- libgit2 0.21.2