Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a date to articles. This uses the 'date' metadata, which not al…

…l of the articles have (although the latest ones seem to)
  • Loading branch information...
commit 2276fb75e7eda8e5e5c772660f8f7ad8916a32d8 1 parent 3c9e3b2
@thechrisoshow thechrisoshow authored
Showing with 10 additions and 1 deletion.
  1. +6 −1 blog.rb
  2. +3 −0  public/stylesheets/layout.css
  3. +1 −0  views/post.haml
View
7 blog.rb
@@ -17,6 +17,10 @@ def title
"#{title}Literate Programming"
end
+ def formatted_date
+ @date && Date.parse(@date).strftime("%-d %B %Y")
+ end
+
def format_outline(outline)
prev_level = 2
@@ -77,10 +81,11 @@ def format_outline(outline)
@title_hidden = source.metadata['title-hidden']
@content = source.content
@outline = source.outline
+ @date = source.metadata['date']
haml :post
rescue Errno::ENOENT # we couldn't find the file on disk.
- pass
+ pass
end
end
View
3  public/stylesheets/layout.css
@@ -22,6 +22,9 @@ div.container {
pre.prettyprint {
margin-bottom: 2em;
}
+div.date {
+ text-align: right;
+}
/* #Page Styles
View
1  views/post.haml
@@ -1,5 +1,6 @@
- unless @title_hidden
%h1= @title
+ .date= formatted_date
:preserve
#{@content}
- content_for :sidebar do
Please sign in to comment.
Something went wrong with that request. Please try again.