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

system.verbs.builtins.radio.callbacks.installTool

on installTool (adrTool) {
	<<Changes
		<<12/20/01; 1:03:45 AM by JES
			<<Use file.writeTextFile instead of file.writeWholeFile to write the Tool's website files to disk.
		<<11/26/01; 11:14:17 PM by JES
			<<Possibly install pages from the tool's website into the filesystem. Remove its entry from the websiteFramework responder's docTree table, so the radio responder will handle the hits.
	local (addressList = string.parseAddress (adrTool));
	local (f = addressList [1]);
	local (cleanName = Frontier.tools.cleanToolName (file.fileFromPath (f)));
	local (adrsite = @[f].[cleanName + "Website"]);
	if defined (adrsite^) { //if it doesn't have a website, do nothing
		if not defined (adrsite^.["#template"]) { //if the website has a template, let the websiteFramework responder take the hits
			local (pc = file.getPathChar ());
			local (folder = user.radio.prefs.wwwfolder + cleanName + pc);
			bundle { //write a #upstream.xml to the folder, whose type is none
				local (f = folder + radio.data.fileNames.upstreamFileName);
				file.sureFilePath (f);
				file.writeWholeFile (f, "<upstream type=\"none\"/>")};
			local (adritem);
			on installItem (adritem, folder) {
				local (itemname = nameOf (adritem^));
				if not (itemname beginsWith "#") { //a page or a table
					local (filetext, extension = ".txt");
					case typeOf (adritem^) {
						tableType {
							local (subfolder = folder + itemname + pc);
							local (adrsubitem);
							for adrsubitem in adritem {
								installItem (adrsubitem, subfolder)};
							continue};
						scriptType { //make a wrapper file
							local (adrpage = string.popFileFromAddress (adritem));
							filetext = "<%" + adrpage + " ()%>"};
						outlineType { //convert to opml
							filetext = op.outlineToXml (adritem);
							extension = ".opml"}}
					else { //coerce to string, and write the file
						filetext = string (adritem^)};
					local (f = folder + itemname + extension);
					file.sureFilePath (f);
					file.writeTextFile (f, filetext)}};
			for adritem in adrsite { //install the tool's website pages into the www folder
				installItem (adritem, folder)};
			bundle { //delete the entry for the Tool's website in the websiteFramework responder's docTree
				if defined (user.webserver.responders.websiteFramework.data.docTree.[cleanName]) {
					delete (@user.webserver.responders.websiteFramework.data.docTree.[cleanName])}}}};
	return (true)} //always allow the Tool to be installed
<<bundle //testing
	<<installTool ("Backup:Radio UserLand:Tools:whoIs.root")



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.