diff --git a/app/helpers/blog_helper.rb b/app/helpers/blog_helper.rb index 407d399..a74650f 100644 --- a/app/helpers/blog_helper.rb +++ b/app/helpers/blog_helper.rb @@ -18,7 +18,8 @@ module BlogHelper pagination = will_paginate(articles, { :param_name => 'npage', :previous_label => _('« Newer posts'), - :next_label => _('Older posts »') + :next_label => _('Older posts »'), + :params => {:action=>"view_page", :page=>articles.first.parent.path.split('/'), :controller=>"content_viewer"} }) content = [] artic_len = articles.length diff --git a/app/models/article_block.rb b/app/models/article_block.rb index 85fb7c2..0fe811e 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -49,4 +49,14 @@ class ArticleBlock < Block self.box.owner.kind_of?(Environment) ? self.box.owner.portal_community.articles : self.box.owner.articles end + def posts_per_page + self.settings[:posts_per_page] or 1 + end + + def posts_per_page= value + value = value.to_i + self.settings[:posts_per_page] = value if value > 0 + end + + settings_items :visualization_format, :type => :string, :default => 'short' end diff --git a/app/views/box_organizer/_article_block.rhtml b/app/views/box_organizer/_article_block.rhtml index 5de82d8..7eccaa1 100644 --- a/app/views/box_organizer/_article_block.rhtml +++ b/app/views/box_organizer/_article_block.rhtml @@ -1,10 +1,23 @@ -
+
<%= _("You don't have an community defined as the portal community. Define it before use this block properly.") %>
<% else %> - <% articles = @block.available_articles.select {|article| !article.folder? } %> - <%= select_tag('block[article_id]', options_for_select_with_title(articles.map {|item| [item.path, item.id]}, @block.article ? @block.article.id : nil)) %> + <% + articles = @block.available_articles.select {|a| !a.folder? || a.blog? } + firstText = articles[articles.find_index{|a| a.kind_of?TextArticle}||-1] + selected = @block.article || firstText + %> + <%= select_tag('block[article_id]', options_for_select_with_title(articles.map {|item| [item.path, item.id]}, selected.id), :onchange => 'jQuery("#block_blog_options").toggle(this.blogs.indexOf(this.value) != -1)') %> +Wasserstoffbombe
') + fast_create(TinyMceArticle, :name => "A Post", :profile_id => profile.id, :parent_id => blog.id, :body => 'Lorem ipsum dolor sit amet
Second paragraph
') block = ArticleBlock.new block.article = blog profile.boxes << Box.new profile.boxes.first.blocks << block - - get "/profile/#{profile.identifier}" + return block + end + + should 'allow blog as article block content' do + block = blog_on_article_block_bootstrap + get "/profile/#{block.owner.identifier}" + assert_match(/Lorem ipsum dolor sit amet/, @response.body) + end + + should 'display short version for block posts on article block' do + block = blog_on_article_block_bootstrap + get "/profile/#{block.owner.identifier}" + assert_no_match(/Second paragraph/, @response.body) + end + + should 'display full version for block posts on article block' do + block = blog_on_article_block_bootstrap + block.visualization_format = 'full' + block.save! + get "/profile/#{block.owner.identifier}" + assert_match(/Second paragraph/, @response.body) + end + + should 'display configured number of blog posts on article block' do + block = blog_on_article_block_bootstrap + block.posts_per_page = 2 + block.save! + get "/profile/#{block.owner.identifier}" assert_match(/Lorem ipsum dolor sit amet/, @response.body) + assert_match(/Wasserstoffbombe/, @response.body) + end + + should 'link correctly in pagination' do + block = blog_on_article_block_bootstrap + p = block.owner + b = block.article + f = fast_create(Folder, :name => 'Folder1', :profile_id => p.id) + b.parent = f + b.save! + get "/profile/#{block.owner.identifier}" + assert_tag :tag => 'a', :attributes => { :href => "/#{p.identifier}/#{f.slug}/#{b.slug}?npage=2" } end end -- libgit2 0.21.2