! Copyright (C) 2006 Chris Double, Daniel Ehrenberg.
! Portions copyright (C) 2008, 2009 Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
+! See https://factorcode.org/license.txt for BSD license.
USING: accessors byte-arrays calendar.format calendar.parser
combinators combinators.short-circuit continuations http.client
kernel present sequences strings urls xml xml.data
: try-parsing-timestamp ( string -- timestamp )
[ rfc822>timestamp ] [ drop rfc3339>timestamp ] recover ;
+: ?children>string ( tag -- str/f )
+ dup [ children>string ] when ; inline
+
: rss1.0-entry ( tag -- entry )
<entry> swap {
[ "title" tag-named children>string >>title ]
[ "link" tag-named children>string >url >>url ]
[ "description" tag-named children>string >>description ]
[
- f "date" "http://purl.org/dc/elements/1.1/" <name>
+ f "date" "https://purl.org/dc/elements/1.1/" <name>
tag-named dup [ children>string try-parsing-timestamp ] when
>>date
]
: rss2.0-entry ( tag -- entry )
<entry> swap {
- [ "title" tag-named children>string >>title ]
- [ { "link" "guid" } any-tag-named children>string >url >>url ]
- [ { "description" "encoded" } any-tag-named children>string >>description ]
+ [ "title" tag-named ?children>string >>title ]
+ [ { "link" "guid" } any-tag-named ?children>string >url >>url ]
+ [ { "description" "encoded" } any-tag-named ?children>string >>description ]
[
{ "date" "pubDate" } any-tag-named
- children>string try-parsing-timestamp >>date
+ ?children>string try-parsing-timestamp >>date
]
} cleave ;