ace 0.4.7 → 0.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Ace
4
- VERSION ||= "0.4.7"
4
+ VERSION ||= "0.4.8"
5
5
  end
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.7
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