Flödesfestival 2009

En uppdatering av det här gamla inlägget

Om du inte får nog av mig finns det nu fem ytterligare sätt, förutom den här bloggen, att följa mina förehavanden.

Allt utom de två sistnämnda finns i högerspalten här på bloggen, men som de moderna och intelligenta människor ni är använder ni förstås RSS/Atom-flödena i första hand.

Mikroformatsfestival

Jag har länge varit sugen på att göra något smart med mikroformat. Jag håller för närvarande på att göra om IRIs webbplats, och där har vi en hel del uppgifter som lämpar sig för mikroformatsuppmärkning — kontaktuppgifter (hCard), kalendarium (hCalendar) och nyheter (hAtom), till exempel.

Ett designmål med IRIs webplats är att det ska vara statiska sidor — vi har inget CMS och min efterträdare måste kunna underhålla webplatsen i frontpage eller notepad. Det gör att traditionella metoder för att skapa RSS/Atom-flöden och iCalendar-feeds inte riktigt funkar. Ingenting ligger i en databas från vilken vi kan dra ut samma innehåll i flera olika versioner.

Men om de statiska sidorna är mikroformatsuppmärkta skulle jag kunna skriva ett script som tar en HTML-sida med hCalendar-data och spottar ut en iCalendar-feed, klar att inkludera i Apple iCal eller Google Calendar. Samma med nyhetssidan och valfri flödesläsare.

Det stora problemet är bara att göra det i den tekniska miljö vi har — classic ASP. Att parsa HTML med strängoperationer i VBscript känns inte så upphetsande, så helst vill jag använda mshtml. Tyvärr hittar jag ingen dokumentation om hur man kan använda MSHTML från Activescripting-världen med allt vad det innebär av Dispatchinterface och sen bindning — jag hittar inte ens rätt CLSID. doc = CreateObject("mshtml.HTMLDocument2") funkar inte, iallafall. Det finns en hel del dokumentation om hur man gör det utifrån en webbrowser control, men ett sådant objekt verkar inte gå att instansiera från serversidan. Hmm. Vid närmare efterforskningar verkar mshtml inte supportas på serversidan överhuvudtaget.

Kanske att jag ska fixa det med ett pythonscript på min egen server som använder Almost Universal Microformats Parser istället, bara för att få något som funkar?

Flödesfestival

Om du läser den här bloggen via websidan (istället för via en rss/flödesläsare) har du kanske sett att det dykt upp lite bilder på högersidan – det är från min fotoströmflickr, till vilken jag skickar bilder via min telefon när jag behöver ett avbrott i studierna, eller i övrigt hittar något värt att bevara till omvärlden. För er som inte kan få nog av mig kan ni följa utvecklingen LIVE genom att antingen, om ni själva använder flickr, lägga till mig som kontakt, eller prenumera direkt på RSS-flödet.

Och du har väl inte missat att allt jag bokmärkerdel.icio.us också, med fördel, kan upplevas LIVE genom flöde, snarare än ihopklumpat på söndagkvällarna?

Bra bloggar, dåliga flöden

Jag läser mycket bloggar och andra nyhetskällor, och skulle knappast klara av nyhetsflödet utan en RSS-läsare. Tyvärr har många av mina favoritsajter dåliga RSS/Atom-flöden. Den här osorterade samlingen gnäll kan ses som en guide till hur man inte ska designa sitt flöde. Den kan eventuellt också ses som en rekommendation av några riktigt bra sajter, eftersom jag fortsätter läsa dem trots deras dåliga flöden.

