Skip to content

Commit 71fd1d4

Browse files
committed
add post meta data
1 parent f9c26cf commit 71fd1d4

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

content/changes/2012-9-5-watcher-api.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
---
22
title: Upcoming Changes to Watcher and Star APIs
3+
published: 2012-9-5
4+
author: technoweenie
35
---
46

7+
<%= render '_meta', :item => @item, :level => :h1 %>
8+
59
We recently [changed the Watcher behavior][change-watching] on GitHub. What
610
used to be known as "Watching", is now "Starring". Starring is basically
711
a way to bookmark interesting repositories. Watching is a way to indicate that

layouts/_meta.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<<%= @level %>><%= @item[:title] %></<%= @level %>>
2+
<div class="meta">
3+
<div class="who_when">
4+
<%= gravatar_for(@item[:author]) %>
5+
<span class="author vcard fn">
6+
<a href="https://github.com/<%= @item[:author] %>"><%= @item[:author] %></a>
7+
</span>
8+
<span class="published">
9+
<%= post_date @item %>
10+
</span>
11+
</div>
12+
</div>

lib/default.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# All files in the 'lib' directory will be loaded
22
# before nanoc starts compiling.
3+
include Nanoc::Helpers::Rendering

lib/resources.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,29 @@ module Helpers
2121
500 => '500 Server Error'
2222
}
2323

24+
AUTHORS = {
25+
:technoweenie => '821395fe70906c8290df7f18ac4ac6cf'
26+
}
27+
28+
def post_date(item)
29+
pub = item[:published]
30+
if !pub.respond_to?(:strftime)
31+
pub = Time.parse(pub)
32+
end
33+
pub.strftime("%B %-d, %Y")
34+
end
35+
36+
def gravatar_for(login)
37+
%(<img height="16" width="16" src="%s" />) % gravatar_url_for(login)
38+
end
39+
40+
def gravatar_url_for(login)
41+
md5 = AUTHORS[login.to_sym]
42+
default = "https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-user-420.png"
43+
"https://secure.gravatar.com/avatar/%s?s=20&d=%s" %
44+
[md5, default]
45+
end
46+
2447
def headers(status, head = {})
2548
css_class = (status == 204 || status == 404) ? 'headers no-response' : 'headers'
2649
lines = ["Status: #{STATUSES[status]}"]

0 commit comments

Comments
 (0)