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


on rssUpdate (url, whenLastCheck, adrCtNewParts) {
		<<2/18/07; 8:01:15 AM by DW
			<<Because the feed is now written in reverse-chronologic order, we must process the updates starting at the bottom of the feed and work our way up. To see why this is true, consider this case...
				<<On Tuesday we update examples.counters.
				<<On Wednesday we update examples.counters.test2.
				<<If we were to process the second update before the first, we'd wipe out he change to test2 when we update its parent table. But that wasn't the intention of the author. We have to perform the changes in the order the author performed them or else we'll break the app.
		<<2/17/07; 4:20:33 AM by DW
	local (xmltext = tcp.httpreadurl (url));
	xml.compile (xmltext, @xstruct);
	<<scratchpad.xstruct = xstruct
	local (adrrss = xml.getaddress (@xstruct, "rss"));
	local (adrchannel = xml.getaddress (adrrss, "channel"));
	local (adritem, i);
	for i = sizeof (adrchannel^) downto 1 {
		adritem = @adrchannel^ [i];
		if nameof (adritem^) contains "item" {
			local (pubdate = date (xml.getvalue (adritem, "pubDate")));
			local (title = xml.getvalue (adritem, "title"));
			if pubdate > whenLastCheck {
				local (adrenclosure = xml.getaddress (adritem, "enclosure"));
				local (urlpart = xml.getattribute (adrenclosure, "url")^);
				local (bits = tcp.httpreadurl (urlpart), atts);
				bits = string.replaceAll (bits, cr + lf, cr);
				bits = string.replaceAll (bits, lf, cr);
				on partError () {
					scriptError ("The part, \"" + title + "\", does not contain an embedded object.")};
				if not fatPages.getPageAtts (@bits, @atts) {
					partError ()};
				if not defined (atts.pageData) {
					partError ()};
				local (x = atts.objectType, objectType);
				local (prefix = "application/x-frontier-");
				if not (x beginsWith prefix) {
					partError ()};
				objectType = string.delete (x, 1, sizeof (prefix));
				local (data = binary (base64.decode (atts.pageData)));
				setBinaryType (@data, objectType);
				table.surePath (string (atts.adrPageData));
				unpack (@data, atts.adrPageData);
bundle { //test code
	window.about ();
	rssUpdate ("", date ("12/1/2006"))}

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.