Sha256: b993a2723c39e1d669775480d0e683fe19c1294a0df46b41b286fcc874a1b8d0
Contents?: true
Size: 626 Bytes
Versions: 1
Compression:
Stored size: 626 Bytes
Contents
# encoding: utf-8 require 'digest/md5' require 'nokogiri' # <gravatar email="john@doe.com"> # TODO: # class Post < Ace::Item # before Ace::GravatarFilter # end module Ace class GravatarFilter < Filter def gravatar_url(email) hash = Digest::MD5.hexdigest(email) "http://www.gravatar.com/avatar/#{hash}" end def call(item, content) doc = Nokogiri::HTML(content) doc.css("gravatar").each do |node| image_node = Nokogiri::XML::Node.new("img", doc) image_node.set_attribute("src", gravatar_url(node[:email])) node.replace(image_node) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ace-0.4.9 | lib/ace/filters/gravatar.rb |