Client- vs server-side scripting with Radio

Jon Udell talks about client- vs server-side scripting with Radio: Radio pages, for example, are dynamically generated but statically served — a strategy that I like very much on the whole, but sometimes chafe at when nifty features like TrackBack and your search extender show up in MT.

For some time now I’ve been considering moving away from Radio. I like a lot of its features, but whilst I can muddle my way around Radio’s macro system, I find it much easier to do things in Perl. And, as the pages are generated, rather than calculated, there’s lots of nifty things I’d like to do, but can’t.

And then it struck me, that actually I could solve both of these problems in one simple step – SSI.

So, I decided to try to implement one feature I’ve been wanting for quite some time: a “further reading”-type feature, like that at dive into mark etc, that tracks referrers back:

I turned SSI on in Apache for my blog directory, and wrote an Apache Logging Handler that throws the referrer information into a MySQL database. Then I wrote a simple CGI script that tallies up the referrers for a given page, and outputs them as HTML.

Then in my Day Template, I added the line:

<!--#include virtual="/cgi-bin/getlinks?date=<%longDate%>" -->

Now when Radio generates my page, it will include the SSI command in the static page, which in turn will get called at page request time, calculating the HTML to insert in the final document.

Hey presto! Server-side scripting, in Perl, with Radio.

(My only nit is that I have to pass a date with spaces in it as an argument to the CGI script. If anyone knows how I can reformat the ‘longdate’ macro output in Radio, I’d love to hear …)

Leave a Reply

Your email address will not be published. Required fields are marked *