Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.cloud.getInitialResources
on getInitialResources (adrCloudInfo=@user.radio.prefs.defaultCloud) { <<Changes <<5/14/02; 6:36:11 PM by JES <<If the server doesn't return a themesDirectoryOpml url, set radio.data.cloudUrls.themesDirectoryOpml 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 user.radio.prefs.usernum 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 = "subhonker7.userland.com" <<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 == "radio.xmlstoragesystem.com" { radio.data.staticSiteStats.groupName = "radio1"} else { radio.data.staticSiteStats.groupName = "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) { radio.data.cloudUrls.commentsPageUrl = initialResources.commentsPageUrl; local (adrblog = radio.weblog.init ()); adrblog^.prefs.commentsPageUrl = initialResources.commentsPageUrl}}; bundle { //themes if defined (initialResources.themesDirectory) { radio.data.cloudUrls.themesDirectoryOpml = initialResources.themesDirectory} else { //this server doesn't supply Themes -- set to the empty string radio.data.cloudUrls.themesDirectoryOpml = ""}; if not defined (user.radio.prefs.usernum) { 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) { radio.data.cloudUrls.aggregatorBootstrap = initialResources.defaultFeeds}; if radio.data.flDoInitialScan { //read default subscriptions, and run the first news scan radio.data.flDoInitialScan = false; thread.callScript (@xml.aggregator.bootstrap, {radio.data.cloudUrls.aggregatorBootstrap})}}; return (initialResources)}; <<bundle //testing <<local (cloudInfo = user.radio.prefs.defaultCloud) <<cloudInfo.server = "127.0.0.1" <<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.