From 25cd3e95a92fff202b50c615716c211ef10c4a73 Mon Sep 17 00:00:00 2001 From: Rodrigo Souto Date: Tue, 8 Jun 2010 12:12:59 -0300 Subject: [PATCH] Article block do not show pagination links with images --- app/helpers/application_helper.rb | 5 +++-- app/models/article_block.rb | 2 +- app/models/uploaded_file.rb | 2 +- app/views/content_viewer/view_page.rhtml | 3 ++- test/unit/article_block_test.rb | 15 +++++++++++++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e86ecfb..90794a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -945,8 +945,9 @@ module ApplicationHelper content_for(:head) { stylesheet_link_tag(*args) } end - def article_to_html(article) - content = article.to_html(:page => params[:npage]) + def article_to_html(article, options = {}) + options.merge(:page => params[:npage]) + content = article.to_html(options) return self.instance_eval(&content) if content.kind_of?(Proc) content end diff --git a/app/models/article_block.rb b/app/models/article_block.rb index 9250fe5..dabaa3f 100644 --- a/app/models/article_block.rb +++ b/app/models/article_block.rb @@ -12,7 +12,7 @@ class ArticleBlock < Block block = self lambda do block_title(block.title) + - (block.article ? article_to_html(block.article) : _('Article not selected yet.')) + (block.article ? article_to_html(block.article, :gallery_view => false) : _('Article not selected yet.')) end end diff --git a/app/models/uploaded_file.rb b/app/models/uploaded_file.rb index 8918583..e56a01b 100644 --- a/app/models/uploaded_file.rb +++ b/app/models/uploaded_file.rb @@ -58,7 +58,7 @@ class UploadedFile < Article article = self if image? lambda do - if article.display_as_gallery? + if article.display_as_gallery? && options[:gallery_view] images = article.parent.images current_index = images.index(article) total_of_images = images.count diff --git a/app/views/content_viewer/view_page.rhtml b/app/views/content_viewer/view_page.rhtml index 308039d..e2f4781 100644 --- a/app/views/content_viewer/view_page.rhtml +++ b/app/views/content_viewer/view_page.rhtml @@ -86,7 +86,8 @@ <% cache(@page.cache_key(params, user)) do %>
"> - <%= article_to_html(@page) %> + <% options = @page.image? ? {:gallery_view => true} : {} %> + <%= article_to_html(@page, options) %>
<% end %> diff --git a/test/unit/article_block_test.rb b/test/unit/article_block_test.rb index b3f7a5c..bb627df 100644 --- a/test/unit/article_block_test.rb +++ b/test/unit/article_block_test.rb @@ -115,6 +115,21 @@ class ArticleBlockTest < Test::Unit::TestCase assert_match(/image/, instance_eval(&block.content)) end + should 'not display gallery pages navigation in content' do + profile = create_user('testuser').person + block = ArticleBlock.new + gallery = fast_create(Folder, :profile_id => profile.id) + gallery.view_as = 'image_gallery' + gallery.save! + image = UploadedFile.create!(:profile => profile, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png'), :parent => gallery) + block.article = image + block.save! + + expects(:image_tag).with(image.public_filename(:display), :class => image.css_class_name, :style => 'max-width: 100%').returns('image') + + assert_no_match(/Previous/, instance_eval(&block.content)) + end + should 'display link to archive if article is an archive' do profile = create_user('testuser').person block = ArticleBlock.new -- libgit2 0.21.2