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 The action for the search form.
20 sub search : Chained('find') Args(0) {
22 my $repository = $c->stash->{Repository};
23 # Lifted from /shortlog.
25 sha1 => $repository->head_hash,
26 # count => Gitalist->config->{paging}{log},
27 # ($c->req->param('f') ? (file => $c->req->param('f')) : ()),
29 type => $c->req->param('type'),
30 text => $c->req->param('text'),
31 regexp => $c->req->param('regexp') || 0,
37 results => [$repository->list_revs(%logargs)],
38 # This could be added - page => $page,
44 Expose the local reflog. This may go away.
48 sub reflog : Chained('find') Args(0) {
49 my ( $self, $c ) = @_;
50 my @log = $c->stash->{Repository}->reflog(
61 Provides an atom feed for a given repository.
65 sub atom : Chained('find') Args(0) {
68 my $feed = XML::Atom::Feed->new;
70 my $host = lc hostname();
71 $feed->title($host . ' - ' . Gitalist->config->{name});
72 $feed->updated(~~DateTime->now);
74 my $repository = $c->stash->{Repository};
76 sha1 => $repository->head_hash,
77 count => Gitalist->config->{paging}{log} || 25,
80 my $mk_title = $c->stash->{short_cmt};
81 for my $commit ($repository->list_revs(%logargs)) {
82 my $entry = XML::Atom::Entry->new;
83 $entry->title( $mk_title->($commit->comment) );
84 $entry->id($c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]));
85 # XXX FIXME Needs work ...
86 $entry->content($commit->comment);
87 $feed->add_entry($entry);
90 $c->response->body($feed->as_xml);
91 $c->response->content_type('application/atom+xml');
96 Provides an RSS feed for a given repository.
100 sub rss : Chained('find') Args(0) {
103 my $repository = $c->stash->{Repository};
105 my $rss = XML::RSS->new(version => '2.0');
107 title => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name},
108 link => $c->uri_for_action('/repository/summary', [$repository->name]),
110 description => $repository->description,
111 pubDate => DateTime->now,
112 lastBuildDate => DateTime->now,
116 sha1 => $repository->head_hash,
117 count => Gitalist->config->{paging}{log} || 25,
118 # ($c->req->param('f') ? (file => $c->req->param('f')) : ())
120 my $mk_title = $c->stash->{short_cmt};
121 for my $commit ($repository->list_revs(%logargs)) {
122 # XXX FIXME Needs work ....
124 title => $mk_title->($commit->comment),
125 permaLink => $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]),
126 description => $commit->comment,
130 $c->response->body($rss->as_string);
131 $c->response->content_type('application/rss+xml');
134 __PACKAGE__->meta->make_immutable;