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

system.verbs.builtins.html.utilities.buildCDF

on buildCDF (adrsite) { <<build a Microsoft CDF-format file for the site
	<<Original version by Wesley Felter, wesf@mail.utexas.edu
		<<Second version by Dave Winer, dwiner@well.com
			<<Mon, Apr 14, 1997 at 11:18:55 AM by DW
		<<For docs, see http://www.microsoft.com/standards/cdf.htm.
		<<The site must have a #cdf table at the top level. 
	local (adrcdf = @adrsite^.["#cdf"]);
	if not defined (adrcdf^) {
		scriptError (adrsite + " doesn't have contain a #cdf table.")};
	
	local (channeltext = "");
	with adrcdf^ {
		on add (s) {
			channeltext = channeltext + s};
		on dateString (d) {
			local (day, month, year, hour, minute, second);
			date.get (d, @day, @month, @year, @hour, @minute, @second);
			return (year + "." + month + "." + day + "TO" + hour + ":" + minute + timeZone)};
		on addLastMod (adr) {
			add ("<LastMod VALUE=\"" + dateString (timeModified (adr)) + "\" />\r")};
		add ("<!DOCTYPE Channel SYSTEM \"http://www.w3c.org/Channel.dtd\" >\r\r");
		local (adrlist = {});
		bundle { <<add channel header
			add ("<Channel HREF=\"" + siteurl + "\" IsClonable=");
			if isClonable {
				add ("YES")}
			else {
				add ("NO")};
			add (" >\r")};
		bundle { <<add pagesThatChange, each one an "item"
			target.set (@adrcdf^.pagesThatChange);
			op.firstSummit ();
			loop {
				local (title = "", abstract = "", author = "");
				local (adr = op.getLineText ());
				if op.go (right, 1) {
					on gethead () {
						local (s = op.getlinetext ());
						s = string.commentDelete (s);
						s = string.popTrailing (s, ' ');
						op.go (down, 1);
						return (s)};
					url = gethead ();
					title = gethead ();
					abstract = gethead ();
					author = gethead ();
					add ("\r\t<Item ");
					if url != "" {
						add ("HREF=\"" + url + "\"")};
					add (" >\r");
					add ("\t\t"); addLastMod (adr);
					if title != "" {
						add ("\t\t<Title VALUE=\""+ title + "\" />\r")};
					if abstract != "" {
						add ("\t\t<Abstract VALUE=\""+ abstract + "\" />\r")};
					if author != "" {
						add ("\t\t<Author value=\"" + author + "\" />\r")};
					add ("\t\t</Item>\r");
					op.go (left, 1)};
				if not op.go (down, 1) {
					break}};
			target.clear ()};
		bundle { <<add schedule
			add ("\r\t<schedule>\r");
			if defined (schedule.startDate) {
				add ("\t\t<StartDate VALUE=\"" + dateString (schedule.startDate) + "\" />\r")};
			if defined (schedule.endDate) {
				add ("\t\t<EndDate VALUE=\"" + dateString (schedule.endDate) + "\" />\r")};
			if defined (schedule.earliestTime) {
				add ("\t\t<EarliestTime VALUE=\"" + schedule.earliestTime + "\" />\r")};
			if defined (schedule.latestTime) {
				add ("\t\t<LatestTime VALUE=\"" + schedule.latestTime + "\" />\r")};
			if defined (schedule.intervalTime) {
				add ("\t\t<IntervalTime VALUE=\"" + schedule.intervalTime + "\" />\r")};
			add ("\t\t</schedule>\r")};
		add ("\r\t</Channel>");
		};
	return (channeltext)}
<<bundle <<test code
	<<wp.newtextobject (buildCDF (@user.websites.davenet), @scratchpad.cdf)
	<<edit (@scratchpad.cdf)



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.