Planet Factor Atom feed
parent
a01a7e4383
commit
4369dc61c2
|
@ -1,24 +1,14 @@
|
||||||
! Copyright (C) 2006 Chris Double.
|
! Copyright (C) 2006 Chris Double, Daniel Ehrenberg.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
IN: rss
|
IN: rss
|
||||||
! USING: kernel http-client xml xml-utils xml-data errors io strings
|
|
||||||
! sequences xml-writer parser-combinators lazy-lists entities ;
|
|
||||||
USING: xml.utilities kernel promises parser-combinators assocs
|
USING: xml.utilities kernel promises parser-combinators assocs
|
||||||
parser-combinators.replace strings sequences xml.data xml.writer
|
strings sequences xml.data xml.writer
|
||||||
io.streams.string combinators xml xml.entities io.files io
|
io.streams.string combinators xml xml.entities io.files io
|
||||||
http.client ;
|
http.client namespaces xml.generator hashtables ;
|
||||||
|
|
||||||
: ?children>string ( tag/f -- string/f )
|
: ?children>string ( tag/f -- string/f )
|
||||||
[ children>string ] [ f ] if* ;
|
[ children>string ] [ f ] if* ;
|
||||||
|
|
||||||
LAZY: '&' ( -- parser )
|
|
||||||
"&" token
|
|
||||||
[ blank? ] satisfy &>
|
|
||||||
[ "&" swap add ] <@ ;
|
|
||||||
|
|
||||||
: &>& ( string -- string )
|
|
||||||
'&' replace ;
|
|
||||||
|
|
||||||
TUPLE: feed title link entries ;
|
TUPLE: feed title link entries ;
|
||||||
|
|
||||||
C: <feed> feed
|
C: <feed> feed
|
||||||
|
@ -95,3 +85,22 @@ C: <entry> entry
|
||||||
] [
|
] [
|
||||||
2drop "Error retrieving newsfeed file" throw
|
2drop "Error retrieving newsfeed file" throw
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
! Atom generation
|
||||||
|
: simple-tag, ( content name -- )
|
||||||
|
[ , ] tag, ;
|
||||||
|
|
||||||
|
: (generate-atom) ( entry -- )
|
||||||
|
"entry" [
|
||||||
|
dup entry-title "title" simple-tag,
|
||||||
|
"link" over entry-link "href" associate contained*,
|
||||||
|
dup entry-pub-date "published" simple-tag,
|
||||||
|
entry-description "content" simple-tag,
|
||||||
|
] tag, ;
|
||||||
|
|
||||||
|
: generate-atom ( feed -- xml )
|
||||||
|
"feed" [
|
||||||
|
dup feed-title "title" simple-tag,
|
||||||
|
"link" over feed-link "href" associate contained*,
|
||||||
|
feed-entries [ (generate-atom) ] each
|
||||||
|
] make-xml ;
|
||||||
|
|
|
@ -123,3 +123,15 @@ SYMBOL: last-update
|
||||||
[ update-thread ] in-thread ;
|
[ update-thread ] in-thread ;
|
||||||
|
|
||||||
"planet" "planet-factor" "extra/webapps/planet" web-app
|
"planet" "planet-factor" "extra/webapps/planet" web-app
|
||||||
|
|
||||||
|
: merge-feeds ( feeds -- feed )
|
||||||
|
[ feed-entries ] map concat sort-entries ;
|
||||||
|
|
||||||
|
: planet-feed ( -- feed )
|
||||||
|
default-blogroll get [ second news-get ] map merge-feeds
|
||||||
|
>r "[ planet-factor ]" "http://planet.factorcode.org" r> <entry>
|
||||||
|
generate-atom ;
|
||||||
|
|
||||||
|
: feed.xml planet-feed ;
|
||||||
|
|
||||||
|
\ feed.xml { } define-action
|
||||||
|
|
Loading…
Reference in New Issue