Commit 25cd3e95a92fff202b50c615716c211ef10c4a73
Committed by
Joenio Costa
1 parent
bb3c6485
Exists in
master
and in
29 other branches
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)
Showing
5 changed files
with
22 additions
and
5 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -945,8 +945,9 @@ module ApplicationHelper | @@ -945,8 +945,9 @@ module ApplicationHelper | ||
945 | content_for(:head) { stylesheet_link_tag(*args) } | 945 | content_for(:head) { stylesheet_link_tag(*args) } |
946 | end | 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 | return self.instance_eval(&content) if content.kind_of?(Proc) | 951 | return self.instance_eval(&content) if content.kind_of?(Proc) |
951 | content | 952 | content |
952 | end | 953 | end |
app/models/article_block.rb
@@ -12,7 +12,7 @@ class ArticleBlock < Block | @@ -12,7 +12,7 @@ class ArticleBlock < Block | ||
12 | block = self | 12 | block = self |
13 | lambda do | 13 | lambda do |
14 | block_title(block.title) + | 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 | end | 16 | end |
17 | end | 17 | end |
18 | 18 |
app/models/uploaded_file.rb
@@ -58,7 +58,7 @@ class UploadedFile < Article | @@ -58,7 +58,7 @@ class UploadedFile < Article | ||
58 | article = self | 58 | article = self |
59 | if image? | 59 | if image? |
60 | lambda do | 60 | lambda do |
61 | - if article.display_as_gallery? | 61 | + if article.display_as_gallery? && options[:gallery_view] |
62 | images = article.parent.images | 62 | images = article.parent.images |
63 | current_index = images.index(article) | 63 | current_index = images.index(article) |
64 | total_of_images = images.count | 64 | total_of_images = images.count |
app/views/content_viewer/view_page.rhtml
@@ -86,7 +86,8 @@ | @@ -86,7 +86,8 @@ | ||
86 | 86 | ||
87 | <% cache(@page.cache_key(params, user)) do %> | 87 | <% cache(@page.cache_key(params, user)) do %> |
88 | <div class="<%="article-body article-body-" + @page.css_class_name %>"> | 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 | <br style="clear:both" /> | 91 | <br style="clear:both" /> |
91 | </div> <!-- end class="article-body" --> | 92 | </div> <!-- end class="article-body" --> |
92 | <% end %> | 93 | <% end %> |
test/unit/article_block_test.rb
@@ -115,6 +115,21 @@ class ArticleBlockTest < Test::Unit::TestCase | @@ -115,6 +115,21 @@ class ArticleBlockTest < Test::Unit::TestCase | ||
115 | assert_match(/image/, instance_eval(&block.content)) | 115 | assert_match(/image/, instance_eval(&block.content)) |
116 | end | 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 | should 'display link to archive if article is an archive' do | 133 | should 'display link to archive if article is an archive' do |
119 | profile = create_user('testuser').person | 134 | profile = create_user('testuser').person |
120 | block = ArticleBlock.new | 135 | block = ArticleBlock.new |