Docs for syndication vocab
parent
853f1ef5a6
commit
d312c97171
|
@ -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.
|
||||
|
|
@ -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: <entry>
|
||||
{ $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: <feed>
|
||||
{ $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 <feed> }
|
||||
{ $subsection entry }
|
||||
{ $subsection <entry> }
|
||||
"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"
|
|
@ -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 -- )
|
||||
|
|
Loading…
Reference in New Issue