better range text for explore popular

This commit is contained in:
albert
2011-08-15 12:19:09 -04:00
parent dafe322b77
commit c6b1778145
2 changed files with 12 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
module PostSetPresenters
class Popular < Base
attr_accessor :post_set, :tag_set_presenter
delegate :posts, :date, :to => :post_set
delegate :posts, :date, :min_date, :max_date, :to => :post_set
def initialize(post_set)
@post_set = post_set
@@ -30,5 +30,15 @@ module PostSetPresenters
def next_month
1.month.since(date)
end
def range_text
if min_date == max_date
date.strftime("%B %d, %Y")
elsif max_date - min_date == 6
min_date.strftime("Week of %B %d, %Y")
else
date.strftime("Month of %B %Y")
end
end
end
end

View File

@@ -1,6 +1,6 @@
<div id="c-explore-posts">
<div id="a-index">
<h1>Explore: <%= @post_set.min_date %> &ndash; <%= @post_set.max_date %></h1>
<h1>Explore: <%= @post_set.presenter.range_text %></h1>
<%= render "date_explore", :post_set => @post_set %>