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

system.verbs.builtins.radio.weblog.getUrl

on getUrl (adrblog = radio.weblog.init ()) {
	<<Changes:
		<<2/26/02; 9:59:54 PM by JES
			<<Don't return a hard-coded radio.weblogs.com url if the cached url for the www folder doesn't exist. Instead return the url returned by radio.upstream.getFileUrl, which is constructed from the server capabilities or values in the upstream spec (depending on the spec's type).
		<<12/24/01; 3:31:33 AM by JES
			<<If user.radio.prefs.usernum is not defined, return pta^.uri. If we can't get the pagetable address, return the empty string.
		<<12/17/01; 1:07:17 PM by JES
			<<Respect the pref at adrblog^.prefs.homePageFilePath.
		<<12/17/01; 12:38:04 PM by JES
			<<If the home page has never been upstreamed, return the radio.weblogs.com URL. Default value for adrblog is the value returned by radio.weblog.init.
		<<12/5/01; 3:10:48 PM by JES
			<<Return the url of the upstreamed www folder, instead of the url of the home page itself.
		<<Archive
			<<2/19/01 at 1:07:50 AM by JES
				<<Generate the correct URL when the filename is specified at adrprefs^.ftp.url, not just the directory.
			<<2/17/01; 5:43:44 PM by JES
				<<Get the URL of a blog, given the address of its table.
					<<Here's the order of precedence:
						<<1- The FTP version
						<<2- The Manila version
						<<3- The version in the cloud
						<<4- The locally served version
	local (adrprefs = @adrblog^.prefs);
	local (url);
	
	<<bundle //old code
		<<if adrprefs^.ftp.enabled
			<<url = adrprefs^.ftp.url
			<<if (url endsWith "/")
				<<local (path = adrprefs^.homePageFilePath)
				<<local (filename = string.nthField (path, '/', string.countFields (path, '/')))
				<<url = url + filename
			<<return (url)
		<<if adrprefs^.manila.enabled
			<<return (adrprefs^.manila.url)
		<<if user.playlist.data.upstream.enabled
			<<local (pc = file.getPathChar ())
			<<local (path = adrprefs^.homePageFilePath)
			<<if path beginsWith "/"
				<<path = string.mid (path, 2, infinity)
			<<path = string.replaceAll (path, "/", pc)
			<<if defined (user.playlist.data.upstream.files.[path])
				<<if defined (user.playlist.data.upstream.files.[path].url)
					<<return (user.playlist.data.upstream.files.[path].url)
	
	local (pc = file.getPathChar ());
	local (folder = file.folderFromPath (radio.file.getAbsolutePath (adrblog^.prefs.homePageFilePath)));
	local (adrfolder = @user.radio.settings.files.[folder]);
	if defined (adrfolder^) {
		if adrfolder^.upstream.url != "" {
			return (adrfolder^.upstream.url)}};
	
	return (radio.upstream.getFileUrl (folder));
	}
	<<bundle //more old code
		<<if defined (user.radio.prefs.usernum)
			<<return ("http://radio.weblogs.com/" + string.padWithZeros (user.radio.prefs.usernum, 7) + "/")
		<<try
			<<local (pta = html.getPageTableAddress ())
			<<return (pta^.uri)
		<<return ("")
	<<bundle //old code
		<<local (relPath = string.popLeading (adrprefs^.homePageFilePath, '/'))
		<<url = "/" + relPath
		<<local (ip = tcp.dns.getMyDottedId ())
		<<local (port = user.inetd.config.http.port)
		<<if port == 80
			<<port = ""
		<<else
			<<port = ":" + port
		<<url = "http://" + ip + port + url
		<<return (url)
<<bundle //debugging
	<<radio.weblog.getUrl ()



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.