From 771532124d5486eb78c22f1c638ff647883d46b8 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 24 Dec 2013 14:15:45 +0100 Subject: Populate home page with blog entries. I would like to just render the refinery/blog/index template for this, but I did not find a way to do it, so I copied it instead. May need to revisit this if upgrading to a new refinery or blog engine. --- .../refinery/pages_controller_decorator.rb | 12 ++++++++++++ app/helpers/home_page_helper.rb | 3 +++ app/views/refinery/pages/home.html.erb | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 app/helpers/home_page_helper.rb create mode 100644 app/views/refinery/pages/home.html.erb (limited to 'app') diff --git a/app/decorators/controllers/refinery/pages_controller_decorator.rb b/app/decorators/controllers/refinery/pages_controller_decorator.rb index da020da..034939c 100644 --- a/app/decorators/controllers/refinery/pages_controller_decorator.rb +++ b/app/decorators/controllers/refinery/pages_controller_decorator.rb @@ -1,6 +1,8 @@ ApplicationController.class_eval do + include Refinery::Blog::ControllerHelper before_filter :populate_sidebars + before_filter :populate_home_page, :only => [:home] protected @@ -20,4 +22,14 @@ ApplicationController.class_eval do end end end + + def populate_home_page + # + # These methods are included from Refinery::Blog::ControllerHelper + # Makes sure everyting is in place for the home page view template. + # + find_all_blog_posts + find_all_blog_categories + find_tags + end end diff --git a/app/helpers/home_page_helper.rb b/app/helpers/home_page_helper.rb new file mode 100644 index 0000000..8e165d0 --- /dev/null +++ b/app/helpers/home_page_helper.rb @@ -0,0 +1,3 @@ +module HomePageHelper + include Refinery::Blog::PostsHelper +end diff --git a/app/views/refinery/pages/home.html.erb b/app/views/refinery/pages/home.html.erb new file mode 100644 index 0000000..2e8837c --- /dev/null +++ b/app/views/refinery/pages/home.html.erb @@ -0,0 +1,20 @@ +<% content_for :body_content_left do %> + <%= raw @page.content_for(Refinery::Pages.default_parts.first.to_sym) if Refinery::Pages.default_parts.any? %> + + <% if @posts.any? %> +
+ <%= render :partial => "/refinery/blog/shared/post", :collection => @posts %> + <%= will_paginate @posts %> +
+ <% else %> +

<%= t('.no_blog_articles_yet') %>

+ <% end %> +<% end %> + +<% content_for :body_content_right_prepend do -%> + <%= raw @page.content_for(Refinery::Pages.default_parts.second.to_sym) %> +<% end if Refinery::Pages.default_parts.many? -%> +<%= render :partial => '/refinery/blog/shared/body_content_right' %> + +<%= render :partial => "/refinery/content_page" %> +<% content_for :stylesheets, stylesheet_link_tag('refinery/blog/frontend') %> -- cgit v1.2.3