Keep a list of blog authors in a yaml file.

This commit is contained in:
Chris Eppstein 2011-04-18 09:04:21 -07:00
parent 6b884d34c3
commit be8e5f5313
3 changed files with 29 additions and 1 deletions

11
doc-src/authors.yml Normal file
View File

@ -0,0 +1,11 @@
chris:
fullname: Chris Eppstein
byline_link: http://chriseppstein.github.com/
brandon:
fullname: Brandon Mathis
eric:
fullname: Eric Meyer
nico:
fullname: Nico Hagenburger
scott:
fullname: Scott Davis

View File

@ -1,5 +1,11 @@
- render "blog" do - render "blog" do
%h1= @item[:title] %h1= @item[:title]
%h2 By #{@item[:author]} - author = author(@item[:author])
%h2
By
- if author["byline_link"]
%a{:href=>author["byline_link"]}= author["fullname"]
- else
= author["fullname"]
= yield = yield
-#comments= render "partials/disqus_comments" -#comments= render "partials/disqus_comments"

View File

@ -1,5 +1,6 @@
POST_NAME = %r{^/posts/(\d{4})-(\d{2})-(\d{2})-(.*)/$} POST_NAME = %r{^/posts/(\d{4})-(\d{2})-(\d{2})-(.*)/$}
require 'time' require 'time'
require 'yaml'
def blog_posts_in_order def blog_posts_in_order
@blog_posts_in_order ||= @items.select {|i| i.identifier =~ %r{/posts} }.sort_by {|i| i.identifier } @blog_posts_in_order ||= @items.select {|i| i.identifier =~ %r{/posts} }.sort_by {|i| i.identifier }
@ -24,3 +25,13 @@ def blog_date(item = @item)
Time.new($1.to_i, $2.to_i, $3.to_i) Time.new($1.to_i, $2.to_i, $3.to_i)
end end
end end
def authors
@site.cached("authors") do
YAML.load_file("#{File.dirname(__FILE__)}/../authors.yml")
end
end
def author(author_id)
authors[author_id]
end