Improved front page

This commit is contained in:
Ariejan de Vroom 2013-05-21 21:53:36 +02:00
parent beb6c1e17f
commit e6b1a49ed9
3 changed files with 35 additions and 53 deletions

View File

@ -75,14 +75,15 @@ ul.tla {
} }
ol.posts { ol.posts {
list-style-type: square; list-style-type: none;
color: #e0e0e0;
list-style-image: none; list-style-image: none;
padding: 0; padding: 0;
margin: 0 0 24px 0; margin: 0 0 24px 0;
font-family: 'Open Sans';
font-weight: 400;
li { li {
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
@ -90,17 +91,7 @@ ol.posts {
span.date { span.date {
display: inline-block; display: inline-block;
float: left; text-align: left;
width: 60px;
margin-top: -1px;
margin-right: 14px;
text-align: right;
font-size: 11px;
color: #a0a0a0;
} }
} }
} }

View File

@ -5,11 +5,10 @@ title: Ariejan's Blog
%section#middle_content %section#middle_content
#posts #posts
- articles_by_year_for_two_columns.each do |column_articles| - articles_by_year(sorted_articles).each do |year, articles|
.one_half
- column_articles.each do |year, articles|
%ol.posts %ol.posts
- articles.each do |article| - articles.each do |article|
%li %li
%span.date= get_short_date(article) %span.date= get_short_date(article)
= link_to article[:title], article.path, title: article[:title] = link_to article[:title], article.path, title: article[:title]

View File

@ -1,4 +1,4 @@
module PostHelper module PostHelper
def articles_by_year(articles) def articles_by_year(articles)
hash = Hash.new { |h, k| h[k] = [] } hash = Hash.new { |h, k| h[k] = [] }
articles.inject(hash) do |output, article| articles.inject(hash) do |output, article|
@ -8,14 +8,6 @@
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('%Y-%m-%d') attribute_to_time(post[:created_at]).strftime('%Y-%m-%d')
end end
@ -31,4 +23,4 @@
post[:tags].compact.map { |tag| tag.downcase }.sort.join(", ") post[:tags].compact.map { |tag| tag.downcase }.sort.join(", ")
end end
end end
end end