aboutsummaryrefslogtreecommitdiffstats
path: root/app/helpers
diff options
context:
space:
mode:
authorJoe Sak <joe@joesak.com>2010-11-18 10:52:10 -0600
committerJoe Sak <joe@joesak.com>2010-11-18 10:52:10 -0600
commitdc3cbaa0918c5194ae0f1e80024611c614be612f (patch)
tree148ec2e27b58295bfbfda2be12863d398d026713 /app/helpers
parentc610fee93b9e20e083c68d99ee941c6b4f507cf0 (diff)
downloadrefinerycms-blog-dc3cbaa0918c5194ae0f1e80024611c614be612f.tar.gz
refinerycms-blog-dc3cbaa0918c5194ae0f1e80024611c614be612f.tar.bz2
refinerycms-blog-dc3cbaa0918c5194ae0f1e80024611c614be612f.zip
Archive listing, views, helpers
@page added to PostsController TODO: language file stuff -- I left comments in the view files where these belong. I don't know how to test them from here
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/blog_posts_helper.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/helpers/blog_posts_helper.rb b/app/helpers/blog_posts_helper.rb
new file mode 100644
index 0000000..fb90e94
--- /dev/null
+++ b/app/helpers/blog_posts_helper.rb
@@ -0,0 +1,22 @@
+module BlogPostsHelper
+ def blog_archive_list
+ posts = BlogPost.select('published_at').all_previous
+ return nil if posts.blank?
+ html = '<section id="blog_archive_list"><h1>Archives</h1><nav>'
+ links = []
+
+ posts.each do |e|
+ links << e.published_at.strftime('%m/%Y')
+ end
+ links.uniq!
+ links.each do |l|
+ year = l.split('/')[1]
+ month = l.split('/')[0]
+ count = BlogPost.by_archive(Time.parse(l)).size
+ text = "#{Date::MONTHNAMES[month.to_i]} #{year} (#{count})"
+ html += link_to(text, archive_blog_posts_path(:year => year, :month => month))
+ end
+ html += '</nav></section>'
+ html.html_safe
+ end
+end