Jeffrey Veen

Publishing Links With Perl

In the continuing saga of publishing my del.icio.us links, I've taken a turn towards Perl. For those of you following along, I started by pointing Feedroll at the auto-generated RSS, then used a Javascript include to show them here. That was cool, but I decided Jason was probably on to something by publishing to them in-line. So I took a stab at XSLT, transforming the output of the del.icio.us API into XHTML, then inserting that into MT. That worked ok, too, and you can see the Perl script I used here, along with the XSLT stylesheet here. But it felt convoluted. Too many dependencies. This talks to that which parses this into that, etc.

While I like XSLT a lot, I found that by using the Perl XPath module, the script almost wrote itself. Anyone familiar with URLs will pick up XPath in an instant. You just enter the path of /the/tag/you/want/, ask for either the text() inside the tag or one of its @attribute, then stuff it in a variable. Easy! So here is the script I'm using now. It pulls the XML over (now with verification that links were posted), turns it into XHTML, then sticks it into MovableType and rebuilds the site. You could easily just chop off the MT stuff at the end and just write it to a file, as well. Bear in mind that this represents about twice as much Perl as I've ever written before. But it seems to work. Comments please.


This entry was written by Jeffrey Veen and posted 12 December 2003 at 11:58 AM. It was filed under Technology.

Comments
1. On 12 December 2003 at 12:17 PM Nate wrote:

I was just about to implement your javascript solution, this looks even better. Quick question that will probably reveal a deep seated ignorance of the technologies used: do you simply have a chron task to trigger the script every N hours?

2. On 12 December 2003 at 12:30 PM jeff wrote:

Oh, right. I forgot to mention that part. Yeah, you can use a cron job to publish them once a day. I've just been calling the script from the command line so far.

3. On 12 December 2003 at 10:10 PM joshua wrote:

i'm probably going to add a way to have del.icio.us post your links to your blog once a day via XML-RPC, as well as html-formatted output.

4. On 15 December 2003 at 12:38 PM Steven Hatch wrote:

Joshua -- Keep us posted on the XML-RPC posting bridge! It sounds perfect! In the meantime, I think I may use Jeff's neat little Perl Hack.

Jeff -- BTW, thanks for all the 'del.icio.us' tips :-)

-s

5. On 2 January 2004 at 11:03 PM Matthew Trentacoste wrote:

Came across your script and have started using it. Very nice. I made a couple modifications to it.

1) Allowing you to assign a category to the post generated.
2) Setting a default value for allow_comments because Moveable Type seems to generate a slew of errors regarding uninitialized values for each post when rebuilding.

If you are interested in either of these, let me know and I will send you my changes to the script.

6. On 10 January 2004 at 7:02 PM Matthew Trentacoste wrote:

At least one person has asked for my modifications w.r.t. assigning a category to link posts. The info on how to modify your script along with my version can be found here.

7. On 10 January 2004 at 7:03 PM Matthew Trentacoste wrote:

Oops, should have assumed you stripped HTML code. The link is:

http://squarewithin.com/2004/01/10_veen_script_modifications

8. On 12 January 2004 at 1:13 AM bingo wrote:

your script is very nice i have worked with it

Currently:

() More...

About Me

Bio: Jeffrey Veen
Book: "The Art & Science of Web Design"
Book: "HotWired Style: Principles For Building Smart Web Sites"
Work: My LinkedIn Profile
Travel: China, Tuscany, Kayaking in Baja, Touring Costa Rica, Studying Theater in London

Popular Posts

» Making a Better Open Source CMS
» Seven Steps to Better Presentations
» A Contrast in Urban Design
» IA Jargon Watch
» On Writing Short
» Pain and Cycling

Recent Photos


XML Feeds

This XML Button links to a feed you can subscribe to. Subscribe to my site
Click the link above to be notified automatically every time I add a new post.

Creative Commons License