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 Provide a simple redirect to C</ref/tree>.
48 sub tree : Chained('find') Args(0) {
50 $c->res->redirect($c->uri_for_action('/ref/tree', [$c->stash->{Repository}->name, 'HEAD']));
56 Provides an atom feed for a given repository.
60 sub atom : Chained('find') Does('FilenameArgs') Args() {
63 my $host = lc hostname();
65 title => $host . ' - ' . Gitalist->config->{name},
66 updated => DateTime->now
69 my $repository = $c->stash->{Repository};
71 sha1 => $repository->head_hash,
72 count => Gitalist->config->{paging}{log} || 25,
73 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
77 my $mk_title = $c->stash->{short_cmt};
78 for my $commit ($repository->list_revs(%logargs)) {
80 $entry->{title} = $mk_title->($commit->comment);
81 $entry->{id} = $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]);
82 # XXX FIXME Needs work ...
83 $entry->{content} = $commit->comment;
90 $c->response->content_type('application/atom+xml');
95 Provides an RSS feed for a given repository.
99 sub rss : Chained('find') Does('FilenameArgs') Args() {
102 my $repository = $c->stash->{Repository};
105 title => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name},
107 pubDate => DateTime->now,
108 lastBuildDate => DateTime->now,
113 sha1 => $repository->head_hash,
114 count => Gitalist->config->{paging}{log} || 25,
115 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
118 my $mk_title = $c->stash->{short_cmt};
119 for my $commit ($repository->list_revs(%logargs)) {
120 # XXX FIXME Needs work ....
122 title => $mk_title->($commit->comment),
123 permaLink => $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]),
124 description => $commit->comment,
127 $c->stash(Commits => \@revs);
128 $c->response->content_type('application/rss+xml');
131 __PACKAGE__->meta->make_immutable;