Fine tune the frontpage

This commit is contained in:
Ariejan de Vroom 2013-03-24 23:01:15 +01:00
parent f939698c61
commit 0e5510a3c1
3 changed files with 34 additions and 11 deletions

View File

@ -68,7 +68,14 @@ ol.posts {
list-style-type: none; list-style-type: none;
list-style-image: none; list-style-image: none;
padding: 0; padding: 0;
margin: 0; margin: 0 0 24px 0;
li {
span.date {
width: 50px;
display: inline-block;
}
}
} }
pre, .plaincode{ pre, .plaincode{

View File

@ -5,12 +5,20 @@ title: Home
%h2 Ariejan's Blog %h2 Ariejan's Blog
.content_wrap.nobg .content_wrap.nobg
%section#middle_content %section#middle_content
#posts :markdown
- articles_by_year.each do |year, articles| Hi! Welcome to _ariejan.net_. Since 1999 this has been my digital home in one form or the other. I hope you find what you're looking for.
%h2= year
%ol.posts #posts
- articles.each do |article| %h3 Recent blog posts
%li
%span.date= get_short_date(article) - articles_by_year_for_two_columns.each do |column_articles|
= link_to article[:title], article.path .one_half
- column_articles.each do |year, articles|
%h2= year
%ol.posts
- articles.each do |article|
%li
%span.date= get_short_date(article)
= link_to article[:title], article.path

View File

@ -1,13 +1,21 @@
module PostHelper module PostHelper
def articles_by_year def articles_by_year(articles)
hash = Hash.new { |h, k| h[k] = [] } hash = Hash.new { |h, k| h[k] = [] }
sorted_articles.inject(hash) do |output, article| articles.inject(hash) do |output, article|
year = attribute_to_time(article[:created_at]).year year = attribute_to_time(article[:created_at]).year
output[year] << article output[year] << article
output output
end end
end end
def articles_by_year_for_two_columns
half_mark = sorted_articles.size / 2
half_one = sorted_articles[0..half_mark-1]
half_two = sorted_articles[half_mark..-1]
[articles_by_year(half_one), articles_by_year(half_two)]
end
def get_short_date(post) def get_short_date(post)
attribute_to_time(post[:created_at]).strftime('%d %b') attribute_to_time(post[:created_at]).strftime('%d %b')
end end