Automatic redirection for del.icio.us 10th of August, 2006 POST·MERIDIEM 02:16
If you, like me, have often thought to yourself “bah, loading del.icio.us and clicking on the first link for a given tag combination is taking six seconds longer and 150% more attention than I’d like”, you’ll have realised that setting up automatic 302 redirection is not really an option for them, since automatic redirectors have become a tool for spammers to disguise dodgy URIs, and the service has open signups; there’s nothing to stop spammers abusing their accounts.
However, it is not trivially possible for a spammer to abuse my del.icio.us account: that’s what the password is there for. So I’ve implemented automatic redirection based on tags for a single account, reading the data from an index made of a daily backup. http://www.parhasard.net/b/dwb will redirect to the newest entry under del.icio.us/aidan with the tag DWB(in this case, the search page of the Grimms’ etymological dictionary at Universität Trier; note that in this implementation, ASCII in tags is case-insensitive, non-ASCII is case-sensitive); http://www.parhasard.net/b/greek+language+καθαρεύουσα gives a synopsis of the current language situation in Greece, and so on.
To do this for your own del.icio.us account, you need shell access to a web server, several Perl modules, and DB4 support in PHP. To check for the Perl modules on the server, run this one-liner from a shell:
If it completes without an error, you’re good. To check for the DB4 support, run this from a shell:
perl -e 'use DB_File; use Date::Parse; use Encode; use File::Temp; use HTTP::Request; use LWP::UserAgent; use XML::Parser'
Again, it needs to complete without an error for the scripts to work.
echo '<?php dba_open("/tmp/my-db-test", "c", "db4"); ?>' | php
Source code for the backup script (which you need to create the index of tag
=> URI mappings) is here; source code for the
redirect script is here. There are a
few constants at the top of each file which you’ll need to modify; those
with the same name need to be identical in the two files. You’ll also need
to add a
crontab(5) entry to keep the backup up-to-date; mine
and runs at 23 minutes past five every morning.
23 5 * cd /www/parhasard.net/www/ && ./backup-del.icio.us.pl
If your web server allows it, try adding the line
On to your
.htaccess; without it, you’ll need to say
http://server-address/b.php?query=tag1+tag2+tag3 , which is much less
Word of the day: inminente is Spanish for “imminent”; I love that the language community is scrupulously regularising enough that they abandoned the Latin orthographic change of <inm> -> <imm>.
Comments are currently disabled.