Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions _plugins/authors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
require 'digest/md5'
module Jekyll

class Author
attr_accessor :author, :posts
def initialize(author, posts)
self.author = author
self.posts = posts
end

def to_liquid
hash = Digest::MD5.hexdigest(self.author['mail'])
text = "<p><div class=\"gravatar\"><img class=\"gravatar\" src=\"http://www.gravatar.com/avatar/#{hash}?s=100\"></div> <b>#{self.author['name']}</b></p>"
text += "<p>Posts:</p>"
text += "<ul>"
self.posts.each do |p|
text += "<li><a href=\"#{p[:url]}\">#{p[:title]}</a></li>"
end
text += "</ul>"
text
end
end

class AuthorsPageGenerator < Generator
safe true

def generate(site)
authors = {}
site.posts.docs.each do |post|
if !authors[post.data["author"]["github"]].nil?
authors[post.data["author"]["github"]][:posts] << {:url => post.url, :title => post.data["title"]}
else
authors[post.data["author"]["github"]] = {:author => post.data["author"], :posts => [{:url => post.url, :title => post.data["title"]}]}
end
end
authors_page = site.pages.detect {|page| page.name == 'authors.html'}
authors_page.data['authors'] = []
authors.each do |author, post_data|
authors_page.data['authors'] << Author.new(post_data[:author], post_data[:posts])
end
end
end

end
2 changes: 2 additions & 0 deletions _sass/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,5 @@ pre code.hljs {
}
}
}

.gravatar{ width: 100px;}
9 changes: 9 additions & 0 deletions authors.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
layout: page
title: "Autores"
permalink: /authors/
---
{% for author in page.authors %}
{{ author }}
<hr/>
{% endfor %}