1 package Gitalist::Controller::Repository;
6 use Sys::Hostname qw/hostname/;
7 use namespace::autoclean;
9 BEGIN { extends 'Gitalist::Controller' }
10 with 'Gitalist::URIStructure::Repository';
12 sub base : Chained('/base') PathPart('') CaptureArgs(0) {}
16 Provides an atom feed for a given repository.
20 sub atom : Chained('find') Args(0) {
23 my $feed = XML::Atom::Feed->new;
25 my $host = lc hostname();
26 $feed->title($host . ' - ' . Gitalist->config->{name});
27 $feed->updated(~~DateTime->now);
29 my $repository = $c->stash->{Repository};
31 sha1 => $repository->head_hash,
32 count => Gitalist->config->{paging}{log} || 25,
35 my $mk_title = $c->stash->{short_cmt};
36 for my $commit ($repository->list_revs(%logargs)) {
37 my $entry = XML::Atom::Entry->new;
38 $entry->title( $mk_title->($commit->comment) );
39 $entry->id($c->uri_for_action('/commit/commit', [$repository->name, $commit->sha1]));
40 # XXX FIXME Needs work ...
41 $entry->content($commit->comment);
42 $feed->add_entry($entry);
45 $c->response->body($feed->as_xml);
46 $c->response->content_type('application/atom+xml');
51 Provides an RSS feed for a given repository.
55 sub rss : Chained('find') Args(0) {
58 my $repository = $c->stash->{Repository};
60 my $rss = XML::RSS->new(version => '2.0');
62 title => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name},
63 link => $c->uri_for('summary', {p=>$repository->name}),
65 description => $repository->description,
66 pubDate => DateTime->now,
67 lastBuildDate => DateTime->now,
71 sha1 => $repository->head_hash,
72 count => Gitalist->config->{paging}{log} || 25,
73 # ($c->req->param('f') ? (file => $c->req->param('f')) : ())
75 my $mk_title = $c->stash->{short_cmt};
76 for my $commit ($repository->list_revs(%logargs)) {
77 # XXX FIXME Needs work ....
79 title => $mk_title->($commit->comment),
80 permaLink => $c->uri_for_action('/commit/commit', [$repository->name, $commit->sha1]),
81 description => $commit->comment,
85 $c->response->body($rss->as_string);
86 $c->response->content_type('application/rss+xml');
89 __PACKAGE__->meta->make_immutable;