From 6ca3b3a6abfc9fb508b337d27e683bf8a76400c3 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 23 Dec 2013 15:33:21 +0100 Subject: Add sidebar_module partial and SidebarPostDecorator class. Also did some code cleanup in PagesControllerDecorator::populate_sidebars. The controller will now populate left and right sidebars (only left for now,) while the SidebarPostDecorator will provide the markup for each post that is to be shown in a sidebar. The plan is to further expand the system with other Sidebar- Decorators, so each item can be rendered using the same in the partial. --- .../controllers/refinery/pages_controller_decorator.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'app/decorators/controllers/refinery') diff --git a/app/decorators/controllers/refinery/pages_controller_decorator.rb b/app/decorators/controllers/refinery/pages_controller_decorator.rb index d86fe39..d49e194 100644 --- a/app/decorators/controllers/refinery/pages_controller_decorator.rb +++ b/app/decorators/controllers/refinery/pages_controller_decorator.rb @@ -5,10 +5,15 @@ ApplicationController.class_eval do protected def populate_sidebars - categories = Refinery::Blog::Category.all - @sidebar_contents = {} - categories.each do |c| - @sidebar_contents[c.title] = c.posts.limit(10) + @sidebar_modules = {:left => {}, :right => {}} + + Refinery::Blog::Category.all.each do |c| + mod = [] + c.posts.limit(5).each do |post| + mod << SidebarPostDecorator.new(post) + end + + @sidebar_modules[:left][c.title] = mod end end end -- cgit v1.2.3