#!/usr/bin/perl use strict; use warnings; use HTTP::Date qw( str2time time2isoz ); use CGI qw( feed icon author name link id entry content updated ); use open IN => ':encoding(ISO-8859-1)', OUT => ':encoding(UTF-8)', ':std'; sub CHANGELOG_URL() { 'http://slackware.osuosl.org/slackware-current/ChangeLog.txt' } sub time2rfc3339 { local $_ = time2isoz shift; tr/ /T/; $_ } if( @ARGV == 1 and $ARGV[ 0 ] eq '--url' ) { print CHANGELOG_URL; exit; } my @entry = split /\n\+----+\+\n/, do { local $/; local $_ = <>; utf8::upgrade( $_ ); $_; }; my $q = CGI->new( '' ); print( $q->start_feed( { xmlns => 'http://www.w3.org/2005/Atom' } ), "\n", $q->id( 'urn:uuid:6195b930-844b-11da-9fcb-dd680b0526e0' ), "\n", $q->title( 'Slackware-current ChangeLog' ), "\n", $q->icon( 'http://www.slackware.com/favicon.ico' ), "\n", $q->author( $q->name( 'Patrick Volkerding' ) ), "\n", $q->link( { type => 'text/plain', href => CHANGELOG_URL, } ), "\n", $q->updated( time2rfc3339 time ), "\n", ); for( @entry ) { m{ \A ( [^\n]+ ) \n* ( .* ) }msx or next; my $time = str2time $1; # needs Time::Zone!! my $text = $q->escapeHTML( $2 ); 1 while chomp $text; print( $q->start_entry(), $q->id( 'tag:plasmasturm.org,2005:Scraped-Feed:Slackware-ChangeLog:' . $time ), $q->title( $1 ), "\n", $q->content( { type => 'xhtml' }, $q->div( { xmlns => 'http://www.w3.org/1999/xhtml' }, $q->pre( $text ), ), ), "\n", $q->updated( time2rfc3339 $time ), $q->end_entry(), "\n", ); } print $q->end_feed;