7 Apr 2010 yeupou   » (Master)

RSS feeds: HTML output with rawdog from akregator’s OPML

Akregator, a KDE RSS aggregator

RSS feeds are probably one of the most useful tools of nowaday’s internet. Obviously, it is not really complicated to find interesting pages over the web. It is way harder to keep up to date, however. These feeds fix that issue. I will not explain what RSS fields are but will focus on how I use them.

On my main workstation, with KDE, I use Akregator that aggregates all the feeds. It is nicely integrated in the enviroment: in Konqueror, with one click, I can add whatever RSS field is mentionned in the headers of a HTML page. After adding RSS fields, I can sort them by categories I defined.

Akregator's feeds in rawdog's HTML output

It happens from time to time that I want to access my RSS fields on another computer over the network or even with my laptop over the web. Here comes rawdog, a “RSS Aggregator Without Delusions Of Grandeur”. I picked it because it is easy to set up and lightweight (unlike TinyRSS etc). This aggregator is installed on my local network server and uses akregator list of feeds and produce a multicolumn HTML output that apache serves.

First, on my main workstation (on which one I use Akregator): I set up a cronjob that copies Akgregator’s feeds list to my user account on the server. Note that I use SSH with a key with no passphrase to do so.

/etc/cron.d/rawdog:

25 * * * * user if [ -e ~/.kde/share/apps/akregator/data/feeds.opml ]; then scp ~/.kde/share/apps/akregator/data/feeds.opml server:~/ 1> /dev/null ; fi

(It is nice that Akgregator use the OPML format and not a specific config file)

Next, on server side, on which one rawdog has been installed (nothing specific here, it is shipped by Debian), I created a rawdog user account then made a symlink from /home/rawdog to /var/www/rss.

We need first to provides rawdog with the Akregator’s OPML – it does not support it. To do this, I fetched a perl scripted made by Tero Karvinen that I edited so it support categories. It results in the following opml_to_rawdog.pl stored in /home/rawdog/scripts (/var/www/rawdog/scripts directory access over http being forbidden by Apache).

We set a cronjob to produce a feeds list that rawdog can handle, /etc/cron.d/rawdog:

# Make sure we have the latest feeds, imported from akregator
# if there is a user/feeds.opml, compare it with the current one
30 * * * * root cd /home/rawdog && if [ -e /home/user/feeds.opml ]; then if [ ! -e feeds.opml ] || [ "`diff /home/user/feeds.opml feeds.opml`" != "" ]; then scripts/opml_to_rawdog.pl /home/user/feeds.opml > feeds ; fi ; fi

I put a rawdog config file in /home/rawdog and I edited it to suit my needs. Most notably, I edited as follow /home/rawdog/config:

maxarticles 50
datetimeformat %d %B, %Hh%M
template templates/page
itemtemplate templates/item
outputfile index.html
showfeeds false

feeddefaults
killtags true
truncate 220

# this is the file generated by opml_to_rawdog.pl
include feeds

It relies on two templates pages stored in templates/ directory: templates/page and templates/item. Not surprisingly, the layout is based on a CSS file called style.css – you will have to edit it to match categories names. It also requires the truncate plugin, to be stored in the plugins directory.

The last step is to update /etc/cron.d/rawdog to actually generate the HTML output:

# Run every 9 minutes
*/9 * * * * rawdog cd ~/ && /usr/bin/rawdog -d ~/ -u -w 2>> errors

# once per month, clean up the errors list
10 2 2 * * rawdog rm -f ~/errors

That’s all folks (even if there is room for improvement)!


Syndicated 2010-04-07 22:37:54 from # cd /scratch

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!