aboutsummaryrefslogtreecommitdiffstats
path: root/app/decorators/models
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2013-12-23 15:33:21 +0100
committerHarald Eilertsen <haraldei@anduin.net>2013-12-23 15:33:21 +0100
commit6ca3b3a6abfc9fb508b337d27e683bf8a76400c3 (patch)
tree4822ad5af4b4aecb72584da1f9ca8ae952857786 /app/decorators/models
parenta959ac78e251f862251358ee2cf441b66c829ded (diff)
downloadhmnoweb-6ca3b3a6abfc9fb508b337d27e683bf8a76400c3.tar.gz
hmnoweb-6ca3b3a6abfc9fb508b337d27e683bf8a76400c3.tar.bz2
hmnoweb-6ca3b3a6abfc9fb508b337d27e683bf8a76400c3.zip
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.
Diffstat (limited to 'app/decorators/models')
-rw-r--r--app/decorators/models/sidebar_post_decorator.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/decorators/models/sidebar_post_decorator.rb b/app/decorators/models/sidebar_post_decorator.rb
new file mode 100644
index 0000000..14cbe7c
--- /dev/null
+++ b/app/decorators/models/sidebar_post_decorator.rb
@@ -0,0 +1,18 @@
+require 'delegate'
+
+class SidebarPostDecorator < SimpleDelegator
+ include ActionView::Helpers::TagHelper
+ include ActionView::Helpers::TextHelper
+
+ def initialize(post)
+ super(post)
+ end
+
+ def title
+ content_tag(:h2, super)
+ end
+
+ def body
+ content_tag(:div, sanitize(truncate(super, :length => 32, :separator => ' ')))
+ end
+end