1 package Gitalist::Controller::Repository;
3 use Sys::Hostname qw/hostname/;
4 use namespace::autoclean;
6 BEGIN { extends 'Gitalist::Controller' }
7 with 'Gitalist::URIStructure::Repository';
9 sub base : Chained('/base') PathPart('') CaptureArgs(0) {}
13 The action for the search form.
17 sub search : Chained('find') Args(0) {
19 my $repository = $c->stash->{Repository};
20 # Lifted from /shortlog.
22 sha1 => $repository->head_hash,
23 # count => Gitalist->config->{paging}{log},
24 # ($c->req->param('f') ? (file => $c->req->param('f')) : ()),
26 type => $c->req->param('type'),
27 text => $c->req->param('text'),
28 regexp => $c->req->param('regexp') || 0,
34 results => [$repository->list_revs(%logargs)],
35 # This could be added - page => $page,
41 Provide a simple redirect to C</ref/tree>.
45 sub tree : Chained('find') Args(0) {
47 $c->res->redirect($c->uri_for_action('/ref/tree', [$c->stash->{Repository}->name, 'HEAD']));
53 Provides an atom feed for a given repository.
57 sub atom : Chained('find') Does('FilenameArgs') Args() {
60 my $host = lc hostname();
62 title => $host . ' - ' . Gitalist->config->{name},
63 updated => DateTime->now
66 my $repository = $c->stash->{Repository};
68 sha1 => $repository->head_hash,
69 count => Gitalist->config->{paging}{log} || 25,
70 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
74 my $mk_title = $c->stash->{short_cmt};
75 for my $commit ($repository->list_revs(%logargs)) {
77 $entry->{title} = $mk_title->($commit->comment);
78 $entry->{id} = $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]);
79 # XXX FIXME Needs work ...
80 $entry->{content} = $commit->comment;
87 $c->response->content_type('application/atom+xml');
92 Provides an RSS feed for a given repository.
96 sub rss : Chained('find') Does('FilenameArgs') Args() {
99 my $repository = $c->stash->{Repository};
102 title => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name},
104 pubDate => DateTime->now,
105 lastBuildDate => DateTime->now,
110 sha1 => $repository->head_hash,
111 count => Gitalist->config->{paging}{log} || 25,
112 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
115 my $mk_title = $c->stash->{short_cmt};
116 for my $commit ($repository->list_revs(%logargs)) {
117 # XXX FIXME Needs work ....
119 title => $mk_title->($commit->comment),
120 permaLink => $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]),
121 description => $commit->comment,
124 $c->stash(Commits => \@revs);
125 $c->response->content_type('application/rss+xml');
128 __PACKAGE__->meta->make_immutable;