Skip to content

Instantly share code, notes, and snippets.

@bkeepers
Created October 17, 2008 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bkeepers/17481 to your computer and use it in GitHub Desktop.
Save bkeepers/17481 to your computer and use it in GitHub Desktop.
Archives section from http://opensoul.org
<table class="archives">
<thead>
<tr>
<th class="month"></th>
<th class="month">Jan</th>
<th class="month">Feb</th>
<th class="month">Mar</th>
<th class="month">Apr</th>
<th class="month">May</th>
<th class="month">Jun</th>
<th class="month">Jul</th>
<th class="month">Aug</th>
<th class="month">Sep</th>
<th class="month">Oct</th>
<th class="month">Nov</th>
<th class="month">Dec</th>
</tr>
</thead>
<tbody>
{% for year in section.years %}
<tr>
<th class="year">{{ year }}</th>
{% for n in (1..12) %}
<td>
{% capture: 'date' %}{{year}}-{{n}}-1{% endcapture %}
{{ date | parse_date | assign_to: 'month' }}
{{ section | monthly_articles: month | assign_to: 'articles' }}
{% unless articles == empty %}
<a href="{{ section | monthly_url: month }}" title="Archives for {{ month | strftime: '%B %Y'}}">{{ articles | size }}</a>
{% endunless %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
diff --git a/app/drops/section_drop.rb b/app/drops/section_drop.rb
index 186772d..457902f 100644
--- a/app/drops/section_drop.rb
+++ b/app/drops/section_drop.rb
@@ -54,4 +54,8 @@ class SectionDrop < BaseDrop
@months
end
+
+ def years
+ (earliest_month.year..Time.now.utc.year).to_a.reverse
+ end
end
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment