From: Frank Lichtenheld Date: Tue, 28 Nov 2006 00:36:44 +0000 (+0000) Subject: Finally fix the new packages rss feed X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=e0996d1bc5a737ae3fbeb9d1598d106ad5496a6a;p=deb%2Fpackages.git Finally fix the new packages rss feed --- diff --git a/cgi-bin/dispatcher.pl b/cgi-bin/dispatcher.pl index e34f0e3..b72e443 100755 --- a/cgi-bin/dispatcher.pl +++ b/cgi-bin/dispatcher.pl @@ -271,7 +271,7 @@ $page_content{uri_escape} = sub { return URI::Escape::uri_escape(@_) }; $page_content{quotemeta} = sub { return quotemeta($_[0]) }; $page_content{string2id} = sub { return &Packages::CGI::string2id(@_) }; -print $input->header( -charset => $charset ); +print $input->header(-charset => $charset, -type => get_mime($opts{format}) ); #use Data::Dumper; #print '
'.Dumper(\%ENV, \%html_header, \%page_content, get_all_messages()).'
'; diff --git a/lib/Packages/CGI.pm b/lib/Packages/CGI.pm index b092352..34d7a5f 100644 --- a/lib/Packages/CGI.pm +++ b/lib/Packages/CGI.pm @@ -7,15 +7,25 @@ use Exporter; use Packages::Config; our @ISA = qw( Exporter ); -our @EXPORT = qw( DEBUG debug fatal_error ); +our @EXPORT = qw( DEBUG debug fatal_error get_mime ); our @EXPORT_OK = qw( error hint msg note get_all_messages make_url make_search_url ); - # define this to 0 in production mode use constant DEBUG => 1; our $debug = 0; +my %mime_types = ( + txt => 'text/plain', + 'txt.gz' => 'text/plain', + html => 'text/html', + rss => 'application/rss+xml', + ); + +sub get_mime { + return $mime_types{$_[0]} || $_[1] || 'text/html'; +} + our (@fatal_errors, @errors, @debug, @msgs, @hints, @notes); sub reset { diff --git a/lib/Packages/DoIndex.pm b/lib/Packages/DoIndex.pm index 0ed874a..239f330 100644 --- a/lib/Packages/DoIndex.pm +++ b/lib/Packages/DoIndex.pm @@ -21,12 +21,6 @@ sub do_allpackages { return send_file( 'allpackages', @_ ); } -# no real need for more flexibility here, I think... -my %mime_types = ( - txt => 'text/plain', - 'txt.gz' => 'text/plain', - html => 'text/html', - ); my %encoding = ( 'txt.gz' => 'x-gzip', ); @@ -59,7 +53,7 @@ sub send_file { if (open( INDEX, '<', "$wwwdir/$path" )) { my %headers; $headers{'-charset'} = get_charset( $opts->{lang} ); - $headers{'-type'} = $mime_types{$opts->{format}} || 'text/plain'; + $headers{'-type'} = get_mime( $opts->{format}, 'text/plain' ); $headers{'-content-encoding'} = $encoding{$opts->{format}} if exists $encoding{$opts->{format}}; print header( %headers ); diff --git a/lib/Packages/DoNewPkg.pm b/lib/Packages/DoNewPkg.pm index 7ee921a..362c426 100644 --- a/lib/Packages/DoNewPkg.pm +++ b/lib/Packages/DoNewPkg.pm @@ -56,10 +56,8 @@ sub do_newpkg { close NEWPKG; (my @date)= gmtime(); - my $now_time = strftime ("%B %d, %Y", @date); - my $rss_time = strftime ("%Y-%m-%dT%H:%M+00:00", @date); - - $page_content->{make_url} = sub { return &Packages::CGI::make_url(@_) }; + #FIXME: compute in the template + $page_content->{rss_timestamp} = strftime ("%Y-%m-%dT%H:%M+00:00", @date); if (@new_pkgs) { $page_content->{new_packages} = [ sort { &$sort_func($a,$b) } @new_pkgs ]; @@ -70,49 +68,6 @@ sub do_newpkg { $page_content->{archive} = $one_archive if $one_archive; $page_content->{sections} = \@SECTIONS; -# my @full_path = ($HOSTNAME, $ROOT, $suite); -# push @full_path, $one_archive if $one_archive; -# my $full_path = join( '/', @full_path ); - -# } else { # unless ($opts->{format} eq 'rss') -# my ( $rss_link, $rss_description, $rss_date ); - -# $rss_description = sprintf(_g( "The following packages were added to suite %s%s in the Debian archive during the last 7 days."), $suite, -# $one_section ? sprintf(_g(" (section %s)"),$one_section):''); - -# my $rss = new XML::RSS (version => '1.0'); -# $rss_link = "$full_path".($one_section?"$one_section/":'')."/newpkg?format=rss"; -# $rss->channel( -# title => _g("New Debian Packages"), -# link => $rss_link, -# description => $rss_description, -# dc => { -# date => $rss_time, -# publisher => 'debian-www@lists.debian.org', -# rights => 'Copyright '.($date[5]+1900).', SPI Inc.', -# language => $opts->{lang}, -# }, -# syn => { -# updatePeriod => "daily", -# updateFrequency => "2", -# # updateBase => "1901-01-01T00:00+00:00", -# } ); - -# foreach my $pkg (sort { &$sort_func($a,$b) } @new_pkgs) { -# $rss->add_item( -# title => $pkg->[0], -# link => "$full_path/$pkg->[0]", -# description => $pkg->[-1], -# dc => { -# subject => $pkg->[6], -# } ); -# } -# my $charset = get_charset( $opts->{lang} ); -# print &CGI::header( -type => 'application/rss+xml', -# -charset => $charset ); -# print $rss->as_string; -# exit; -# } } 1; diff --git a/templates/rss/foot.tmpl b/templates/rss/foot.tmpl new file mode 100644 index 0000000..e69de29 diff --git a/templates/rss/newpkg.tmpl b/templates/rss/newpkg.tmpl new file mode 100644 index 0000000..476202d --- /dev/null +++ b/templates/rss/newpkg.tmpl @@ -0,0 +1,47 @@ + + + + +[%- root_url = "$packages_homepage$suite/"; + SET root_url = "$root_url$section/" IF section -%] + + +New [% organisation %] Packages +[% root_url %]newpkg +Packages that were added to the [% suite %] [% organisation %] archive [% " (section \"$section\")" IF section %] during the last 7 days. +en +Copyright [% timestamp.year %], [% copyright.name %] +[% rss_timestamp %] +[% contact.mail %] +weekly +2 +[% FOREACH pkg IN new_packages %] + [%- IF loop.first %] + + + [% END -%] + + [% IF loop.last -%] + + + [% END -%] +[% END -%] + + +[%- FOREACH pkg IN new_packages %] + +[% pkg.0 %] +[% root_url _ pkg.0 %] +[% pkg.-1 %] +[% pkg.6 %] + +[% END -%] + +