Commit 25cd3e95a92fff202b50c615716c211ef10c4a73

Authored by Rodrigo Souto
Committed by Joenio Costa
1 parent bb3c6485

Article block do not show pagination links with images

	* Added an option to the Article#to_html named :gallery_view.
	  This option is used to contextualize the html that should be
	  generated.

(ActionItem1545)
app/helpers/application_helper.rb
... ... @@ -945,8 +945,9 @@ module ApplicationHelper
945 945 content_for(:head) { stylesheet_link_tag(*args) }
946 946 end
947 947  
948   - def article_to_html(article)
949   - content = article.to_html(:page => params[:npage])
  948 + def article_to_html(article, options = {})
  949 + options.merge(:page => params[:npage])
  950 + content = article.to_html(options)
950 951 return self.instance_eval(&content) if content.kind_of?(Proc)
951 952 content
952 953 end
... ...
app/models/article_block.rb
... ... @@ -12,7 +12,7 @@ class ArticleBlock < Block
12 12 block = self
13 13 lambda do
14 14 block_title(block.title) +
15   - (block.article ? article_to_html(block.article) : _('Article not selected yet.'))
  15 + (block.article ? article_to_html(block.article, :gallery_view => false) : _('Article not selected yet.'))
16 16 end
17 17 end
18 18  
... ...
app/models/uploaded_file.rb
... ... @@ -58,7 +58,7 @@ class UploadedFile < Article
58 58 article = self
59 59 if image?
60 60 lambda do
61   - if article.display_as_gallery?
  61 + if article.display_as_gallery? && options[:gallery_view]
62 62 images = article.parent.images
63 63 current_index = images.index(article)
64 64 total_of_images = images.count
... ...
app/views/content_viewer/view_page.rhtml
... ... @@ -86,7 +86,8 @@
86 86  
87 87 <% cache(@page.cache_key(params, user)) do %>
88 88 <div class="<%="article-body article-body-" + @page.css_class_name %>">
89   - <%= article_to_html(@page) %>
  89 + <% options = @page.image? ? {:gallery_view => true} : {} %>
  90 + <%= article_to_html(@page, options) %>
90 91 <br style="clear:both" />
91 92 </div> <!-- end class="article-body" -->
92 93 <% end %>
... ...
test/unit/article_block_test.rb
... ... @@ -115,6 +115,21 @@ class ArticleBlockTest &lt; Test::Unit::TestCase
115 115 assert_match(/image/, instance_eval(&block.content))
116 116 end
117 117  
  118 + should 'not display gallery pages navigation in content' do
  119 + profile = create_user('testuser').person
  120 + block = ArticleBlock.new
  121 + gallery = fast_create(Folder, :profile_id => profile.id)
  122 + gallery.view_as = 'image_gallery'
  123 + gallery.save!
  124 + image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery)
  125 + block.article = image
  126 + block.save!
  127 +
  128 + expects(:image_tag).with(image.public_filename(:display), :class => image.css_class_name, :style => 'max-width: 100%').returns('image')
  129 +
  130 + assert_no_match(/Previous/, instance_eval(&block.content))
  131 + end
  132 +
118 133 should 'display link to archive if article is an archive' do
119 134 profile = create_user('testuser').person
120 135 block = ArticleBlock.new
... ...