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

system.verbs.builtins.radio.menuCommands.openTemplateFile

on openTemplateFile (fname) {
	<<Changes
		<<11/7/01; 10:09:20 PM by JES
			<<If there's no editor configured for files of mimetype text/plain, ask the user if they would like to open the file with Radio UserLand.
		<<11/1/01; 8:43:47 AM by DW
			<<Created
	
	local (atts);
	local (f = user.radio.prefs.wwwfolder + "xxx");
	radio.webServer.gatherAttributes (f, @atts);
	<<scratchpad.atts = atts
	f = atts.[fname];
	local (mimetype = radio.webserver.getfilemimetype (f));
	local (adreditor = @user.radio.prefs.editors.[mimetype]);
	if not defined (adreditor^) {
		local (adrplaineditor = @user.radio.prefs.editors.["text/plain"]);
		if defined (adrplaineditor^) {
			if not dialog.confirm ("There is no editor configured for files of type \"" + mimetype + "\". Would you like to open the file with " + file.filefrompath (adrplaineditor^) + "?") {
				return};
			adreditor = adrplaineditor}
		else { //use radio?
			if not dialog.confirm ("There is no editor configured for files of type \"" + mimetype + "\". Would you like to open the file with Radio UserLand?") {
				return};
			fileMenu.open (f); //launch.appWithDocument doesn't work for Radio running on MacOS X under Classic, but filemenu.open does work.
			return}};
	launch.appWithDocument (adreditor^, f)}
<<bundle //test code
	<<openTemplateFile ("homeTemplate")



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.