]> git.deb.at Git - deb/packages.git/commitdiff
Finally fix the new packages rss feed
authorFrank Lichtenheld <frank@lichtenheld.de>
Tue, 28 Nov 2006 00:36:44 +0000 (00:36 +0000)
committerFrank Lichtenheld <frank@lichtenheld.de>
Tue, 28 Nov 2006 00:36:44 +0000 (00:36 +0000)
cgi-bin/dispatcher.pl
lib/Packages/CGI.pm
lib/Packages/DoIndex.pm
lib/Packages/DoNewPkg.pm
templates/rss/foot.tmpl [new file with mode: 0644]
templates/rss/newpkg.tmpl [new file with mode: 0644]

index e34f0e39824b214c0b626d2b278f9fb45931a2c0..b72e443615e5b0e8e2ad1cfe61f3048122f75ed2 100755 (executable)
@@ -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 '<pre>'.Dumper(\%ENV, \%html_header, \%page_content, get_all_messages()).'</pre>';
index b09235273ab4d9e057321f2a9c494287bdf89e09..34d7a5f341636414d0175e089561fd241c9c5823 100644 (file)
@@ -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 {
index 0ed874a24ce31a4dcf5865a3036c0cd25330fe58..239f3301a7af582f8faf1478483224fdb63548d8 100644 (file)
@@ -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 );
 
index 7ee921a3975ee6c14f689d0ccd10dfbca029177a..362c4260dd5cb66e122f531e405368f0e1ed6729 100644 (file)
@@ -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 (file)
index 0000000..e69de29
diff --git a/templates/rss/newpkg.tmpl b/templates/rss/newpkg.tmpl
new file mode 100644 (file)
index 0000000..476202d
--- /dev/null
@@ -0,0 +1,47 @@
+<?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>