mofo 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/mofo/hentry.rb +7 -5
- data/test/hatom_test.rb +4 -8
- metadata +1 -1
data/Rakefile
CHANGED
data/lib/mofo/hentry.rb
CHANGED
@@ -3,7 +3,6 @@ require 'microformat'
|
|
3
3
|
require 'mofo/hcard'
|
4
4
|
require 'mofo/rel_tag'
|
5
5
|
require 'mofo/rel_bookmark'
|
6
|
-
require 'digest/md5'
|
7
6
|
|
8
7
|
class HEntry < Microformat
|
9
8
|
one :entry_title, :entry_summary, :updated, :published,
|
@@ -24,6 +23,9 @@ class HEntry < Microformat
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def to_atom(property = nil, value = nil)
|
26
|
+
require 'digest/md5'
|
27
|
+
require 'erb'
|
28
|
+
|
27
29
|
if property
|
28
30
|
value ||= instance_variable_get("@#{property}")
|
29
31
|
return value ? ("<#{property}>%s</#{property}>" % value) : nil
|
@@ -34,9 +36,9 @@ class HEntry < Microformat
|
|
34
36
|
#{atom_id}
|
35
37
|
#{atom_link}
|
36
38
|
#{to_atom :title, @entry_title}
|
37
|
-
<content type="html">#{@entry_content}</content>
|
38
|
-
#{to_atom :updated}
|
39
|
-
#{to_atom :published}
|
39
|
+
<content type="html">#{ERB::Util.h @entry_content}</content>
|
40
|
+
#{to_atom :updated, @updated.try(:xmlschema)}
|
41
|
+
#{to_atom :published, @updated.try(:xmlschema)}
|
40
42
|
<author>
|
41
43
|
#{to_atom :name, @author.try(:fn)}
|
42
44
|
#{to_atom :email, @author.try(:email)}
|
@@ -56,7 +58,7 @@ class Array
|
|
56
58
|
<link type="text/html" href="#{first.base_url}" rel="alternate"/>
|
57
59
|
<link type="application/atom+xml" href="" rel="self"/>
|
58
60
|
<title>#{options[:title]}</title>
|
59
|
-
<updated>#{first.updated || first.published}</updated>
|
61
|
+
<updated>#{(first.updated || first.published).try(:xmlschema)}</updated>
|
60
62
|
#{entries}
|
61
63
|
</feed>
|
62
64
|
end_atom
|
data/test/hatom_test.rb
CHANGED
@@ -44,10 +44,10 @@ context "A parsed hEntry object" do
|
|
44
44
|
<link type="text/html" href="http://errtheblog.com/post/13" rel="alternate"/>
|
45
45
|
<title>“A Rails Toolbox”</title>
|
46
46
|
<content type="html">
|
47
|
-
|
47
|
+
<img
|
48
48
|
src=
|
49
49
|
http://errtheblog.com/static/images/pink-toolbox.jpg
|
50
|
-
|
50
|
+
<p>
|
51
51
|
</content>
|
52
52
|
<author>
|
53
53
|
<name>Chris</name>
|
@@ -74,14 +74,10 @@ context "An hFeed" do
|
|
74
74
|
<link type="text/html" href="http://errtheblog.com/post/13" rel="alternate"/>
|
75
75
|
<title>Err the Blog</title>
|
76
76
|
<content type="html">
|
77
|
-
|
77
|
+
<img
|
78
78
|
src=
|
79
79
|
http://errtheblog.com/static/images/pink-toolbox.jpg
|
80
|
-
|
81
|
-
<pre>
|
82
|
-
just a normal
|
83
|
-
test okay
|
84
|
-
</pre>
|
80
|
+
<p>
|
85
81
|
</content>
|
86
82
|
<updated>
|
87
83
|
<author>
|