Sha256: f2161a367a49c4e8d907dff173e3f8d3682f61379631b98728cc51b1a7110d3c
Contents?: true
Size: 988 Bytes
Versions: 2
Compression:
Stored size: 988 Bytes
Contents
module Panda module CMS module PostsHelper def display_post_path(post) # Unescape the path for display purposes CGI.unescape(post.slug) end def posts_months_menu Rails.cache.fetch("panda_cms_posts_months_menu", expires_in: 1.hour) do Panda::CMS::Post .where(status: :active) .select( Arel.sql("DATE_TRUNC('month', published_at) as month"), Arel.sql("COUNT(*) as post_count") ) .group(Arel.sql("DATE_TRUNC('month', published_at)")) .order(Arel.sql("DATE_TRUNC('month', published_at) DESC")) .map do |result| date = result.month { year: date.strftime("%Y"), month: date.strftime("%m"), month_name: "#{date.strftime("%B")} #{date.year}", post_count: result.post_count } end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
panda-cms-0.7.3 | app/helpers/panda/cms/posts_helper.rb |
panda-cms-0.7.2 | app/helpers/panda/cms/posts_helper.rb |