Groklaw
Groklaw skriver nästan alltid riktigt långa postningar med mycket citerat material, vilket indikeras genom indentering. Den här informationen strippas dock bort i det plaintext-material som finns i RSS-flödet, så texten blir ibland obegriplig. Men det större problemet är att även om flödet innehåller generöst mycket text så är det inte ett fulltext-flöde, och det finns ingen indikation på att texten som finns i flödet inte är den fullständiga artikeln. Dessutom klipps texten vid en styckesgräns, så det är väldigt lätt att tro att man har en fullständig, om än rumphuggen, text i sin RSS-läsare — att lägga på ett avslutande ”[…]” hade hjälpt. Fast bättre hade förstås varit att ha ett fulltextflöde.
The Importance Of (liksom alla andra Corante-bloggar)
Det här är ett snuttifierat flöde med precis så mycket text så att jag nätt och jämt kan ta ett underbyggt beslut om huruvida det är värt att att öppna fulltextpostningen i min webläsare. Eftersom det oftast är bra kvalité på texterna är det oftast det, men varje gång blir jag irriterad eftersom corante.com laddar så långsamt — det kan ta mer än 15 sekunder innan själva artikeltexten är synlig. Det här förvärras av två saker: Dels är HTML-koden strukturerad så att artikeltexten kommer sist i HTML-filen, trots att den CSS-struktur de använder sig av skulle låta dem ladda texten först och navigationsmenyerna till höger och vänster sist (som på den här sajten). Dels laddar sidan bilder och javascript-kod från fånigt många andra servrar (amazon.com, mediaplex.com, yimg.com, bloglines.com,
technorati.com, creativecommons.org, sitemeter.com) — och alla bildreferenser saknar width/height-information, vilket gör att bilderna (och scripten?) måste laddas från de andra servrarna innan sidan kan visas fullt ut.
Lessig Blog
Eftersom Lawrence Lessig ofta har gästbloggare vore det toppen om <author>-elementet i RSS användes för att indikera vem som faktiskt postade, eftersom detta inte framgår från texten i flödet. Det syns däremot på websajten, så uppenbarligen finns informationen i publiceringssystemet.
Notes from the (Legal) underground
DÄR VARENDA MENING BÖRJAR på det här viset. Vilket ser snyggt ut på sidan, men när tio titelrubriker staplas på varandra i min RSS-läsare får jag bara ont i huvudet.
The Becker-Posner Blog
Den här bloggen är på formatet att antingen Posner eller Becker postar en längre artikel om ett ämne, följt av den andres replik. Postningarna görs inom en timme av varandra, och på websidan kommer de i en logisk ordning, men eftersom min RSS-läsare listar saker i äldst-till-yngst-ordning får jag alltid läsa repliken innan huvudartikeln, vilket är irriterande. En annan sak jag ogillar är sättet som Gary Becker envisas med att lägga till sitt efternamn i versaler i titeln, typ: ”Chinese Ownership of American Companies: A Problem? BECKER”. Informationen om vem som skrev artikeln borde vara skiljd från titeln.
LawMeme
Bara ett <link>-element, ingen beskrivning. Det här gör att min RSS-läsare försöker hämta informationen precis när jag ska till att läsa, istället för i förväg, vilket är irriterande långsamt. Layouten på sidan är dessutom dåligt anpassad för att läsas inuti en RSS-läsare, eftersom den är alldeles för bred.

Märkligt nog är alla bloggar jag irriterar mig på juristrelaterade — rena teknikbloggar sköter sig i allmänhet mycket bättre (även om det fortfarande är vanligt med snuttifierade flöden). Vilket inte är så konstigt, eftersom tekniker är snabbare på att ta till sig fördelarna med att använda en separat RSS-läsare.

Min tagline till trots har det inte varit mycket punkrock, eller musik öht, på den här bloggen det senaste året. Bot och bättring imorgon!

Part 8: Finishing touches

(The last in a series of blog posts about the tech behind lagen.nu. The other parts are here: first, second, third, fourth, fifth, sixth and seventh)

URL design: Insired both by ”Cool URIs don’t
change”
and the general REST
emphasis
on sensible URL design, I designed a URL scheme for
lagen.nu that maps closely to how swedish laws are identified, and
one that is future-proof in that it hides implementation
details. Since I hope that many people will find it useful to link
to individual pages on lagen.nu, it’s very important that those
links doesn’t break.

