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 {
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{
}
}
}
}

View File

@ -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]
- 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]

View File

@ -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
end
end