ace 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ace/filters/gravatar.rb +29 -0
- data/lib/ace/version.rb +1 -1
- metadata +2 -1
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'digest/md5'
|
4
|
+
require 'nokogiri'
|
5
|
+
|
6
|
+
# <gravatar email="john@doe.com">
|
7
|
+
|
8
|
+
# TODO:
|
9
|
+
# class Post < Ace::Item
|
10
|
+
# before Ace::GravatarFilter
|
11
|
+
# end
|
12
|
+
|
13
|
+
module Ace
|
14
|
+
class GravatarFilter < Filter
|
15
|
+
def gravatar_url(email)
|
16
|
+
hash = Digest::MD5.hexdigest(email)
|
17
|
+
"http://www.gravatar.com/avatar/#{hash}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(item, content)
|
21
|
+
doc = Nokogiri::HTML(content)
|
22
|
+
doc.css("gravatar").each do |node|
|
23
|
+
image_node = Nokogiri::XML::Node.new("img", doc)
|
24
|
+
image_node.set_attribute("src", gravatar_url(node[:email]))
|
25
|
+
node.replace(img)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/ace/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- lib/ace.rb
|
97
97
|
- lib/ace/dsl.rb
|
98
98
|
- lib/ace/filters.rb
|
99
|
+
- lib/ace/filters/gravatar.rb
|
99
100
|
- lib/ace/filters/haml.rb
|
100
101
|
- lib/ace/filters/image_thumbnailer.rb
|
101
102
|
- lib/ace/filters/layout.rb
|