Hardcoded RSS (Updated) »
FERDY CHRISTANT - AUG 20, 2004 (07:10:31 PM)
As I'm distributing early versions of this blog template to quite some folks now, a problem keeps returning: a hardcoded domain name in the RSS feed of the blog template. This is highly annoying, because participants need to alter the feed every time I send an update. I wonder if there's a brilliant mind out there who can help me with this.
Allow me to explain some current implementation details. The RSS feed is really simple, I have a RSS page which has an embedded RSS view. On the page, I can do a @GetHTTPHeader("Host") to retrieve the host name on the fly. This hostname I use as a prefix for the main RSS link. In the view, however, I can't do this:
Notice my hardcoded domain name in the column formula of the RSS view. This is the formula participants have to change back to their domain with every update of the template, because I don't have a way to dynamically get the host name from within the view.
I know that a way to do it is to store the host name on every document as a field, but that's just a crappy solution. If the host name changes, everything will break. I could also make the host name a new field in the application setup and upon change stamp all blog documents with the new host name, but none of these "solutions" make me happy.
Does anyone know another solution to this? Is it possible to put RSS in a mode where all links are relative to a base link? By default this doesn't work, but perhaps there's a tag for it? Anything is welcome, this is the only thing stopping me from releasing the next version :(
I did some research myself and found out that the RSS spec does not support relative links, very few feed readers allow it, so it's not a safe option to use relative links in RSS feeds. I have implemented a temporary solution where I can live with:
The key was to replace the embedded view with a lookup:
@IsError(txlRSS) | txlRSS = "";"";
@ReplaceSubstring(@Subset(txlRSS;10);"<BASE>";"http://" + @GetHTTPHeader("Host"))
So I simply take the last 10 RSS entries from the view and then replace the BASE word with the dynamic host name. This BASE text defined in the column formula of the lookup view.
I know this is slower than an embedded view, but it seems quite responsive. I simulated the lookup on a set of blog entries that would take me 20 years to create and performance did not really decrease, nor was the lookup limit exceeded. Problem solved for now, until a better solution comes along :)