To illustrate: the generated html files are placed in directories
named html/year/id.html. Suppose that I
just were to let Apache (or any other webserver) serve content straight
from that directory. For example, the copyright law has SFS id
1960:729, and so with this scheme the URL would be
http://lagen.nu/html/1960/729.html (or
http://lagen.nu/1960/729.html, depending on what I would
set DocumentRoot to). This would work fine, the URL’s would be
easy to understand, and people would link to all those individual pages from
all over the web.

But now suppose I wake up one day and decide to stick all data in a big
database, and build a PHP frontend? The URL’s would change, and probably be
on the form
http://lagen.nu/showlaw.php?sfs=1960:729. Again, nice
short URL, easy to understand… but now the links from all over
are broken.

So, mod_rewrite
to the rescue: With just the simple rule:

    RewriteRule ([^:]*):(.*) /html/$1/$2.html
  

, the resource found at URL
http://lagen.nu/html/1960/729.html is now also available
at http://lagen.nu/1960:729. This is even nicer to read,
futureproof, and enables someone that knows the ID of any law to
go straight to the page for that law quickly.

As a added bonus, it makes the text and XML version of the laws
easily available too: During generation, I put these versions in
sibling directories to html/, named text/ and
xml/, respectively, and then use the following rules:

    RewriteRule ([^:]*):(.*).xml	/xml/$1/$2.xml
    RewriteRule ([^:]*):(.*).txt	/text/$1/$2.txt
  

There are other parts, such as the index pages and the about
pages, where the underlying flat-file nature of the site shines
through, such as http://lagen.nu/om/me.html, but those
pages are not as likely to be linked to. Still, if I should decide
to change it at some point, I’ll probably make some mod_rewrite
based backwards compatibility hack. Also, if you want to do this
on a Win32 platform, you’re out of luck. See my previous
post
for alternatives.

Update functionality: As the body of swedish law is always
changing, I had to plan ahead of how to keep the site up to
date. New laws are usually published every Wednesday, and it’s out
of the question to download every page from Regeringskansliets rättsdatabaser
once a week. So instead, I store the highest previously-fetched
ID, and from the update routine, I try fetching laws, increasing
that ID, until I finally get a ”law not found” error. The laws can
be either ”base constitutions”, i.e. new laws, or ”change
constitutions”, laws that specify that some other, older, law
should change (think ”source code file” and ”patch”,
respectively).

If it’s a base constituion it’s pretty simple, just
download it and process it from start to finish. If it’s a change
constitution, however, we find out wich base constitution it
changes, fetch that, see if it has been updated (”patched”), and
if so, store the old versions of that law somewhere, then do the
normal regeneration process. In this way, I can, over time, build
up an archive of old law revisions, so that I can tell how the law
looked at a particular date. For now, I have only a few months
worth of history, but the value of this will grow as the time goes
on. In particular, it would be cool to be able to do CVS-style
diffs between arbitrary revisions of a law, or to be able to link
to a law as it looked at a particular moment of time.

Front page: With the information we gather during the
update process, we can build a list of recently changed laws, and
put it on the front page. Similarly, we build a list of recent new
court verdicts, and also one with site news. All these are
published in a side bar on the front page, while the main content
area is filled with a static listing of some of the most important
laws. The different parts of the side bar leads to different news
pages, which details site, law and verdict news in greater detail.

