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

on getInitialResources ( {
		<<5/14/02; 6:36:11 PM by JES
			<<If the server doesn't return a themesDirectoryOpml url, set to the empty string.
		<<3/20/02; 4:52:48 PM by JES
			<<Only apply the default theme if this is a fresh install -- if is defined.
		<<3/11/02; 4:08:29 PM by JES
			<<Moved to the cloud sub-table.
		<<3/10/02; 10:43:43 PM by JES
			<<Commented out debugging code.
		<<3/10/02; 10:40:29 PM by JES
			<<Make the getInitialResources RPC call in a try block, in case the server doesn't understand the message -- for backward-compatibility.
		<<3/10/02; 10:39:10 PM by JES
			<<Make sure that the rpcPath begins with a slash-character.
		<<3/10/02; 2:18:39 PM by JES
			<<Factored from radio.bootstrap. Now we synchronize themes, and apply the default theme, if it exists. We also set the commentsPageUrl, if defined in the initialResources return struct.
		<<3/1/02; 11:38:27 AM by JES
			<<Perform all of the bootstrapping needed to connect to a community for the first time.
	local (rcsServer, rcsPort, rcsProtocol, rcsRpcPath);
	with adrCloudInfo^ { //get cloud info
		rcsServer = server;
		rcsPort = port;
		rcsProtocol = protocol;
		rcsRpcPath = rpcPath;
		if not (rcsRpcPath beginsWith "/") {
			rcsRpcPath = "/" + rcsRpcPath}};
		<<bundle //old hard-coded values
			<<rcsServer = ""
			<<rcsPort = 80
			<<rcsProtocol = "xml-rpc"
			<<rcsRpcPath = "/RPC2"
	local (rcs = string.dropNonAlphas (rcsProtocol) + "://" + rcsServer + ":" + rcsPort + rcsRpcPath);
	local (initialResources); new (tableType, @initialResources);
	<<initialResources = [rcs].radioCommunityServer.getInitialResources ()
	try {initialResources = [rcs].radioCommunityServer.getInitialResources ()}; //backward-compatible
	local (adrdata = radio.weblog.init ());
	on readOpmlUrl (url) { //like tcp.httpReadUrl, but passes flAcceptOpml as true
		local (urllist = string.urlsplit (url));
		return (string.httpResultSplit (tcp.httpClient (server:urllist [2], path:urllist [3], flAcceptOpml:true)))};
	bundle { //default stats group
		if rcsServer == "" { = "radio1"}
		else { = "default"}};
	bundle { //categories
		if defined (initialResources.defaultCategories) {
			local (categories);
			xml.compile (readOpmlUrl (initialResources.defaultCategories), @categories);
			local (nomad = xml.getAddress (@categories, "opml"));
			nomad = xml.getAddress (nomad, "body");
			nomad = xml.getAddress (nomad, "outline");
			local (adr);
			for adr in nomad {
				if (nameOf (adr^) == "/atts") {continue};
				local (catname = xml.getAttributeValue (adr, "text"));
				if defined (adrdata^.categories.[catname]) {continue};
				local (description = "Describe this category here.");
				try {description = xml.getAttributeValue (adr, "description")};
				local (flRenderHtml = false);
				try {flRenderHtml = boolean (xml.getAttributeValue (adr, "flRenderHtml"))};
				local (language = "en-us");
				try {language = boolean (xml.getAttributeValue (adr, "language"))};
				local (flNotifyWeblogsCom = true);
				try {flNotifyWeblogsCom = boolean (xml.getAttributeValue (adr, "flNotifyWeblogsCom"))};
				radio.weblog.newCategory (catname, description, flRenderHtml, language, flNotifyWeblogsCom)}}
		else {
			on initCategory (catname) {
				radio.weblog.newCategory (catname, "Describe this category here.")};
			initCategory ("My Friends");
			initCategory ("My Hobbies");
			initCategory ("My Interests");
			initCategory ("My Organization");
			initCategory ("My Profession")}};
	bundle { //comments page
		if defined (initialResources.commentsPageUrl) { = initialResources.commentsPageUrl;
			local (adrblog = radio.weblog.init ());
			adrblog^.prefs.commentsPageUrl = initialResources.commentsPageUrl}};
	bundle { //themes
		if defined (initialResources.themesDirectory) { = initialResources.themesDirectory}
		else { //this server doesn't supply Themes -- set to the empty string = ""};
		if not defined ( {
			radio.theme.updateThemes ()}};
	bundle { //apply default theme
		local (f = radio.theme.getThemeFilePath ("default"));
		if file.exists (f) {
			local (theme);
			radio.theme.importThemeFile (f, @theme);
			radio.theme.apply.main (@theme)}};
	bundle { //rss feeds
		if defined (initialResources.defaultFeeds) { = initialResources.defaultFeeds};
		if { //read default subscriptions, and run the first news scan = false;
			thread.callScript (@xml.aggregator.bootstrap, {})}};
	return (initialResources)};

<<bundle //testing
	<<local (cloudInfo =
	<<cloudInfo.server = ""
	<<cloudInfo.port = "8888"
	<<getInitialResources (@cloudInfo)

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.