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

system.verbs.builtins.xml.aggregator.saveServicesXml

on saveServicesXml (f, adrIncludeCallback=nil) {
	<<Changes
		<<4/2/03; 11:44:25 PM by JES
			<<Factored the code that generates the XML to a new verb, xml.aggregator.getServicesXml. New optional parameter, adrIncludeCallback, passed to xml.aggregator.getServicesXml. If supplied, the callback script is called with the address of the service table. If it returns true, the service is included; if it returns false, the service is not included.
		<<12/17/01; 5:06:14 PM by DW
			<<If the url of a service has a username:password encoded, don't include it in the file.
		<<3/1/01; 11:48:38 PM by JES
			<<Use Frontier.id, instead of hard-coding 'Radu'.
		<<2/22/01; 9:28:50 PM by JES
			<<If this is a Mac, convert the opml text to Latin before writing the file.
		<<2/13/01; 3:27:29 PM by PBS
			<<Save mySubscriptions.opml as a Radio UserLand document on Macs.
		<<2/5/01; 6:22:03 PM by DW
			<<Only save if myUserLandData.stats.flSaveMySubscriptions is defined and true.
		<<1/23/01; 11:50:02 AM by DW
			<<Don't let a problem with one channel stop the rendering of all. This is a startup issue, this script is called when we're first initialized, and I can't stop to figure out what it is about which channel that's stopping us.
		<<1/2/01; 5:04:10 PM by DW
			<<If a table doesn't have a compilation sub-table, don't add it to the services file.
		<<1/1/01; 11:21:33 AM by DW
			<<Save an OPML file containing the services the user is subscribed to the rss/misc upstreamed folder.
	<<bundle //old code
		<<local (mySubscriptions)
		<<new (outlinetype, @mySubscriptions)
		<<local (oldtarget = target.set (@mySubscriptions))
		<<
		<<local (adrdata = xml.aggregator.init ())
		<<local (adrservice, atts)
		<<for adrservice in @adrdata^.services
			<<if defined (adrservice^.compilation)
				<<local (url = nameof (adrservice^), flcontainspassword = false)
				<<bundle //set flcontainspassword
					<<try
						<<local (urllist = string.urlsplit (url))
						<<flcontainspassword = urllist [2] contains "@"
				<<if not flcontainspassword
					<<try
						<<op.insert (adrservice^.compilation.channeltitle, down)
						<<new (tabletype, @atts)
						<<atts.type = "rss"
						<<atts.xmlUrl = url
						<<atts.htmlUrl = adrservice^.compilation.channellink
						<<atts.title = adrservice^.compilation.channeltitle
						<<atts.version = adrservice^.compilation.format
						<<atts.description = adrservice^.compilation.channeldescription
						<<try
							<<atts.language = adrservice^.compilation.language
						<<else
							<<atts.language = "unknown"
					<<op.attributes.addgroup (@atts)
		<<op.firstsummit ()
		<<op.deleteline ()
		<<target.set (oldtarget)
		<<
		<<settimecreated (@mySubscriptions, timecreated (@adrdata^.services))
		<<scratchpad.mySubscriptions = mySubscriptions; edit (@scratchpad.mySubscriptions)
		<<
		<<local (xmltext = op.outlineToXml (@mySubscriptions))
	local (adrdata = xml.aggregator.init ());
	local (xmltext = xml.aggregator.getServicesXml (adrdata, adrIncludeCallback));
	if system.environment.isMac { //02/22/2001 JES: convert to Latin text
		xmltext = latinToMac.macToLatin (xmltext)};
	file.surefilepath (f);
	file.writewholefile (f, xmltext, 'OPML', Frontier.id)}
<<bundle //test code
	<<local (f = file.getSystemDisk () + "mySubscriptions.xml")
	<<saveServicesXml (f)



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.