last updated:

Manila automatically generates XML for you so that you can include your site in aggregator-type sites (like My.Userland). It remains faithful to your links — if you specify a relative URL in a link, then the XML generates a link that’s relative. This is a problem if the aggregator isn’t smart about realizing that the link is relative and prepending your site’s URL onto the link — then you end up with links on the aggregator that are relative to the aggregator’s home page, rather than to your own. (This is the exact behavior displayed by My.Userland, and it looks like they’re unwilling to fix it.)

(I won’t go into my perceived benefits of relative vs. absolute URLs here; suffice it to say that I believe that any links to your own website should be relative, not absolute, and this is what drives this bug fix.)

The problem that the aggregator has can prevented by just having your Manila site generate XML that has fixes the relative URLs on-the-fly, thus not giving the aggregator a chance to screw them up.

I posted a patch to Discuss.Userland today, in the belief that (a) since I knew how to fix the bug and knew how to write the code to do it, I shouldn’t just whine for them to fix it, and (b) because I really wanted Manila to be a better product; unfortunately, you can’t read the patch there, since Dave Winer deleted it. (I guess all his talk about the terrific Frontier community isn’t as genuine as it seems to be, which I find funny since his employees readily and quickly fixed the major mainResponder security bug that I found a few weeks back.) So I’ve posted the apparently-controversial patch here, all five lines of it.

For those who want to fix this problem on their own sites, here’s the five-line addition to manilaSuite.xml.getScriptingNewsXml that will solve the issue entirely.

In the extractLinks procedure, within the loop, there are two lines that read:

url = string.mid (s, 1, ix - 1)
s = string.delete (s, 1, ix)

Between these two lines, add the following code:

if string.patternMatch(":", url) == 0 // means that the link is relative
if string.mid(url, 1, 1) == "/"
url = pta^.ftpSite^.url + string.mid(url, 2, infinity)
else
url = pta^.ftpSite^.url + url

My site has this code running now, and my relative links appear correct (in other words, I add the site prefix) in the XML.

(Note that I stressed a little about doing the patternMatch for a colon — I didn’t know if that’s a legit test to see whether or not the url includes a protocol prefix or not, since I didn’t know if a colon could be elsewhere in a URL but as a delimiter after the protocol prefix. But according to the RFC on URIs, the colon is a reserved character for just this purpose.)

If you don’t want to muck with Userland’s code (like I don’t), then do what I did — copy the script into another location and edit it there, and then change the script that sits in your site table at xml/scriptingNews2.xml from calling the Userland version to calling your own. Remember that you’ll have to keep your eyes out for updates to the officially-sanctioned version of the script, and roll them into your own as well.