feedtools 0.2.19 → 0.2.20
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.
- data/CHANGELOG +4 -0
- data/lib/feed_tools/feed.rb +30 -2
- data/lib/feed_tools/feed_item.rb +103 -4
- data/lib/feed_tools.rb +1 -1
- data/rakefile +3 -2
- metadata +1 -1
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
== FeedTools 0.2.20
|
2
|
+
* fixed some atom namespace bugs
|
3
|
+
* added a summary method to feed items
|
4
|
+
* added some support for the apple-wallpapers elements
|
1
5
|
== FeedTools 0.2.19
|
2
6
|
* lousy encoding support (as opposed to none at all)
|
3
7
|
* xml processing instruction now correctly prefixes generated feeds
|
data/lib/feed_tools/feed.rb
CHANGED
@@ -1123,7 +1123,9 @@ module FeedTools
|
|
1123
1123
|
"a/@href"
|
1124
1124
|
], :select_result_value => true)
|
1125
1125
|
if @link.blank?
|
1126
|
-
if FeedTools.is_uri?(self.guid)
|
1126
|
+
if FeedTools.is_uri?(self.guid) &&
|
1127
|
+
!(self.guid =~ /^urn:uuid:/) &&
|
1128
|
+
!(self.guid =~ /^tag:/)
|
1127
1129
|
@link = self.guid
|
1128
1130
|
end
|
1129
1131
|
end
|
@@ -1305,6 +1307,9 @@ module FeedTools
|
|
1305
1307
|
if @author.name.blank?
|
1306
1308
|
@author.name = FeedTools.unescape_entities(
|
1307
1309
|
try_xpaths(author_node, [
|
1310
|
+
"atom10:name/text()",
|
1311
|
+
"atom03:name/text()",
|
1312
|
+
"atom:name/text()",
|
1308
1313
|
"name/text()",
|
1309
1314
|
"@name"
|
1310
1315
|
], :select_result_value => true)
|
@@ -1313,6 +1318,9 @@ module FeedTools
|
|
1313
1318
|
if @author.email.blank?
|
1314
1319
|
@author.email = FeedTools.unescape_entities(
|
1315
1320
|
try_xpaths(author_node, [
|
1321
|
+
"atom10:email/text()",
|
1322
|
+
"atom03:email/text()",
|
1323
|
+
"atom:email/text()",
|
1316
1324
|
"email/text()",
|
1317
1325
|
"@email"
|
1318
1326
|
], :select_result_value => true)
|
@@ -1321,7 +1329,13 @@ module FeedTools
|
|
1321
1329
|
if @author.url.blank?
|
1322
1330
|
@author.url = FeedTools.unescape_entities(
|
1323
1331
|
try_xpaths(author_node, [
|
1332
|
+
"atom10:url/text()",
|
1333
|
+
"atom03:url/text()",
|
1334
|
+
"atom:url/text()",
|
1324
1335
|
"url/text()",
|
1336
|
+
"atom10:uri/text()",
|
1337
|
+
"atom03:uri/text()",
|
1338
|
+
"atom:uri/text()",
|
1325
1339
|
"uri/text()",
|
1326
1340
|
"@url",
|
1327
1341
|
"@uri",
|
@@ -1499,7 +1513,13 @@ module FeedTools
|
|
1499
1513
|
def updated
|
1500
1514
|
if @updated.nil?
|
1501
1515
|
updated_string = try_xpaths(self.channel_node, [
|
1516
|
+
"atom10:updated/text()",
|
1517
|
+
"atom03:updated/text()",
|
1518
|
+
"atom:updated/text()",
|
1502
1519
|
"updated/text()",
|
1520
|
+
"atom10:modified/text()",
|
1521
|
+
"atom03:modified/text()",
|
1522
|
+
"atom:modified/text()",
|
1503
1523
|
"modified/text()"
|
1504
1524
|
], :select_result_value => true)
|
1505
1525
|
unless updated_string.blank?
|
@@ -1520,8 +1540,14 @@ module FeedTools
|
|
1520
1540
|
def published
|
1521
1541
|
if @published.nil?
|
1522
1542
|
published_string = try_xpaths(self.channel_node, [
|
1543
|
+
"atom10:published/text()",
|
1544
|
+
"atom03:published/text()",
|
1545
|
+
"atom:published/text()",
|
1523
1546
|
"published/text()",
|
1524
1547
|
"pubDate/text()",
|
1548
|
+
"atom10:issued/text()",
|
1549
|
+
"atom03:issued/text()",
|
1550
|
+
"atom:issued/text()",
|
1525
1551
|
"issued/text()",
|
1526
1552
|
"dc:date/text()"
|
1527
1553
|
], :select_result_value => true)
|
@@ -1577,6 +1603,7 @@ module FeedTools
|
|
1577
1603
|
image_nodes = try_xpaths_all(self.channel_node, [
|
1578
1604
|
"image",
|
1579
1605
|
"logo",
|
1606
|
+
"apple-wallpapers:image",
|
1580
1607
|
"atom10:link",
|
1581
1608
|
"atom03:link",
|
1582
1609
|
"atom:link",
|
@@ -1587,7 +1614,8 @@ module FeedTools
|
|
1587
1614
|
image = FeedTools::Feed::Image.new
|
1588
1615
|
image.url = try_xpaths(image_node, [
|
1589
1616
|
"url/text()",
|
1590
|
-
"@rdf:resource"
|
1617
|
+
"@rdf:resource",
|
1618
|
+
"text()"
|
1591
1619
|
], :select_result_value => true)
|
1592
1620
|
if image.url.blank? && (image_node.name == "logo" ||
|
1593
1621
|
(image_node.attributes['type'].to_s =~ /^image/) == 0)
|
data/lib/feed_tools/feed_item.rb
CHANGED
@@ -344,6 +344,9 @@ module FeedTools
|
|
344
344
|
if @content.nil?
|
345
345
|
repair_entities = false
|
346
346
|
content_node = try_xpaths(self.root_node, [
|
347
|
+
"atom10:content",
|
348
|
+
"atom03:content",
|
349
|
+
"atom:content",
|
347
350
|
"content:encoded",
|
348
351
|
"content",
|
349
352
|
"fullitem",
|
@@ -353,6 +356,9 @@ module FeedTools
|
|
353
356
|
"description",
|
354
357
|
"tagline",
|
355
358
|
"subtitle",
|
359
|
+
"atom10:summary",
|
360
|
+
"atom03:summary",
|
361
|
+
"atom:summary",
|
356
362
|
"summary",
|
357
363
|
"abstract",
|
358
364
|
"blurb",
|
@@ -411,6 +417,85 @@ module FeedTools
|
|
411
417
|
def content=(new_content)
|
412
418
|
@content = new_content
|
413
419
|
end
|
420
|
+
|
421
|
+
# Returns the feed item summary
|
422
|
+
def summary
|
423
|
+
if @summary.nil?
|
424
|
+
repair_entities = false
|
425
|
+
summary_node = try_xpaths(self.root_node, [
|
426
|
+
"atom10:summary",
|
427
|
+
"atom03:summary",
|
428
|
+
"atom:summary",
|
429
|
+
"summary",
|
430
|
+
"abstract",
|
431
|
+
"blurb",
|
432
|
+
"description",
|
433
|
+
"tagline",
|
434
|
+
"subtitle",
|
435
|
+
"fullitem",
|
436
|
+
"xhtml:body",
|
437
|
+
"body",
|
438
|
+
"content:encoded",
|
439
|
+
"encoded",
|
440
|
+
"atom10:content",
|
441
|
+
"atom03:content",
|
442
|
+
"atom:content",
|
443
|
+
"content",
|
444
|
+
"info"
|
445
|
+
])
|
446
|
+
if summary_node.nil?
|
447
|
+
return nil
|
448
|
+
end
|
449
|
+
summary_type = try_xpaths(summary_node, "@type",
|
450
|
+
:select_result_value => true)
|
451
|
+
summary_mode = try_xpaths(summary_node, "@mode",
|
452
|
+
:select_result_value => true)
|
453
|
+
summary_encoding = try_xpaths(summary_node, "@encoding",
|
454
|
+
:select_result_value => true)
|
455
|
+
|
456
|
+
# Note that we're checking for misuse of type, mode and encoding here
|
457
|
+
if !summary_encoding.blank?
|
458
|
+
@summary =
|
459
|
+
"[Embedded data objects are not currently supported.]"
|
460
|
+
elsif summary_node.cdatas.size > 0
|
461
|
+
@summary = summary_node.cdatas.first.value
|
462
|
+
elsif summary_type == "base64" || summary_mode == "base64" ||
|
463
|
+
summary_encoding == "base64"
|
464
|
+
@summary = Base64.decode64(summary_node.inner_xml.strip)
|
465
|
+
elsif summary_type == "xhtml" || summary_mode == "xhtml" ||
|
466
|
+
summary_type == "xml" || summary_mode == "xml" ||
|
467
|
+
summary_type == "application/xhtml+xml"
|
468
|
+
@summary = summary_node.inner_xml
|
469
|
+
elsif summary_type == "escaped" || summary_mode == "escaped"
|
470
|
+
@summary = FeedTools.unescape_entities(
|
471
|
+
summary_node.inner_xml)
|
472
|
+
else
|
473
|
+
@summary = summary_node.inner_xml
|
474
|
+
repair_entities = true
|
475
|
+
end
|
476
|
+
if @summary.blank?
|
477
|
+
@summary = self.itunes_summary
|
478
|
+
end
|
479
|
+
if @summary.blank?
|
480
|
+
@summary = self.itunes_subtitle
|
481
|
+
end
|
482
|
+
|
483
|
+
unless @summary.blank?
|
484
|
+
@summary = FeedTools.sanitize_html(@summary, :strip)
|
485
|
+
@summary = FeedTools.unescape_entities(@summary) if repair_entities
|
486
|
+
@summary = FeedTools.tidy_html(@summary)
|
487
|
+
end
|
488
|
+
|
489
|
+
@summary = @summary.strip unless @summary.nil?
|
490
|
+
@summary = nil if @summary.blank?
|
491
|
+
end
|
492
|
+
return @summary
|
493
|
+
end
|
494
|
+
|
495
|
+
# Sets the feed item summary
|
496
|
+
def summary=(new_summary)
|
497
|
+
@summary = new_summary
|
498
|
+
end
|
414
499
|
|
415
500
|
# Returns the contents of the itunes:summary element
|
416
501
|
def itunes_summary
|
@@ -497,7 +582,9 @@ module FeedTools
|
|
497
582
|
"a/@href"
|
498
583
|
], :select_result_value => true)
|
499
584
|
if @link.blank?
|
500
|
-
if FeedTools.is_uri?
|
585
|
+
if FeedTools.is_uri?(self.guid) &&
|
586
|
+
!(self.guid =~ /^urn:uuid:/) &&
|
587
|
+
!(self.guid =~ /^tag:/)
|
501
588
|
@link = self.guid
|
502
589
|
end
|
503
590
|
end
|
@@ -601,6 +688,7 @@ module FeedTools
|
|
601
688
|
image_nodes = try_xpaths_all(self.root_node, [
|
602
689
|
"image",
|
603
690
|
"logo",
|
691
|
+
"apple-wallpapers:image",
|
604
692
|
"atom10:link",
|
605
693
|
"atom03:link",
|
606
694
|
"atom:link",
|
@@ -611,7 +699,8 @@ module FeedTools
|
|
611
699
|
image = FeedTools::Feed::Image.new
|
612
700
|
image.url = try_xpaths(image_node, [
|
613
701
|
"url/text()",
|
614
|
-
"@rdf:resource"
|
702
|
+
"@rdf:resource",
|
703
|
+
"text()"
|
615
704
|
], :select_result_value => true)
|
616
705
|
if image.url.blank? && (image_node.name == "logo" ||
|
617
706
|
(image_node.attributes['type'].to_s =~ /^image/) == 0)
|
@@ -1215,6 +1304,9 @@ module FeedTools
|
|
1215
1304
|
if @author.name.blank?
|
1216
1305
|
@author.name = FeedTools.unescape_entities(
|
1217
1306
|
try_xpaths(author_node, [
|
1307
|
+
"atom10:name/text()",
|
1308
|
+
"atom03:name/text()",
|
1309
|
+
"atom:name/text()",
|
1218
1310
|
"name/text()",
|
1219
1311
|
"@name"
|
1220
1312
|
], :select_result_value => true)
|
@@ -1223,6 +1315,9 @@ module FeedTools
|
|
1223
1315
|
if @author.email.blank?
|
1224
1316
|
@author.email = FeedTools.unescape_entities(
|
1225
1317
|
try_xpaths(author_node, [
|
1318
|
+
"atom10:email/text()",
|
1319
|
+
"atom03:email/text()",
|
1320
|
+
"atom:email/text()",
|
1226
1321
|
"email/text()",
|
1227
1322
|
"@email"
|
1228
1323
|
], :select_result_value => true)
|
@@ -1231,7 +1326,13 @@ module FeedTools
|
|
1231
1326
|
if @author.url.blank?
|
1232
1327
|
@author.url = FeedTools.unescape_entities(
|
1233
1328
|
try_xpaths(author_node, [
|
1329
|
+
"atom10:url/text()",
|
1330
|
+
"atom03:url/text()",
|
1331
|
+
"atom:url/text()",
|
1234
1332
|
"url/text()",
|
1333
|
+
"atom10:uri/text()",
|
1334
|
+
"atom03:uri/text()",
|
1335
|
+
"atom:uri/text()",
|
1235
1336
|
"uri/text()",
|
1236
1337
|
"@url",
|
1237
1338
|
"@uri",
|
@@ -1921,8 +2022,6 @@ module FeedTools
|
|
1921
2022
|
end
|
1922
2023
|
end
|
1923
2024
|
|
1924
|
-
alias_method :summary, :content
|
1925
|
-
alias_method :summary=, :content=
|
1926
2025
|
alias_method :abstract, :content
|
1927
2026
|
alias_method :abstract=, :content=
|
1928
2027
|
alias_method :description, :content
|
data/lib/feed_tools.rb
CHANGED
data/rakefile
CHANGED
@@ -7,7 +7,7 @@ require 'rake/gempackagetask'
|
|
7
7
|
require 'rake/contrib/rubyforgepublisher'
|
8
8
|
|
9
9
|
PKG_NAME = 'feedtools'
|
10
|
-
PKG_VERSION = '0.2.
|
10
|
+
PKG_VERSION = '0.2.20'
|
11
11
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
12
12
|
|
13
13
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
@@ -91,7 +91,8 @@ Rake::TestTask.new("rss_test") { |t|
|
|
91
91
|
Rake::RDocTask.new { |rdoc|
|
92
92
|
rdoc.rdoc_dir = 'doc'
|
93
93
|
rdoc.title = "Feed Tools -- caching system for xml news feeds"
|
94
|
-
rdoc.options << '--line-numbers --inline-source
|
94
|
+
rdoc.options << '--line-numbers' << '--inline-source' <<
|
95
|
+
'--accessor' << 'cattr_accessor=object'
|
95
96
|
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
96
97
|
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
97
98
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
metadata
CHANGED