denny/ShinyCMS-ruby

View on GitHub
plugins/ShinyBlog/app/views/shiny_blog/blog/month.html.erb

Summary

Maintainability
Test Coverage
<%
  if params[:year].to_i != Time.zone.now.year
    @page_title = "Blog posts in #{I18n.t("date.month_names")[params[:month].to_i]} #{params[:year]}"
  elsif params[:month].to_i != Time.zone.now.month
    @page_title = "Blog posts in #{I18n.t("date.month_names")[params[:month].to_i]}"
  else
    @page_title = 'Blog posts this month'
  end
%>

<%= render partial: 'blog/index/page_title' %>

<% @posts.each do |post| %>
<section>
  <%= render partial: 'blog/index/post_header', locals: { post: post } %>

  <% teaser = post.teaser( paragraphs: 3 ) %>
  <%= sanitize teaser %>

  <% read_more = post.body.length > ( teaser.length + 10 ) ? 'read_more' : 'view_post' # 10 is an arbitrary fudge factor for extra newlines etc %>
  <%= render partial: 'blog/index/post_footer', locals:  { post: post, read_more: read_more } %>
</section>
<% end %>

<% if @posts.size == 0 %>
<p>
  <%= t( 'shinycms.empty_list', items: 'blog posts' ) %>
</p>
<% end %>

<% @sidebar_position = 'right' %>
<%= render partial: 'right_sidebar_join' %>
<%= render partial: 'sidebar' %>