X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FGitalist%2FController%2FRepository.pm;h=ec28dbb8fed51547b7da167d41af3ac9c9c6e425;hb=2298d93ff984748b0c15d19bad6fdebb1d81c4f1;hp=b3ed66639847ee6f64ce3e19fd7dde764c6a9ffa;hpb=840edca5cc6b621336749fb04640c0abd515883f;p=catagits%2FGitalist.git diff --git a/lib/Gitalist/Controller/Repository.pm b/lib/Gitalist/Controller/Repository.pm index b3ed666..ec28dbb 100644 --- a/lib/Gitalist/Controller/Repository.pm +++ b/lib/Gitalist/Controller/Repository.pm @@ -1,8 +1,5 @@ package Gitalist::Controller::Repository; use Moose; -use XML::Atom::Feed; -use XML::Atom::Entry; -use XML::RSS; use Sys::Hostname qw/hostname/; use namespace::autoclean; @@ -11,18 +8,24 @@ with 'Gitalist::URIStructure::Repository'; sub base : Chained('/base') PathPart('') CaptureArgs(0) {} +=encoding UTF-8 + +=head1 NAME + +Gitalist::Controller::Repository - Controller::Repository module for Gitalist + =head2 search The action for the search form. =cut -sub search : Chained('base') Args(0) { +sub search : Chained('find') Args(0) { my($self, $c) = @_; my $repository = $c->stash->{Repository}; # Lifted from /shortlog. my %logargs = ( -# sha1 => $commit->sha1, + sha1 => $repository->head_hash, # count => Gitalist->config->{paging}{log}, # ($c->req->param('f') ? (file => $c->req->param('f')) : ()), search => { @@ -39,21 +42,16 @@ sub search : Chained('base') Args(0) { ); } -=head2 reflog +=head2 tree -Expose the local reflog. This may go away. +Provide a simple redirect to C. =cut -sub reflog : Chained('base') Args(0) { - my ( $self, $c ) = @_; - my @log = $c->stash->{Repository}->reflog( - '--since=yesterday' - ); - - $c->stash( - log => \@log, - ); +sub tree : Chained('find') Args(0) { + my($self, $c) = @_; + $c->res->redirect($c->uri_for_action('/ref/tree', [$c->stash->{Repository}->name, 'HEAD'])); + $c->res->status(301); } =head2 atom @@ -62,33 +60,37 @@ Provides an atom feed for a given repository. =cut -sub atom : Chained('find') Args(0) { - my($self, $c) = @_; - - my $feed = XML::Atom::Feed->new; +sub atom : Chained('find') Does('FilenameArgs') Args() { + my ($self, $c) = @_; - my $host = lc hostname(); - $feed->title($host . ' - ' . Gitalist->config->{name}); - $feed->updated(~~DateTime->now); - - my $repository = $c->stash->{Repository}; - my %logargs = ( - sha1 => $repository->head_hash, - count => Gitalist->config->{paging}{log} || 25, - ); + my $host = lc hostname(); + $c->stash( + title => $host . ' - ' . Gitalist->config->{name}, + updated => DateTime->now + ); - my $mk_title = $c->stash->{short_cmt}; - for my $commit ($repository->list_revs(%logargs)) { - my $entry = XML::Atom::Entry->new; - $entry->title( $mk_title->($commit->comment) ); - $entry->id($c->uri_for_action('/commit/commit', [$repository->name, $commit->sha1])); - # XXX FIXME Needs work ... - $entry->content($commit->comment); - $feed->add_entry($entry); - } + my $repository = $c->stash->{Repository}; + my %logargs = ( + sha1 => $repository->head_hash, + count => Gitalist->config->{paging}{log} || 25, + ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()), + ); - $c->response->body($feed->as_xml); - $c->response->content_type('application/atom+xml'); + my @revs; + my $mk_title = $c->stash->{short_cmt}; + for my $commit ($repository->list_revs(%logargs)) { + my $entry = {}; + $entry->{title} = $mk_title->($commit->comment); + $entry->{id} = $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]); + # XXX FIXME Needs work ... + $entry->{content} = $commit->comment; + push(@revs, $entry); + } + $c->stash( + Commits => \@revs, + no_wrapper => 1, + ); + $c->response->content_type('application/atom+xml'); } =head2 rss @@ -97,37 +99,35 @@ Provides an RSS feed for a given repository. =cut -sub rss : Chained('find') Args(0) { +sub rss : Chained('find') Does('FilenameArgs') Args() { my ($self, $c) = @_; my $repository = $c->stash->{Repository}; - my $rss = XML::RSS->new(version => '2.0'); - $rss->channel( + $c->stash( title => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name}, - link => $c->uri_for_action('/repository/summary', [$repository->name]), language => 'en', - description => $repository->description, pubDate => DateTime->now, lastBuildDate => DateTime->now, + no_wrapper => 1, ); my %logargs = ( sha1 => $repository->head_hash, count => Gitalist->config->{paging}{log} || 25, -# ($c->req->param('f') ? (file => $c->req->param('f')) : ()) + ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()), ); + my @revs; my $mk_title = $c->stash->{short_cmt}; for my $commit ($repository->list_revs(%logargs)) { # XXX FIXME Needs work .... - $rss->add_item( + push(@revs, { title => $mk_title->($commit->comment), - permaLink => $c->uri_for_action('/commit/commit', [$repository->name, $commit->sha1]), + permaLink => $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]), description => $commit->comment, - ); + }); } - - $c->response->body($rss->as_string); + $c->stash(Commits => \@revs); $c->response->content_type('application/rss+xml'); }