mofo 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/README +2 -0
- data/Rakefile +1 -1
- data/lib/microformat.rb +21 -11
- data/lib/mofo/hentry.rb +2 -2
- metadata +1 -1
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 0.2.6
|
2
|
+
- Added rel-license [Mark Murphy]
|
3
|
+
- Performance optimization [Mark Murphy]
|
4
|
+
- Fix bug in hEntry rel-tag [Mark Murphy]
|
5
|
+
|
1
6
|
= 0.2.5
|
2
7
|
- Added ability to find ALL microformats on a page using Microformat.find.
|
3
8
|
Only searches using loaded microformat classes, so make sure to just require 'mofo'
|
data/README
CHANGED
data/Rakefile
CHANGED
data/lib/microformat.rb
CHANGED
@@ -174,21 +174,26 @@ class Microformat
|
|
174
174
|
def build_hash(doc, attributes = @attributes)
|
175
175
|
hash = {}
|
176
176
|
|
177
|
+
# rel="bookmark" pattern
|
178
|
+
if bookmark = extract_bookmark(doc)
|
179
|
+
hash[:bookmark] = bookmark
|
180
|
+
end
|
181
|
+
|
182
|
+
# rel="license" pattern
|
183
|
+
if license = extract_license(doc)
|
184
|
+
hash[:license] = license
|
185
|
+
end
|
186
|
+
|
187
|
+
# rel="tag" pattern
|
188
|
+
if tags = extract_tags(doc)
|
189
|
+
hash[:tags] = tags
|
190
|
+
end
|
191
|
+
|
177
192
|
[:one, :many].each do |name|
|
178
193
|
attributes[name].each do |attribute|
|
179
194
|
is_hash = attribute.is_a? Hash
|
180
195
|
key = is_hash ? attribute.keys.first : attribute
|
181
196
|
|
182
|
-
# rel="bookmark" pattern
|
183
|
-
if bookmark = extract_bookmark(doc)
|
184
|
-
hash[:bookmark] = bookmark
|
185
|
-
end
|
186
|
-
|
187
|
-
# rel="tag" pattern
|
188
|
-
if tags = extract_tags(doc)
|
189
|
-
hash[:tags] = tags
|
190
|
-
end
|
191
|
-
|
192
197
|
found = doc/".#{key.no_bang.to_s.gsub('_','-')}"
|
193
198
|
raise InvalidMicroformat if found.empty? && key.to_s =~ /!/
|
194
199
|
next if found.empty?
|
@@ -236,10 +241,15 @@ class Microformat
|
|
236
241
|
end
|
237
242
|
|
238
243
|
def extract_bookmark(doc)
|
239
|
-
bookmark = doc.at("[@rel=bookmark]") rescue nil
|
244
|
+
bookmark = (doc.at("[@rel=bookmark]") || doc.at("[@rel='self bookmark']")) rescue nil
|
240
245
|
bookmark.attributes['href'] if bookmark.respond_to? :attributes
|
241
246
|
end
|
242
247
|
|
248
|
+
def extract_license(doc)
|
249
|
+
license = doc.at("[@rel=license]") rescue nil
|
250
|
+
license.attributes['href'] if license.respond_to? :attributes
|
251
|
+
end
|
252
|
+
|
243
253
|
def extract_tags(doc)
|
244
254
|
return unless (tags = doc.search("[@rel=tag]")).size.nonzero?
|
245
255
|
tags.inject([]) { |array, tag| array + [tag.innerText] }
|
data/lib/mofo/hentry.rb
CHANGED
@@ -5,9 +5,9 @@ require 'mofo/rel_tag'
|
|
5
5
|
|
6
6
|
class HEntry < Microformat
|
7
7
|
one :entry_title!, :entry_summary, :updated, :published,
|
8
|
-
:author => HCard
|
8
|
+
:author => HCard
|
9
9
|
|
10
|
-
many :entry_content
|
10
|
+
many :entry_content, :tags => RelTag
|
11
11
|
|
12
12
|
after_find do
|
13
13
|
@updated = @published unless @updated if @published
|