aboutsummaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/sidebar_blog_category.rb12
-rw-r--r--app/models/sidebar_module.rb13
2 files changed, 25 insertions, 0 deletions
diff --git a/app/models/sidebar_blog_category.rb b/app/models/sidebar_blog_category.rb
new file mode 100644
index 0000000..53d15af
--- /dev/null
+++ b/app/models/sidebar_blog_category.rb
@@ -0,0 +1,12 @@
+class SidebarBlogCategory < SidebarModule
+ def initialize(category)
+ @title = category.title
+ @position = category.sidebar_position
+ @posts = category.posts.recent(5)
+ end
+
+ def body
+ @posts
+ end
+
+end
diff --git a/app/models/sidebar_module.rb b/app/models/sidebar_module.rb
new file mode 100644
index 0000000..1e9bde1
--- /dev/null
+++ b/app/models/sidebar_module.rb
@@ -0,0 +1,13 @@
+class SidebarModule
+ attr_reader :title, :body, :position
+
+ def initialize(title, body, pos)
+ @title = title
+ @body = body
+ @position = pos
+ end
+
+ def to_partial_path
+ "sidebar_modules/#{self.class.to_s.underscore}"
+ end
+end