diff --git a/basis/syndication/readme.txt b/basis/syndication/readme.txt deleted file mode 100644 index 2e64b0d52a..0000000000 --- a/basis/syndication/readme.txt +++ /dev/null @@ -1,32 +0,0 @@ -This library is a simple RSS2 parser and RSS reader web -application. To run the web application you'll need to make sure you -have the sqlite library working. This can be tested with - - "contrib/sqlite" require - "contrib/sqlite" test-module - -Remember that to use "sqlite" you need to have done the following -somewhere: - - USE: alien - "sqlite" "/usr/lib/libsqlite3.so" "cdecl" add-library - -Replacing "libsqlite3.so" with the path to the sqlite shared library -or DLL. I put this in my ~/.factor-rc. - -The RSS reader web application creates a database file called -'rss-reader.db' in the same directory as the Factor executable when -first started. This database contains all the feed information. - -To load the web application use: - - "contrib/rss" require - -Fire up the web server and navigate to the URL: - - http://localhost:8888/responder/maintain-feeds - -Add any RSS2 compatible feed. Use 'Update Feeds' to retrieve them and -update the sqlite database with the feed contains. Use 'Database' to -view the entries from the database for that feed. - diff --git a/basis/syndication/syndication-docs.factor b/basis/syndication/syndication-docs.factor new file mode 100644 index 0000000000..5604a94dbd --- /dev/null +++ b/basis/syndication/syndication-docs.factor @@ -0,0 +1,68 @@ +USING: help.markup help.syntax io.streams.string strings urls +calendar xml.data xml.writer present ; +IN: syndication + +HELP: entry +{ $description "An Atom or RSS feed entry. Has the following slots:" + { $table + { "Name" "Class" } + { "title" { $link string } } + { "url" { "any class supported by " { $link present } } } + { "description" { $link string } } + { "date" { $link timestamp } } + } +} ; + +HELP: +{ $values { "entry" entry } } +{ $description "Creates a new entry." } ; + +HELP: feed +{ $description "An Atom or RSS feed. Has the following slots:" + { $table + { "Name" "Class" } + { "title" { $link string } } + { "url" { "any class supported by " { $link present } } } + { "entries" { "a sequence of " { $link entry } " instances" } } + } +} ; + +HELP: +{ $values { "feed" feed } } +{ $description "Creates a new feed." } ; + +HELP: download-feed +{ $values { "url" url } { "feed" feed } } +{ $description "Downloads a feed from a URL using the " { $link "http.client" } "." } ; + +HELP: string>feed +{ $values { "string" string } { "feed" feed } } +{ $description "Parses a feed in string form." } ; + +HELP: xml>feed +{ $values { "xml" xml } { "feed" feed } } +{ $description "Parses a feed in XML form." } ; + +HELP: feed>xml +{ $values { "feed" feed } { "xml" xml } } +{ $description "Converts a feed to Atom XML form." } +{ $notes "The result of this word can then be passed to " { $link write-xml } ", or stored in an HTTP response object." } ; + +ARTICLE: "syndication" "Atom and RSS feed syndication" +"The " { $vocab-link "syndication" } " vocabulary implements support for reading Atom and RSS feeds, and writing Atom feeds." +$nl +"Data types:" +{ $subsection feed } +{ $subsection } +{ $subsection entry } +{ $subsection } +"Reading feeds:" +{ $subsection download-feed } +{ $subsection string>feed } +{ $subsection xml>feed } +"Writing feeds:" +{ $subsection feed>xml } +"The " { $vocab-link "furnace.syndication" } " vocabulary builds on top of this vocabulary to enable easy generation of Atom feeds from web applications. The " { $vocab-link "webapps.planet" } " vocabulary is a complete example of a web application which reads and exports feeds." +{ $see-also "urls" } ; + +ABOUT: "syndication" diff --git a/basis/syndication/syndication.factor b/basis/syndication/syndication.factor index a432d8c31c..ca7511f1af 100644 --- a/basis/syndication/syndication.factor +++ b/basis/syndication/syndication.factor @@ -102,12 +102,12 @@ TUPLE: entry title url description date ; { "feed" [ atom1.0 ] } } case ; -: read-feed ( string -- feed ) +: string>feed ( string -- feed ) [ string>xml xml>feed ] with-html-entities ; : download-feed ( url -- feed ) #! Retrieve an news syndication file, return as a feed tuple. - http-get nip read-feed ; + http-get nip string>feed ; ! Atom generation : simple-tag, ( content name -- )