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

system.verbs.builtins.radio.weblog.getRssUrl

on getRssUrl (adrblog) {
	<<2/17/01; 6:02:53 PM by JES
		<<Get the URL of a blog's RSS file, 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
		<<Changes:
			<<2/19/01 at 1:06:47 AM by JES
				<<Generate the proper URL even if the home page filename is specified at adrprefs^.ftp.url, and not just the directory.
	local (adrprefs = @adrblog^.prefs);
	local (url);
	
	<<bundle //old code
		<<if adrprefs^.ftp.enabled
			<<local (path = adrprefs^.rssFilePath)
			<<local (filename = string.nthField (path, '/', string.countFields (path, '/')))
			<<url = adrprefs^.ftp.url
			<<if not (url endsWith "/")
				<<url = string.mid (url, 1, sizeOf (url) - sizeOf (string.nthField (url, "/", string.countFields (url, "/"))))
			<<url = url + filename
			<<return (url)
		<<if adrprefs^.manila.enabled
			<<url = adrprefs^.manila.url
			<<if not (url endsWith "/")
				<<url = url + "/"
			<<url = url + "xml/rss.xml"
			<<return (url)
		<<if user.playlist.data.upstream.enabled
			<<local (pc = file.getPathChar ())
			<<local (path = adrprefs^.rssFilePath)
			<<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 (relPath = string.popLeading (adrprefs^.rssFilePath, '/'));
	local (f = user.radio.prefs.wwwfolder + string.replaceAll (relPath, '/', pc));
	if file.exists (f) {
		local (adrfile);
		radio.file.getFileAttributes (f, @adrfile);
		local (adrspec);
		if radio.upstream.getUpstreamSpec (adrfile, @adrspec) {
			if adrfile^.upstream.url != "" {
				return (adrfile^.upstream.url)}}};
	
	url = "/" + relPath;
	if not (url beginswith "/") {
		url = "/" + url};
	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.getRssUrl (radio.weblog.init ())



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.