diff --git a/contrib/rss/readme.txt b/contrib/rss/readme.txt
index c6a7c0f9c2..2f0885b569 100644
--- a/contrib/rss/readme.txt
+++ b/contrib/rss/readme.txt
@@ -14,14 +14,9 @@ somewhere:
Replacing "libsqlite3.so" with the path to the sqlite shared library
or DLL. I put this in my ~/.factor-rc.
-Before running the RSS reader web application you need to create the
-history database in the same directory as the 'f' executable. Create
-it with:
-
- sqlite3 history.db
- > create table rss (url text, title text, link text, primary key (url));
- > create table entries (url text, link text, title text, description text, pubdate text, primary key(url, link));
- > [eof]
+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:
diff --git a/contrib/rss/rss-reader.factor b/contrib/rss/rss-reader.factor
index ae3d8f3b73..b6ed9ad626 100644
--- a/contrib/rss/rss-reader.factor
+++ b/contrib/rss/rss-reader.factor
@@ -9,20 +9,36 @@
! > [eof]
!
IN: rss
-USING: kernel html cont-responder namespaces sequences io hashtables sqlite errors ;
+USING: kernel html cont-responder namespaces sequences io hashtables sqlite errors tuple-db ;
-SYMBOL: feeds
+TUPLE: reader-feed url title link ;
+TUPLE: reader-entry url link title description pubdate ;
-: init-feeds ( -- )
- V{ } clone feeds set-global ;
+reader-feed default-mapping set-mapping
+reader-entry default-mapping set-mapping
+
+SYMBOL: db
+
+: init-db ( -- )
+ db get-global [ sqlite-close ] when*
+ "rss-reader.db" exists? [
+ "rss-reader.db" sqlite-open db set-global
+ ] [
+ "rss-reader.db" sqlite-open dup db set-global
+ dup reader-feed create-tuple-table
+ reader-entry create-tuple-table
+ ] if ;
: add-feed ( url -- )
- feeds get push ;
+ "" ""
- rss-entry-description write
+ reader-entry-description write
dup rss-entry-title write
+ dup reader-entry-title write
- feeds get [
+ all-urls [
] each
dup write
dup [ remove-feed ] curry "Remove" swap quot-href
- [ view-entries ] curry "Database" swap quot-href
+ [ display-entries ] curry "Database" swap quot-href
"Add Feed" [ get-feed add-feed ] quot-href
-"Update Feeds" [ feeds get update-feeds ] quot-href
+"Add Feed" [ ask-for-url add-feed ] quot-href
+"Update Feeds" [ all-urls update-feeds ] quot-href
] show-final ; -init-feeds - - -"maintain-feeds" [ maintain-feeds ] install-cont-responder +"maintain-feeds" [ init-db maintain-feeds ] install-cont-responder