From de85692eb4cb19112e5b3a6d68c8867c65ff0da0 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 25 Dec 2013 00:15:57 +0100 Subject: Clean up sidebar modules. Rewrite the _sidebar_module partial to render only one module, and to not make any assumptions about the contents of a module. (Except that it has a title and a body.) Move the actual module logic into model classes, and use the ActiveModel magic to have it find it's own partial. Now we have the view logic for each module in it's own partial that in turn renders as part of the _sidebar_module partial. Only implementation this far is the blog-category module listing the latest blog entries within each category. --- .../controllers/refinery/pages_controller_decorator.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'app/decorators') diff --git a/app/decorators/controllers/refinery/pages_controller_decorator.rb b/app/decorators/controllers/refinery/pages_controller_decorator.rb index 034939c..cc30030 100644 --- a/app/decorators/controllers/refinery/pages_controller_decorator.rb +++ b/app/decorators/controllers/refinery/pages_controller_decorator.rb @@ -7,19 +7,10 @@ ApplicationController.class_eval do protected def populate_sidebars - @sidebar_modules = {} + @sidebar_modules = [] Refinery::Blog::Category.all.each do |c| - pos = c.sidebar_position - unless pos == 0 - mod = [] - c.posts.limit(5).each do |post| - mod << SidebarPostDecorator.new(post) - end - - @sidebar_modules[pos] = {} unless @sidebar_modules[pos] - @sidebar_modules[pos][c.title] = mod - end + @sidebar_modules << SidebarBlogCategory.new(c) end end -- cgit v1.2.3