]> gitweb.factorcode.org Git - factor.git/commitdiff
fix link when extracting the feed address
authorSamuel Tardieu <sam@rfc1149.net>
Wed, 14 Dec 2011 22:18:26 +0000 (23:18 +0100)
committerJoe Groff <arcata@gmail.com>
Sat, 17 Dec 2011 00:07:01 +0000 (16:07 -0800)
If the <link rel="alternate" href="..."/> was not the first
<link/> attribute under the <feed/> tag, the bad one was extracted
as the corresponding site URL.

basis/syndication/syndication.factor
basis/syndication/test/atom.xml

index 0cc124c088dbb0e2dc812b531e019f7a063b23c6..407e09aab11dbd68c50ae0b6a10c087ae414b55e 100644 (file)
@@ -65,15 +65,14 @@ TUPLE: entry title url description date ;
     [ "item" tags-named [ rss2.0-entry ] map set-entries ]
     tri ;
 
-: atom-entry-link ( tag -- url/f )
-    "link" tags-named
-    [ "rel" attr { f "alternate" } member? ] find nip
-    dup [ "href" attr >url ] when ;
+: atom-link ( tag -- url/f )
+    "link" "alternate" "rel" tag-named-with-attr
+    [ "href" attr >url ] [ f ] if* ;
 
 : atom1.0-entry ( tag -- entry )
     <entry> swap {
         [ "title" tag-named children>string >>title ]
-        [ atom-entry-link >>url ]
+        [ atom-link >>url ]
         [
             { "content" "summary" } any-tag-named
             dup children>> [ string? not ] any?
@@ -90,7 +89,7 @@ TUPLE: entry title url description date ;
 : atom1.0 ( xml -- feed )
     <feed> swap
     [ "title" tag-named children>string >>title ]
-    [ "link" tag-named "href" attr >url >>url ]
+    [ atom-link >>url ]
     [ "entry" tags-named [ atom1.0-entry ] map set-entries ]
     tri ;
 
index d0195661ce49c0c5b21e7323447cbce5693a1200..222c3211895fea02176ca4f067c96b838a1f4a32 100644 (file)
@@ -7,6 +7,7 @@
      </subtitle>
      <updated>2005-07-31T12:29:29Z</updated>
      <id>tag:example.org,2003:3</id>
+     <link rel="hub" href="https://pubsubhubbub.example.org/"/>
      <link rel="alternate" type="text/html"
       hreflang="en" href="http://example.org/"/>
      <link rel="self" type="application/atom+xml"