From 610b0fb31c728d991e0f909d2cfee092c2553094 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Wed, 2 Oct 2013 16:37:02 +0200 Subject: [PATCH] Implemented per-project feeds for ncdu, ncdc, globster and tuwf --- index.cgi | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/index.cgi b/index.cgi index a478d84..9659139 100755 --- a/index.cgi +++ b/index.cgi @@ -75,6 +75,9 @@ my @changes = ( [ '2009-04-30', undef, 'Site redesign and reorganisation.' ], ); +my %feeds = map +($_,1), qw|ncdc ncdu globster tuwf|; +my $feedreg = join '|', keys %feeds; + TUWF::register( qr{} => sub { podpage(shift, 'home', '', '', "Yorhel's Projects") }, @@ -108,8 +111,8 @@ TUWF::register( qr{dump/grenamr} => sub { podpage(shift, 'dump-grenamr', 'dump', 'grenamr', 'GTK+ Mass File Renamer') }, qr{dump/nccolour} => sub { podpage(shift, 'dump-nccolour', 'dump', 'nccolour', 'Colours in NCurses') }, qr{dump/insbench} => sub { podpage(shift, 'dump-insbench', 'dump', 'insbench', 'Insertion Performance Benchmarks') }, - qr{feed\.atom} => \&atom, - qr{(ncdc|ncdu|globster)/bug} => \&bug_list, + qr{(?:($feedreg)/)?feed\.atom} => \&atom, + qr{(ncdc|ncdu|globster)/bug} => \&bug_list, qr{(ncdc|ncdu|globster)/bug/post} => \&bug_post, qr{(ncdc|ncdu|globster)/bug/new} => \&bug_new, qr{(ncdc|ncdu|globster)/bug/([1-9][0-9]*)} => \&bug_item, @@ -178,12 +181,13 @@ sub tuwfmanual { sub atom { my $s = shift; + my $sub = shift; my $t = (stat("$ROOT/index.cgi"))[9]; $s->resHeader('Last-Modified' => strftime '%a, %d %b %Y %H:%M:%S GMT', gmtime $t); $s->resHeader('Content-Type' => 'application/atom+xml'); xml; tag feed => xmlns => 'http://www.w3.org/2005/Atom', 'xml:lang' => 'en', 'xml:base' => 'http://dev.yorhel.nl/'; - tag title => "Yorhel's Projects"; + tag title => $sub ? "\u$sub Project Announcements" : "Yorhel's Projects"; tag updated => strftime('%Y-%m-%dT%H:%M:%SZ', gmtime $t); tag id => "http://dev.yorhel.nl/feed.atom"; tag link => rel => 'self', type => 'application/atom+xml', href => "http://dev.yorhel.nl/feed.atom", undef; @@ -191,6 +195,7 @@ sub atom { my $n = 0; for(@changes) { + next if $sub && $_->[1] !~ /^\/\Q$sub/; last if $n++ >= 10; tag 'entry'; tag id => 'http://dev.yorhel.nl'.($_->[1]||'/').'#'.$_->[0]; @@ -424,7 +429,7 @@ sub htmlHeader { html; head; Link rel => 'stylesheet', href => '/style.css', type => 'text/css', media => 'all'; - Link rel => 'alternate', type => 'application/atom+xml', href => '/feed.atom', title => 'Site updates'; + Link rel => 'alternate', type => 'application/atom+xml', href => ($feeds{$o{page}||''} ? "/$o{page}" : '').'/feed.atom', title => 'Site updates'; title $o{title}; end; body;