$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 '<pre>'.Dumper(\%ENV, \%html_header, \%page_content, get_all_messages()).'</pre>';
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 {
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',
);
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 );
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 ];
$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;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<rdf:RDF
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns="http://purl.org/rss/1.0/"
+ xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
+ xmlns:admin="http://webns.net/mvcb/"
+>
+
+[%- root_url = "$packages_homepage$suite/";
+ SET root_url = "$root_url$section/" IF section -%]
+
+<channel rdf:about="[% root_url %]newpkg">
+<title>New [% organisation %] Packages</title>
+<link>[% root_url %]newpkg</link>
+<description>Packages that were added to the [% suite %] [% organisation %] archive [% " (section \"$section\")" IF section %] during the last 7 days.</description>
+<dc:language>en</dc:language>
+<dc:rights>Copyright [% timestamp.year %], [% copyright.name %]</dc:rights>
+<dc:date>[% rss_timestamp %]</dc:date>
+<dc:publisher>[% contact.mail %]</dc:publisher>
+<syn:updatePeriod>weekly</syn:updatePeriod>
+<syn:updateFrequency>2</syn:updateFrequency>
+[% FOREACH pkg IN new_packages %]
+ [%- IF loop.first %]
+ <items>
+ <rdf:Seq>
+ [% END -%]
+<rdf:li rdf:resource="[% root_url _ pkg.0 %]" />
+ [% IF loop.last -%]
+ </rdf:Seq>
+ </items>
+ [% END -%]
+[% END -%]
+</channel>
+
+[%- FOREACH pkg IN new_packages %]
+<item rdf:about="[% root_url _ pkg.0 %]">
+<title>[% pkg.0 %]</title>
+<link>[% root_url _ pkg.0 %]</link>
+<description>[% pkg.-1 %]</description>
+<dc:subject>[% pkg.6 %]</dc:subject>
+</item>
+[% END -%]
+
+</rdf:RDF>