From e6b1a49ed973fa0ceaad5ade9048fb85fe74a9a1 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Tue, 21 May 2013 21:53:36 +0200 Subject: [PATCH] Improved front page --- content/css/_main.scss | 21 +++++------------ content/index.haml | 15 ++++++------ lib/helpers/post.rb | 52 ++++++++++++++++++------------------------ 3 files changed, 35 insertions(+), 53 deletions(-) diff --git a/content/css/_main.scss b/content/css/_main.scss index 7970ef7..c15a1b4 100644 --- a/content/css/_main.scss +++ b/content/css/_main.scss @@ -75,14 +75,15 @@ ul.tla { } ol.posts { - list-style-type: square; - color: #e0e0e0; - + list-style-type: none; list-style-image: none; padding: 0; margin: 0 0 24px 0; + font-family: 'Open Sans'; + font-weight: 400; + li { white-space: nowrap; overflow: hidden; @@ -90,17 +91,7 @@ ol.posts { span.date { display: inline-block; - float: left; - - width: 60px; - - margin-top: -1px; - margin-right: 14px; - - text-align: right; - font-size: 11px; - - color: #a0a0a0; + text-align: left; } } } @@ -151,4 +142,4 @@ pre, .plaincode{ } } -} \ No newline at end of file +} diff --git a/content/index.haml b/content/index.haml index 5116515..ce72971 100644 --- a/content/index.haml +++ b/content/index.haml @@ -5,11 +5,10 @@ title: Ariejan's Blog %section#middle_content #posts - - articles_by_year_for_two_columns.each do |column_articles| - .one_half - - column_articles.each do |year, articles| - %ol.posts - - articles.each do |article| - %li - %span.date= get_short_date(article) - = link_to article[:title], article.path, title: article[:title] \ No newline at end of file + - articles_by_year(sorted_articles).each do |year, articles| + %ol.posts + - articles.each do |article| + %li + %span.date= get_short_date(article) + – + = link_to article[:title], article.path, title: article[:title] diff --git a/lib/helpers/post.rb b/lib/helpers/post.rb index 92a6d59..ea445b0 100644 --- a/lib/helpers/post.rb +++ b/lib/helpers/post.rb @@ -1,34 +1,26 @@ - module PostHelper - def articles_by_year(articles) - hash = Hash.new { |h, k| h[k] = [] } - articles.inject(hash) do |output, article| - year = attribute_to_time(article[:created_at]).year - output[year] << article - output - end +module PostHelper + def articles_by_year(articles) + hash = Hash.new { |h, k| h[k] = [] } + articles.inject(hash) do |output, article| + year = attribute_to_time(article[:created_at]).year + output[year] << article + output 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] + def get_short_date(post) + attribute_to_time(post[:created_at]).strftime('%Y-%m-%d') + end - [articles_by_year(half_one), articles_by_year(half_two)] + def get_pretty_date(post) + attribute_to_time(post[:created_at]).strftime('%-d %B, %Y') + end + + def get_tags(post) + if post[:tags].nil? || post[:tags].empty? + "(not tagged)" + else + post[:tags].compact.map { |tag| tag.downcase }.sort.join(", ") end - - def get_short_date(post) - attribute_to_time(post[:created_at]).strftime('%Y-%m-%d') - end - - def get_pretty_date(post) - attribute_to_time(post[:created_at]).strftime('%-d %B, %Y') - end - - def get_tags(post) - if post[:tags].nil? || post[:tags].empty? - "(not tagged)" - else - post[:tags].compact.map { |tag| tag.downcase }.sort.join(", ") - end - end - end \ No newline at end of file + end +end