RSS feeds: Hey, it’s 2004, how could any self-respecting
new site not have a RSS feed? I generate feeds for all three news
types (site, law and verdict) using PyRSS2Gen,
a nice little lib for creating RSS 2.0 feeds. I haven’t tried them
out much, but feedvalidator says they’re OK, and they work fine in
all RSS readers I’ve tested with (although Opera tends to show the
raw HTML instead of rendering it, which probably indicates that I
should include it in some other way than just escaping it and
showing it in the description tag. Maybe it would be
useful to use a service like Feedburner for
this.

Conclusion: This marks the end of this eight-part posting. I
hope that you’ve picked up a trick or two. As should be apparent,
I am no python wizard or even a programming guru in general, but
over the years I’ve found a style of development that works for me
in a single-developer context (doing multiple-developer projects
is a totally different thing), mostly centered around the XP tenet
”Do the simplest thing that could possibly work”, or in my own
words: ”Don’t try to find the right way of doing something — if
you just work away, the right way will find you”.

Most music sites do not suck (anymore)

Almost a year ago, I ranted about how few
music sites have adopted RSS
. Well, yesterday I got a mail from Kal at dagensskiva.com, telling me that they have a multitude of RSS feeds now. Cool!

And they’re not alone. Out of my list of six favourite music sites, all but one now has RSS feeds:

While I’m at it, let me plug three other music sites that I read:

2004 has indeed been the year of RSS. Why, we now even have uninformed
opionion pieces
against it, can a mass market breakthrough be far
away?

Quickies of the day

Lately, I’ve only been blogging about what’s going on in my
world. Time to go through the last few days of blog postings that I
found interesting for one reason or another:

  • pHatidic writes
    about
    the fact that Wikipedia does work, despite all the
    theoretical arguments detailing why it cannot. It’s like the
    bumblebee
    , which by the law of physics cannot fly (well, actually
    of
    course they can
    ), but since the bumblebees have never taken even
    remedial physics, they are blissfully unaware of this fact.
  • At first, I thought Microsoft was patenting
    su
    . After further examination, it’s not as bad as it
    looks. Still, if you subscribe to the newly
    granted Microsoft patents RSS feed
    , you’ll get several examples each week
    of why software patentability is not a good idea.
  • Spamamusment continues
    to churn out brilliant
    spam-inspired comics
    .
  • A new beta of the next-generation
    windows shell (Monad)
    is out. I no longer have MSDN beta access,
    but I’m really looking forward to trying this out when it becomes more
    widely available. I just hope they focus as much on the accompanying
    programs as the core shell technology. If one has do download
    Monad-compliant utilities from all over the place, much of the value
    of the shell will be lost. I’m looking forward to see how the
    functionality of tools like sed and awk could be expressed in a .Net
    object environment.
  • Raymond is shocked to find out that Swedes are mis-using the right
    to sick leave
    . ”Everyone” has known that the sick-leave system is
    widely abused, but this is the maybe the first time that the
    politicans in charge admit it. But I’m mainly linking to this since
    I, like most Swedes, am deeply curious about how this country looks
    through the eyes of someone outside of it.
  • Scoble continues
    to act as the Kibo of the
    blogosphere. This post is yet another cheap attempt to get mentioned
    on his blog.
  • This story about scientific experiments with swimming in syrup has
    been seen everywhere today, but I first read it in jwz’s
    livejournal
    , as usual.
  • Cedric’s talking about his
    experiences after 6+ months of working with JDK 5.0. Interesting
    stuff.
  • Edward W. Felten has an interesting
    take
    on the recent story about online-poker-playing
    bots
    . ”There’s a sucker at every poker table, and if you can’t see
    him, it’s probably you”

And some links to interesting swedish blog posts. If you’re not a
swedish speaker, take a page from Raymond
Chen’s book
🙂

  • My friend and colleguage Erik has published his report on
    the state
    of the web security
    of swedish political parties. It has sparked
    some
    debate
    , and Erik has also published a follow-up
    article
    detailing why it’s important to fix security problems,
    even if they can’t be exploited right away.
  • Karl Jonsson writes about
    the latest controversy involving swedish bittorent site The Pirate Bay. The TPB guys
    come off more immature than ever in their email exchange with
    Uppsala Universitet. Those advocating stronger copyright protection
    must love TPB, since they provide so many examples of how
    irresponsible the filesharing community can behave.
  • Niklas Lundblad is holding a lecture about information security
    and philosophy, and has put up his slides with
    comments. Certainly a unique perspective on security, I would have
    loved to attend the lectures.