Monday, November 08, 2010 at 12:00 AM.


on readList (urlList) {
		<<9/3/09; 4:14:23 AM by DW
			<<Get the listinfo for the reading list from the OPML.
		<<8/16/09; 11:02:16 AM by DW
	local (adrdata = river2suite.init (), xmltext = tcp.httpreadurl (urlList), feeds);
	local (adrlist = river2Suite.initList (urlList), now = (), startticks = clock.ticks ());
	xml.rss.getOpmlFeeds (xmltext, @feeds, @adrlist^.listInfo);
	on logmebaby (action, url, title) { //gotta log this shit to keep from going crazy
		local (adrday = mainresponder.calendar.getdayaddress (@adrlist^.calendar, now));
		local (adritem = @adrday^.[string.padwithzeros (sizeof (adrday^) + 1, 3)]);
		new (tabletype, adritem);
		adritem^.action = action;
		adritem^.url = url;
		adritem^.title = title};
	bundle { //figure out which feeds disappeared
		local (i, adroldfeed, url);
		for i = sizeof (adrlist^.feeds) downto 1 {
			adroldfeed = @adrlist^.feeds [i];
			url = nameof (adroldfeed^);
			if not defined (feeds.[url]) { //goodbye compadre
				local (title = adroldfeed^.atts.title);
				logmebaby ("Unsubbed", url, title);
				delete (adroldfeed); //delete in the list's feeds table
				local (adrfeed = river2suite.initfeed (url)); //now find the feed in the global table
				delete (@adrfeed^.lists.[urlList]);
				if (sizeof (adrfeed^.lists) == 0) and (not adrfeed^.prefs.flNonListSubscribe) {
					logmebaby ("Goodbye Feed", url, title);
					delete (adrfeed)}}}};
	bundle { //figure out which feeds are new
		local (adrnewfeed, url);
		for adrnewfeed in @feeds {
			url = nameof (adrnewfeed^);
			if not defined (adrlist^.feeds.[url]) { //greetings my new amigo
				logmebaby ("Subbed", url, adrnewfeed^.atts.title);
				adrlist^.feeds.[url] = adrnewfeed^;
				bundle { //now deal with the feed in the global table
					local (flerror = false);
					if not defined (adrdata^.feeds.[url]) { //we don't already know about the feed!
						local (startticks = clock.ticks ());
						try {
							river2Suite.readFeed (url);
							local (adrfeed = river2suite.initfeed (url));
							adrfeed^.stats.whenSubscribed = now;
							adrdata^.prefs.flNonListSubscribe = false; //we only know about it through a list
							log2.add (, "Subscribe", "<a href=\"" + url + "\">" + adrfeed^.feedinfo.title + "</a>.", startticks)}
						else {
							local (s = tryerror, adrfeed = river2suite.initfeed (url));
							log2.add (, "Subscribe", "Error subscribing to \"" + url + "\": " + s, startticks);
							delete (adrfeed);
							flerror = true}};
					if not flerror {
						local (adrfeed = river2suite.initfeed (url));
						adrfeed^.lists.[urlList] = now}}}}};
	<<scratchpad.feedsReadingList = adrlist^.feeds
	adrlist^.stats.whenLastRead = now};
bundle { //test code
	readList ("")}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.