tinyatom 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +13 -6
- data/VERSION +1 -1
- data/lib/tinyatom/feed.rb +29 -4
- data/tinyatom.gemspec +11 -13
- metadata +6 -7
- data/.gitignore +0 -1
data/README.textile
CHANGED
@@ -40,17 +40,23 @@ feed.add_entry(
|
|
40
40
|
|
41
41
|
:via_type => 'text/html',
|
42
42
|
:via_href => 'http://anotherblog.com/posts/999',
|
43
|
-
:via_title => 'Look at this photo'
|
43
|
+
:via_title => 'Look at this photo',
|
44
|
+
|
45
|
+
|
46
|
+
:media_thumbnail_url => 'http://mysite.com/thumbnails/1.jpg',
|
47
|
+
:media_thumbnail_width => 100,
|
48
|
+
:media_thumbnail_height => 100,
|
49
|
+
:media_thumbnail_time => '00:00:00.000'
|
44
50
|
)
|
45
51
|
|
46
52
|
puts feed.make(:indent => 2)
|
47
53
|
# open('atom.xml', 'w') { |f| feed.make(:target => f) }
|
48
54
|
|
49
55
|
<?xml version="1.0" encoding="UTF-8"?>
|
50
|
-
<feed xmlns="http://www.w3.org/2005/Atom">
|
56
|
+
<feed xmlns:media="http://purl.org/syndication/atommedia" xmlns="http://www.w3.org/2005/Atom">
|
51
57
|
<title>My Blog</title>
|
52
58
|
<link rel="self" href="http://mysite.com/blog/atom.xml"/>
|
53
|
-
<updated>2010-
|
59
|
+
<updated>2010-11-14T10:15:25-05:00</updated>
|
54
60
|
<id>http://mysite.com/blog/</id>
|
55
61
|
<author>
|
56
62
|
<name>me</name>
|
@@ -61,14 +67,15 @@ puts feed.make(:indent => 2)
|
|
61
67
|
<entry>
|
62
68
|
<title>post 1</title>
|
63
69
|
<link href="http://mysite.com/blog/1"/>
|
64
|
-
<id>tag:mysite.com,2010-
|
65
|
-
<updated>2010-
|
70
|
+
<id>tag:mysite.com,2010-11-14:1</id>
|
71
|
+
<updated>2010-11-14T10:15:25-05:00</updated>
|
66
72
|
<author>
|
67
73
|
<name>me</name>
|
68
74
|
<email>me@mysite.com</email>
|
69
75
|
<uri>http://mysite.com/</uri>
|
70
76
|
</author>
|
71
|
-
<link type="image/png" rel="enclosure"
|
77
|
+
<link type="image/png" rel="enclosure" title="photo" length="6227" href="http://mysite.com/image.png"/>
|
78
|
+
<media:thumbnail url="http://mysite.com/thumbnails/1.jpg" height="100" time="00:00:00.000" width="100"/>
|
72
79
|
<link type="text/html" rel="via" title="Look at this photo" href="http://anotherblog.com/posts/999"/>
|
73
80
|
</entry>
|
74
81
|
</feed>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/lib/tinyatom/feed.rb
CHANGED
@@ -29,7 +29,8 @@ module TinyAtom
|
|
29
29
|
xm = Builder::XmlMarkup.new(options)
|
30
30
|
xm.instruct!(:xml)
|
31
31
|
|
32
|
-
xm.feed(:xmlns => 'http://www.w3.org/2005/Atom'
|
32
|
+
xm.feed(:xmlns => 'http://www.w3.org/2005/Atom',
|
33
|
+
:'xmlns:media' => 'http://purl.org/syndication/atommedia') {
|
33
34
|
xm.title(title)
|
34
35
|
xm.link(:href => feed_url, :rel => 'self')
|
35
36
|
xm.updated(updated.xmlschema)
|
@@ -48,8 +49,11 @@ module TinyAtom
|
|
48
49
|
xm.summary(e[:summary]) if e[:summary]
|
49
50
|
xm.content(e[:content]) if e[:content]
|
50
51
|
|
51
|
-
TinyAtom::author(xm,
|
52
|
-
TinyAtom::enclosure(xm,
|
52
|
+
(e[:authors] || [e]).each { |h| TinyAtom::author(xm, h) }
|
53
|
+
(e[:enclosures] || [e]).each { |h| TinyAtom::enclosure(xm, h) }
|
54
|
+
(e[:media_thumbnails] || [e]).each do |h|
|
55
|
+
TinyAtom::media_thumbnail(xm, h)
|
56
|
+
end
|
53
57
|
TinyAtom::via(xm, e)
|
54
58
|
}
|
55
59
|
end
|
@@ -94,7 +98,6 @@ module TinyAtom
|
|
94
98
|
# Add enclosure tags if present
|
95
99
|
def enclosure(markup, h)
|
96
100
|
if h[:enclosure_type] and h[:enclosure_href] and h[:enclosure_title]
|
97
|
-
|
98
101
|
options = {}
|
99
102
|
h.each do |k,v|
|
100
103
|
if EnclosureOptionalAttrs.include?(k)
|
@@ -107,6 +110,28 @@ module TinyAtom
|
|
107
110
|
end
|
108
111
|
end
|
109
112
|
|
113
|
+
# param name => tag name
|
114
|
+
MediaThumbnailOptionalAttrs = {
|
115
|
+
:media_thumbnail_height => :height,
|
116
|
+
:media_thumbnail_width => :width,
|
117
|
+
:media_thumbnail_time => :time,
|
118
|
+
}
|
119
|
+
|
120
|
+
# Add media:thumbnail tags if present.
|
121
|
+
def media_thumbnail(markup, h)
|
122
|
+
if h[:media_thumbnail_url]
|
123
|
+
options = {}
|
124
|
+
h.each do |k,v|
|
125
|
+
if MediaThumbnailOptionalAttrs.include?(k)
|
126
|
+
options[MediaThumbnailOptionalAttrs[k]] = v
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
markup.media(:thumbnail,
|
131
|
+
{ :url => h[:media_thumbnail_url] }.merge(options))
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
110
135
|
# Add via tags if present
|
111
136
|
def via(markup, h)
|
112
137
|
if h[:via_type] and h[:via_href] and h[:via_title]
|
data/tinyatom.gemspec
CHANGED
@@ -1,33 +1,31 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tinyatom}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Matthew M. Boedicker"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-14}
|
13
13
|
s.description = %q{Small and easy to use ruby Atom feed generator.}
|
14
14
|
s.email = %q{matthewm@boedicker.org}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.textile"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
"tinyatom.gemspec"
|
19
|
+
"COPYING",
|
20
|
+
"README.textile",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION",
|
23
|
+
"lib/tinyatom.rb",
|
24
|
+
"lib/tinyatom/feed.rb",
|
25
|
+
"lib/tinyatom/uri.rb",
|
26
|
+
"tinyatom.gemspec"
|
28
27
|
]
|
29
28
|
s.homepage = %q{http://github.com/mmb/tinyatom}
|
30
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
31
29
|
s.require_paths = ["lib"]
|
32
30
|
s.rubygems_version = %q{1.3.7}
|
33
31
|
s.summary = %q{Small and easy to use ruby Atom feed generator.}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinyatom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 3
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Matthew M. Boedicker
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-14 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -43,7 +43,6 @@ extensions: []
|
|
43
43
|
extra_rdoc_files:
|
44
44
|
- README.textile
|
45
45
|
files:
|
46
|
-
- .gitignore
|
47
46
|
- COPYING
|
48
47
|
- README.textile
|
49
48
|
- Rakefile
|
@@ -57,8 +56,8 @@ homepage: http://github.com/mmb/tinyatom
|
|
57
56
|
licenses: []
|
58
57
|
|
59
58
|
post_install_message:
|
60
|
-
rdoc_options:
|
61
|
-
|
59
|
+
rdoc_options: []
|
60
|
+
|
62
61
|
require_paths:
|
63
62
|
- lib
|
64
63
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
*~
|