From 024c31bc4c52f04e94fcca116d05dcc0a4aa435a Mon Sep 17 00:00:00 2001 From: Breon Knight Date: Fri, 5 Feb 2016 14:13:14 -0800 Subject: [PATCH 1/2] Fixes to lib/archives_sidebar/lib/archives_sidebar.rb showing the incorrect date --- lib/archives_sidebar/lib/archives_sidebar.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/archives_sidebar/lib/archives_sidebar.rb b/lib/archives_sidebar/lib/archives_sidebar.rb index b77559ca6..e0c7cea26 100644 --- a/lib/archives_sidebar/lib/archives_sidebar.rb +++ b/lib/archives_sidebar/lib/archives_sidebar.rb @@ -30,7 +30,7 @@ def parse_request(_contents, _params) article_counts = Content.find_by_sql(["select count(*) as count, #{date_func} from contents where type='Article' and published = ? and published_at < ? group by year,month order by year desc,month desc limit ? ", true, Time.now, count.to_i]) @archives = article_counts.map do |entry| - month = (entry.month.to_i%12)+1 + month = (entry.month.to_i%12) year = entry.year.to_i { name: I18n.l(Date.new(year, month), format: '%B %Y'), From faa43ea60fc93a34b2bb842bd33864e1ac97da18 Mon Sep 17 00:00:00 2001 From: Breon Knight Date: Fri, 5 Feb 2016 14:46:14 -0800 Subject: [PATCH 2/2] added updates to formating --- .../app/views/archives_sidebar/_content.html.erb | 2 +- lib/archives_sidebar/lib/archives_sidebar.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/archives_sidebar/app/views/archives_sidebar/_content.html.erb b/lib/archives_sidebar/app/views/archives_sidebar/_content.html.erb index 7d74c3347..6a8a29b1a 100644 --- a/lib/archives_sidebar/app/views/archives_sidebar/_content.html.erb +++ b/lib/archives_sidebar/app/views/archives_sidebar/_content.html.erb @@ -5,7 +5,7 @@ <% sidebar.archives.each do |month| %> <% counter = sidebar.show_count ? "(#{month[:article_count]})" : "" %>
  • - <%= link_to"#{month[:name]} #{counter}".html_safe, articles_by_month_path( month[:year], "%02i" % (month[:month]+1) ) %> + <%= link_to"#{month[:name]} #{counter}".html_safe, articles_by_month_path( month[:year], "%02i" % (month[:month]) ) %>
  • <% end %> diff --git a/lib/archives_sidebar/lib/archives_sidebar.rb b/lib/archives_sidebar/lib/archives_sidebar.rb index e0c7cea26..a65c419b8 100644 --- a/lib/archives_sidebar/lib/archives_sidebar.rb +++ b/lib/archives_sidebar/lib/archives_sidebar.rb @@ -30,11 +30,11 @@ def parse_request(_contents, _params) article_counts = Content.find_by_sql(["select count(*) as count, #{date_func} from contents where type='Article' and published = ? and published_at < ? group by year,month order by year desc,month desc limit ? ", true, Time.now, count.to_i]) @archives = article_counts.map do |entry| - month = (entry.month.to_i%12) + month = (entry.month.to_i) year = entry.year.to_i { name: I18n.l(Date.new(year, month), format: '%B %Y'), - month: month - 1, + month: month, year: year, article_count: entry.count }