Press "Enter" to skip to content

Category: Navel-Gazing

Jumping off the Empire State

It’s pretty much traditional among a certain class of geek bloggers to come up with a way to set up an email->blog gateway. I’ve sort of put this off for a while, but since I’m pretty sure I’m about to go out and indulge in a Sidekick, the day can be delayed no longer. Thus: this entry, which was in fact posted wholly from within my email client.

Which is mutt, and you can’t tell me that doesn’t make it worse.

Signifying nothing

I’m a geek. I’ve finally given into the desire to make Population: One even more full of cute little Web gimmicks; namely, we’re PHP-based now. If this means nothing to you, you ought to ignore it, which is generally good advice around here. Unless I’m talking about politics; all that stuff is Holy Writ.

Anyhow, I abashedly admit that I made the change simply so that I could implement the random quote you’ll see over there on the right of the page under the Search box. There. See it? Yeah. It’s random.

On the bright side, I can now make the blogrolls PHP-based as well, which means they won’t be dependent on the whims of your browser’s JavaScript implementation. Not that anybody’s complained but I’ve always felt a little shady about that.

Licensed to recreate

Perceptive souls will notice a Creative Commons license in the bottom of the left hand column. Or, if you’re reading the bare bones Population: One, it’s at the bottom of the page. I wound up choosing the very liberal Attribution license. This means that anyone can copy, distribute, or display these pages or works derived from these pages, as long as they give me credit. I doubt anyone will, mind you. This is pretty much just a philosophical statement.

I have noted that the entire site is under that license except where specifically noted otherwise. That’s because of this entry, which is licensed under the Open Game License. I think the Creative Commons licenses are generally superior to the OGL; the OGL includes several restrictions on material covered by the license, and also adds a complex and confusing Product Identity clause. I don’t expect to license anything further under the OGL, unless I have to because I’m deriving from something else licensed under the OGL.

I haven’t bothered adding the license to each individual archive page, because I don’t want to be cluttered. I may change my mind; if anyone happens to have thoughts on this, feel free to sing out.

Mirror mirror

Referrer log spam has to be the best kind of spam ever. For $1,000, they’ll add your URL as a referrer in the httpd logs of thousands of weblogs. (They’ve hit me twice.) Right now, the user agent is “Mastadonte Referrer Advertising”, which is pretty easy to filter out; I assume they’ll change that to something that doesn’t give away the game.

The great thing about this spam is that it’s so easy to nullify it. All we have to do is stop obsessively poring over our referrer logs. If we stop caring who links to us, we won’t ever be suckered into hitting one of their URLs. If we stop building those automated referrer display widgets then the spammers get less advertising.

(Yeah, I know, we shouldn’t have to constrain our behavior to avoid spam. It still amuses me that they’re taking advantage of our harmless narcisissm.)

Update: More on this here.

My feelings are valid too

I have happily validated my RSS feeds; sing hooray! Yeah, pretty geeky. Movable Type users should note that the instructions for fixing old Movable Type feeds assume that you want to replace your RSS .9x feed with an RSS 2.0 feed, which may or may not be the case — some aggregators will still choke on RSS 2.0 and there are no perl modules to handle RSS 2.0 feeds as far as I know. So you may want to proceed with a bit more caution there. If anyone wants to know how I fixed my .91 feed, drop me a comment.

Bridgebuilding

Now that my MT -> LJ bridge is finally working the way I want it to, I’ll take the time to do a little documentation.

The basic architecture is as follows. I have an MT template containing a verbose RSS .91 feed, which is an index template, so the page it produces is rebuilt every time I post. I added a CGI script residing on my server to the list of URLs to ping when my blog is updated. The CGI runs blagg (an RSS aggregator) with the LiveJournal plugin, which pushes the post to my LiveJournal.

Notes:

Blagg is not a very smart parser; it expects the RSS tags to come in a certain order. Specifically, it requires first <title>, then <link> then <description>. As it happens, this is not the order in which the default MT RSS .91 template presents the tags, so I had to modify a copy of the template to put things in an order blagg would understand. I also expanded the description field to contain the entire post, since I wanted people to be able to read the full entry without leaving the LJ page. Finally, I replaced encode_xml=”1” with encode_html=”1” throughout the template, since encode_xml encodes some characters in a way that most browsers won’t understand. Specifically, IE can’t make sense of &apos;.

My CGI script looks like this:

#!/usr/bin/perl -w
use strict;
use XMLRPC::Transport::HTTP;
my $server = XMLRPC::Transport::HTTP::CGI
-> dispatch_to('weblogUpdates')
-> handle
;
package weblogUpdates;
sub ping {
`/home/durrell/bin/pushlj.sh &`;
return "OK";
}

pushlj.sh is this:

#!/bin/sh
lockfile=/tmp/lj-bridge.lck
blagg=/home/durrell/bin/blagg
plugin=-plugin=livejournal
mode=-mode=automatic
login=-login=bryant
REQUEST_METHOD=
i=1
while [ $i -lt 5 ]; do
if [ ! -e $lockfile ]; then
touch $lockfile
$blagg $plugin $mode $login
rm $lockfile
i=5
else
sleep 60
i=$(( $i + 1 ))
fi
done

Why a separate script? Because in case I run into a lock, I don’t want the CGI to sit around waiting for the lock to vanish. Also, I intend to put a five minute delay in there to give me time to edit a bad post before it hits LJ.

Why the REQUEST_METHOD= bit? Because blagg processes its command line switches with CGI.pm. This is a very clever method of processing arbitrary switches in an elegant manner, but if REQUEST_METHOD is set, then CGI.pm won’t look for parameters on the command line. So I have to unset it somewhere. Getopt::Long really ought to have a method for processing arbitrary switches, but that’s a rant for another post.

Finally, since I’m using version 1.0 of the livejournal plugin, I had to edit the plugin a little to make it set the preformatted flag for posting. I also tweaked it a little to store the password in the plugin itself, since I don’t like the idea of exposing the password on the command line (and thus in the process table). Version 1.1 of the plugin allows you to specify preformatted mode with a command line switch, but I haven’t upgraded yet.