diff --git a/app/helpers/blog_helper.rb b/app/helpers/blog_helper.rb index a185502..e29cf80 100644 --- a/app/helpers/blog_helper.rb +++ b/app/helpers/blog_helper.rb @@ -6,7 +6,13 @@ module BlogHelper @article = article hidden_field_tag('article[published]', 1) + hidden_field_tag('article[accept_comments]', 0) + - visibility_options(article,tokenized_children) + visibility_options(article,tokenized_children) + + content_tag('h4', _('Visualization of posts')) + + content_tag( + 'div', + check_box(:article, :display_preview) + + content_tag('label', _('I want to display the preview of posts before the text'), :for => 'article_display_preview') + ) end def cms_label_for_new_children diff --git a/app/models/article.rb b/app/models/article.rb index 44bc601..94c3664 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -9,7 +9,7 @@ class Article < ActiveRecord::Base :highlighted, :notify_comments, :display_hits, :slug, :external_feed_builder, :display_versions, :external_link, :image_builder, :show_to_followers, - :author + :author, :display_preview acts_as_having_image @@ -643,6 +643,12 @@ class Article < ActiveRecord::Base false end + settings_items :display_preview, :type => :boolean, :default => false + + def display_preview? + false + end + def image? false end diff --git a/app/models/text_article.rb b/app/models/text_article.rb index 66dbe9f..9cf6870 100644 --- a/app/models/text_article.rb +++ b/app/models/text_article.rb @@ -41,4 +41,8 @@ class TextArticle < Article end end + def display_preview? + parent && parent.kind_of?(Blog) && parent.display_preview + end + end diff --git a/app/views/content_viewer/_article_title.html.erb b/app/views/content_viewer/_article_title.html.erb index 240b8b7..241ed90 100644 --- a/app/views/content_viewer/_article_title.html.erb +++ b/app/views/content_viewer/_article_title.html.erb @@ -7,7 +7,7 @@ <% end %> <%= render :partial => "publishing_info" %> - <% unless @page.abstract.blank? %> + <% if @page.display_preview? %>
<%= @page.lead %>
diff --git a/test/unit/article_test.rb b/test/unit/article_test.rb index 937517e..57e4cc0 100644 --- a/test/unit/article_test.rb +++ b/test/unit/article_test.rb @@ -2214,4 +2214,9 @@ class ArticleTest < ActiveSupport::TestCase assert !a.display_media_panel? end + should 'have display_preview' do + a = Article.new(:display_preview => false) + assert !a.display_preview? + end + end diff --git a/test/unit/text_article_test.rb b/test/unit/text_article_test.rb index ae981f2..43ce800 100644 --- a/test/unit/text_article_test.rb +++ b/test/unit/text_article_test.rb @@ -109,4 +109,12 @@ class TextArticleTest < ActiveSupport::TestCase assert text.translatable? end + should 'display preview when configured on parent that is a blog' do + person = fast_create(Person) + post = fast_create(TextArticle, :profile_id => person.id) + blog = Blog.new(:display_preview => true) + post.parent = blog + assert post.display_preview? + end + end -- libgit2 0.21.2