[Cpan-forum-commit] rev 218 - in trunk: . lib/CPAN lib/CPAN/Forum/RM www/img

svn at pti.co.il svn at pti.co.il
Thu Aug 31 11:48:44 IDT 2006


Author: gabor
Date: 2006-08-31 11:48:43 +0300 (Thu, 31 Aug 2006)
New Revision: 218

Added:
   trunk/www/img/atom.gif
Modified:
   trunk/
   trunk/Build.PL
   trunk/lib/CPAN/Forum.pm
   trunk/lib/CPAN/Forum/RM/Notify.pm
Log:
Add atom feed



Property changes on: trunk
___________________________________________________________________
Name: svk:merge
   - 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11100
   + 8c4c90e1-83eb-0310-96eb-e7cb62807872:/local/cpan-forum:11101

Modified: trunk/Build.PL
===================================================================
--- trunk/Build.PL	2006-08-31 08:48:35 UTC (rev 217)
+++ trunk/Build.PL	2006-08-31 08:48:43 UTC (rev 218)
@@ -34,6 +34,7 @@
         'Parse::CPAN::Packages'                 => '2.26',  # for populating and maybe also later ?
         'LWP::Simple'                           => 0,  # for populate
         'XML::RSS::SimpleGen'                   => 0,  # for, well RSS generation
+        'XML::Atom::SimpleFeed'                 => 0,
         'Mail::Sendmail'                        => 0,  
         'CGI::Session::SQLite'                  => 0,
         'Parse::RecDescent'                     => 0,

Modified: trunk/lib/CPAN/Forum/RM/Notify.pm
===================================================================
--- trunk/lib/CPAN/Forum/RM/Notify.pm	2006-08-31 08:48:35 UTC (rev 217)
+++ trunk/lib/CPAN/Forum/RM/Notify.pm	2006-08-31 08:48:43 UTC (rev 218)
@@ -81,6 +81,11 @@
     $self->_feed('rss');
 }
 
+=head2 atom
+
+adom feed
+
+=cut
 sub atom {
     my ($self) = @_;
     $self->_feed('atom');
@@ -95,7 +100,7 @@
     my $limit  = $self->config("${type}_size") || 10;
     my $it = $self->get_feed($limit);
     #if ($it) {
-        my $call = "generate_$type";
+        my $call = "_generate_$type";
         return $self->$call($it, $limit);
     #}
     #else {
@@ -104,13 +109,42 @@
     #}
 }
 
-sub generate_atom {
-    # TODO
-    die "TODO";
+sub _generate_atom {
+    my ($self, $it, $limit) = @_;
+
+    require XML::Atom::SimpleFeed;
+ 
+    my $url = "http://$ENV{HTTP_HOST}/";
+
+    my $feed = XML::Atom::SimpleFeed->new(
+        title    => 'CPAN::Forum',
+        link     => $url,
+        author   => 'admin at cpanforum.com',
+    );
+ 
+    if ($it) {
+        while (my $post = $it->next() and $limit--) {
+            my $title = sprintf "[%s] %s", $post->gid->name, $post->subject;
+            $feed->add_entry(
+                title  => $title, # TODO _subject_escape ?
+                link   => $url. "posts/" . $post->id(), 
+            );
+        }
+    }
+    else {
+        $feed->add_entry(
+            title => 'No posts yet',
+            link  => $url,
+        );
+    }
+
+    $self->header_props(-type => 'application/atom+xml');
+    
+    return $feed->as_string();
 }
 
 
-sub generate_rss {
+sub _generate_rss {
     my ($self, $it, $limit) = @_;
 
     require XML::RSS::SimpleGen;

Modified: trunk/lib/CPAN/Forum.pm
===================================================================
--- trunk/lib/CPAN/Forum.pm	2006-08-31 08:48:35 UTC (rev 217)
+++ trunk/lib/CPAN/Forum.pm	2006-08-31 08:48:43 UTC (rev 218)
@@ -507,7 +507,9 @@
     search all 
     site_is_closed
     help
-    rss ); 
+    rss
+    atom
+); 
 my @restricted_modes = qw(
     new_post process_post
     mypan 
@@ -532,7 +534,9 @@
     admin
     admin_edit_user
     mypan selfconfig 
-    search all rss 
+    search all 
+    rss
+    atom
 ); 
 
 use base 'CPAN::Forum::RM::Author';

Added: trunk/www/img/atom.gif
===================================================================
(Binary files differ)


Property changes on: trunk/www/img/atom.gif
___________________________________________________________________
Name: svn:mime-type
   + image/gif



More information about the Cpan-forum-commit mailing list