Commit 6ce76a6eb0139ed5639853763c80e7809018d9e1

Authored by Antonio Terceiro
2 parents 05d99f0e 3b3e0243

Merge branch 'AI3218_article_block_bug' into 'master'

Ai3218 article block bug

Fixing ArticleBlock blog's pagination bug: http://noosfero.org/Development/ActionItem3218

See merge request !301
app/helpers/blog_helper.rb
@@ -17,13 +17,13 @@ module BlogHelper @@ -17,13 +17,13 @@ module BlogHelper
17 _('Configure blog') 17 _('Configure blog')
18 end 18 end
19 19
20 - def list_posts(articles, format = 'full') 20 + def list_posts(articles, format = 'full', paginate = true)
21 pagination = will_paginate(articles, { 21 pagination = will_paginate(articles, {
22 :param_name => 'npage', 22 :param_name => 'npage',
23 :previous_label => _('« Newer posts'), 23 :previous_label => _('« Newer posts'),
24 :next_label => _('Older posts »'), 24 :next_label => _('Older posts »'),
25 :params => {:action=>"view_page", :page=>articles.first.parent.path.split('/'), :controller=>"content_viewer"} 25 :params => {:action=>"view_page", :page=>articles.first.parent.path.split('/'), :controller=>"content_viewer"}
26 - }) if articles.present? 26 + }) if articles.present? && paginate
27 content = [] 27 content = []
28 artic_len = articles.length 28 artic_len = articles.length
29 articles.each_with_index{ |art,i| 29 articles.each_with_index{ |art,i|
app/views/content_viewer/blog_page.html.erb
@@ -9,13 +9,15 @@ @@ -9,13 +9,15 @@
9 </div> 9 </div>
10 <hr class="pre-posts"/> 10 <hr class="pre-posts"/>
11 <div class="blog-posts"> 11 <div class="blog-posts">
  12 + <% paginate = true %>
12 <%= 13 <%=
13 posts = @posts 14 posts = @posts
14 format = blog.visualization_format 15 format = blog.visualization_format
15 if inside_block 16 if inside_block
16 posts = blog.posts.paginate(:page=>1, :per_page=>inside_block.posts_per_page) 17 posts = blog.posts.paginate(:page=>1, :per_page=>inside_block.posts_per_page)
17 format = inside_block.visualization_format 18 format = inside_block.visualization_format
  19 + paginate = false
18 end 20 end
19 - (blog.empty? ? content_tag('em', _('(no posts)')) : list_posts(posts, format)) 21 + (blog.empty? ? content_tag('em', _('(no posts)')) : list_posts(posts, format, paginate))
20 %> 22 %>
21 </div> 23 </div>