diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index db14797..4f1e4a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -30,6 +30,10 @@ module ApplicationHelper include AccountHelper + include BlogHelper + + include ContentViewerHelper + def locale (@page && !@page.language.blank?) ? @page.language : FastGettext.locale end diff --git a/app/models/article_block.rb b/app/models/article_block.rb index bb802be..85fb7c2 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, :gallery_view => false) : _('Article not selected yet.')) + (block.article ? article_to_html(block.article, :gallery_view=>false, :inside_block=>block) : _('Article not selected yet.')) end end diff --git a/app/models/blog.rb b/app/models/blog.rb index 88d2189..71e0501 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -24,8 +24,9 @@ class Blog < Folder # FIXME isn't this too much including just to be able to generate some HTML? include ActionView::Helpers::TagHelper def to_html(options = {}) + me = self lambda do - render :file => 'content_viewer/blog_page' + render :file => 'content_viewer/blog_page', :locals => { :blog=>me, :inside_block=>options[:inside_block] } end end diff --git a/app/views/content_viewer/blog_page.rhtml b/app/views/content_viewer/blog_page.rhtml index 4eba287..52bb080 100644 --- a/app/views/content_viewer/blog_page.rhtml +++ b/app/views/content_viewer/blog_page.rhtml @@ -1,13 +1,19 @@ -<% add_rss_feed_to_head(@page.name, @page.feed.url) if @page.blog? && @page.feed %> +<% add_rss_feed_to_head(blog.name, blog.feed.url) if blog.blog? && blog.feed %> -<%= content_tag('em', _('(external feed was not loaded yet)'), :id => 'external-feed-info', :class => 'metadata') if @page.blog? && @page.external_feed && @page.external_feed.enabled && @page.external_feed.fetched_at.nil? %> +<%= content_tag('em', _('(external feed was not loaded yet)'), :id => 'external-feed-info', :class => 'metadata') if blog.blog? && blog.external_feed && blog.external_feed.enabled && blog.external_feed.fetched_at.nil? %>
- <%= @page.body %> + <%= blog.body %>

- <%= (@page.empty? ? content_tag('em', _('(no posts)')) : list_posts(@posts, @page.visualization_format)) %> + <%= + posts = @posts + if inside_block + posts = blog.posts.paginate(:page=>1, :per_page=>1) + end + (blog.empty? ? content_tag('em', _('(no posts)')) : list_posts(posts, blog.visualization_format)) + %>
diff --git a/test/integration/blocks_integration_test.rb b/test/integration/blocks_integration_test.rb new file mode 100644 index 0000000..2a031c5 --- /dev/null +++ b/test/integration/blocks_integration_test.rb @@ -0,0 +1,18 @@ +require "#{File.dirname(__FILE__)}/../test_helper" + +class BlocksIntegrationTest < ActionController::IntegrationTest + + should "allow blog as block content" do + profile = fast_create(Profile) + blog = fast_create(Blog, :name => 'Blog', :profile_id => profile.id) + post = fast_create(TinyMceArticle, :name => "A Post", :profile_id => profile.id, :parent_id => blog.id, :body => 'Lorem ipsum dolor sit amet') + block = ArticleBlock.new + block.article = blog + profile.boxes << Box.new + profile.boxes.first.blocks << block + + get "/profile/#{profile.identifier}" + assert_match(/Lorem ipsum dolor sit amet/, @response.body) + end + +end -- libgit2 0.21.2