1 package Gitalist::Controller::Repository;
5 use Sys::Hostname qw/hostname/;
6 use namespace::autoclean;
8 BEGIN { extends 'Gitalist::Controller' }
9 with 'Gitalist::URIStructure::Repository';
11 sub base : Chained('/base') PathPart('') CaptureArgs(0) {}
15 The action for the search form.
19 sub search : Chained('find') Args(0) {
21 my $repository = $c->stash->{Repository};
22 # Lifted from /shortlog.
24 sha1 => $repository->head_hash,
25 # count => Gitalist->config->{paging}{log},
26 # ($c->req->param('f') ? (file => $c->req->param('f')) : ()),
28 type => $c->req->param('type'),
29 text => $c->req->param('text'),
30 regexp => $c->req->param('regexp') || 0,
36 results => [$repository->list_revs(%logargs)],
37 # This could be added - page => $page,
43 Provide a simple redirect to C</ref/tree>.
47 sub tree : Chained('find') Args(0) {
49 $c->res->redirect($c->uri_for_action('/ref/tree', [$c->stash->{Repository}->name, 'HEAD']));
55 Provides an atom feed for a given repository.
59 sub atom : Chained('find') Does('FilenameArgs') Args() {
62 my $host = lc hostname();
64 title => $host . ' - ' . Gitalist->config->{name},
65 updated => DateTime->now
68 my $repository = $c->stash->{Repository};
70 sha1 => $repository->head_hash,
71 count => Gitalist->config->{paging}{log} || 25,
72 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
76 my $mk_title = $c->stash->{short_cmt};
77 for my $commit ($repository->list_revs(%logargs)) {
79 $entry->{title} = $mk_title->($commit->comment);
80 $entry->{id} = $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]);
81 # XXX FIXME Needs work ...
82 $entry->{content} = $commit->comment;
89 $c->response->content_type('application/atom+xml');
94 Provides an RSS feed for a given repository.
98 sub rss : Chained('find') Does('FilenameArgs') Args() {
101 my $repository = $c->stash->{Repository};
104 title => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name},
106 pubDate => DateTime->now,
107 lastBuildDate => DateTime->now,
112 sha1 => $repository->head_hash,
113 count => Gitalist->config->{paging}{log} || 25,
114 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
117 my $mk_title = $c->stash->{short_cmt};
118 for my $commit ($repository->list_revs(%logargs)) {
119 # XXX FIXME Needs work ....
121 title => $mk_title->($commit->comment),
122 permaLink => $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]),
123 description => $commit->comment,
126 $c->stash(Commits => \@revs);
127 $c->response->content_type('application/rss+xml');
130 __PACKAGE__->meta->make_immutable;