Merge branch 'master' of git://github.com/zts/Gitalist into zts-patches
Dan Brook [Thu, 19 Nov 2009 18:49:16 +0000 (18:49 +0000)]
Conflicts:
lib/Gitalist/Controller/Root.pm

Makefile.PL
lib/Gitalist/Controller/Root.pm
root/nav/actions.tt2
t/03legacy_uri.t

index 5359f9e..920142c 100644 (file)
@@ -57,6 +57,7 @@ requires 'Sub::Exporter';
 requires 'Syntax::Highlight::Engine::Kate';
 requires 'Sys::Hostname';
 requires 'XML::Atom';
+requires 'XML::RSS';
 
 author_requires 'Test::NoTabs';
 author_requires 'Test::Pod' => '1.14';
index 17c8750..4ffb827 100644 (file)
@@ -11,9 +11,10 @@ BEGIN { extends 'Catalyst::Controller' }
 __PACKAGE__->config->{namespace} = '';
 
 use IO::Capture::Stdout;
+use Sys::Hostname ();
 use XML::Atom::Feed;
 use XML::Atom::Entry;
-use Sys::Hostname ();
+use XML::RSS;
 
 =head1 NAME
 
@@ -428,16 +429,44 @@ sub atom : Local {
     $feed->add_entry($entry);
   }
 
-  $c->stash(
-    feed       => $feed->as_xml,
-    no_wrapper => 1,
-  );
+  $c->response->body($feed->as_xml);
   $c->response->content_type('application/atom+xml')
+  $c->response->status(200);
 }
 
 sub rss : Local {
-    # FIXME - implement rss
-    Carp::croak "Not implemented.";
+  my ($self, $c) = @_;
+
+  my $project = $c->stash->{Project};
+
+  my $rss = XML::RSS->new(version => '2.0');
+  $rss->channel(
+    title          => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name},
+    link           => $c->uri_for('summary', {p=>$project->name}),
+    language       => 'en',
+    description    => $project->description,
+    pubDate        => DateTime->now,
+    lastBuildDate  => DateTime->now,
+  );
+
+  my %logargs = (
+      sha1   => $project->head_hash,
+      count  => Gitalist->config->{paging}{log} || 25,
+      ($c->req->param('f') ? (file => $c->req->param('f')) : ())
+  );
+  my $mk_title = $c->stash->{short_cmt};
+  for my $commit ($project->list_revs(%logargs)) {
+    # XXX Needs work ....
+    $rss->add_item(
+        title       => $mk_title->($commit->comment),
+        permaLink   => $c->uri_for(commit => {h=>$commit->sha1}),
+        description => $commit->comment,
+    );
+  }
+
+  $c->response->body($rss->as_string);
+  $c->response->content_type('application/rss+xml');
+  $c->response->status(200);
 }
 
 sub patch : Local {
index a5a5767..4e647b2 100644 (file)
@@ -3,8 +3,8 @@
     <a href="[% c.uri_for('shortlog', {h=object.sha1}) %]">shortlog</a> •
     <a href="[% c.uri_for('log', {h=object.sha1}) %]">log</a> •
     <a href="[% c.uri_for('commit', {h=object.sha1}) %]">commit</a> •
-    <a href="[% c.uri_for('commitdiff', {h=object.sha1}) %]">commitdiff</a> •
-    [% IF object.type == 'commit' %]
+    <a href="[% c.uri_for('commitdiff', {h=object.sha1}) %]">commitdiff</a>
+    [% IF object.type == 'commit' %] •
     <a href="[% c.uri_for('tree', {h=object.tree_sha1, hb=object.sha1}) %]">tree</a>
     [% END %]
     <div class='chroma-hash'>[% INCLUDE '_chroma_hash.tt2' sha1 = object.sha1 %]</div>
index de6ad10..35b86fe 100644 (file)
@@ -217,23 +217,20 @@ test('/', 'a=atom;h=refs/heads/master');
 test('/', 'a=atom;h=refs/heads/master;opt=--no-merges');
 test('/', 'a=atom;opt=--no-merges');
 
-TODO: {
-    local $TODO = "Action: rss is not yet implemented.";
-    test('/', 'a=rss');
-    test('/', 'a=rss;f=dir1');
-    test('/', 'a=rss;f=dir1/file2');
-    test('/', 'a=rss;f=dir1/file2;opt=--no-merges');
-    test('/', 'a=rss;f=dir1;h=refs/heads/master');
-    test('/', 'a=rss;f=dir1;h=refs/heads/master;opt=--no-merges');
-    test('/', 'a=rss;f=dir1;opt=--no-merges');
-    test('/', 'a=rss;f=file1');
-    test('/', 'a=rss;f=file1;h=refs/heads/master');
-    test('/', 'a=rss;f=file1;h=refs/heads/master;opt=--no-merges');
-    test('/', 'a=rss;f=file1;opt=--no-merges');
-    test('/', 'a=rss;h=refs/heads/master');
-    test('/', 'a=rss;h=refs/heads/master;opt=--no-merges');
-    test('/', 'a=rss;opt=--no-merges');
-}
+test('/', 'a=rss');
+test('/', 'a=rss;f=dir1');
+test('/', 'a=rss;f=dir1/file2');
+test('/', 'a=rss;f=dir1/file2;opt=--no-merges');
+test('/', 'a=rss;f=dir1;h=refs/heads/master');
+test('/', 'a=rss;f=dir1;h=refs/heads/master;opt=--no-merges');
+test('/', 'a=rss;f=dir1;opt=--no-merges');
+test('/', 'a=rss;f=file1');
+test('/', 'a=rss;f=file1;h=refs/heads/master');
+test('/', 'a=rss;f=file1;h=refs/heads/master;opt=--no-merges');
+test('/', 'a=rss;f=file1;opt=--no-merges');
+test('/', 'a=rss;h=refs/heads/master');
+test('/', 'a=rss;h=refs/heads/master;opt=--no-merges');
+test('/', 'a=rss;opt=--no-merges');
 
 done_testing;