Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Month sorting #30

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ gem 'recaptcha', require: 'recaptcha/rails', branch: 'rails3'
gem 'rubypants', '~> 0.2.0'
gem 'twitter', '~> 5.14.0'
gem 'uuidtools', '~> 2.1.1'
gem 'psych', '~> 2.0', '>= 2.0.17'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to add this to the gemfile?


group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<% unless sidebar.archives.blank? %>
<h3 class="sidebar_title"><%= sidebar.title %></h3>
<div class="sidebar_body">
<ul id="archives">
<h3 class="sidebar-title"><%= sidebar.title %></h3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this html change relevant to issue #2?

<div class="sidebar-body">
<ul>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure this ID isn't used by some other code ? (JS, RSpec, etc)

<% sidebar.archives.each do |month| %>
<% counter = sidebar.show_count ? "<em>(#{month[:article_count]})</em>" : "" %>
<li>
<%= 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]) ) %>
</li>
<% end %>
</ul>
Expand Down
6 changes: 3 additions & 3 deletions lib/archives_sidebar/lib/archives_sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)+1
year = entry.year.to_i
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
}
Expand Down