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) {}
15 Gitalist::Controller::Repository - Controller::Repository module for Gitalist
19 The action for the search form.
23 sub search : Chained('find') Args(0) {
25 my $repository = $c->stash->{Repository};
26 # Lifted from /shortlog.
28 sha1 => $repository->head_hash,
29 # count => Gitalist->config->{paging}{log},
30 # ($c->req->param('f') ? (file => $c->req->param('f')) : ()),
32 type => $c->req->param('type'),
33 text => $c->req->param('text'),
34 regexp => $c->req->param('regexp') || 0,
40 results => [$repository->list_revs(%logargs)],
41 # This could be added - page => $page,
47 Provide a simple redirect to C</ref/tree>.
51 sub tree : Chained('find') Args(0) {
53 $c->res->redirect($c->uri_for_action('/ref/tree', [$c->stash->{Repository}->name, 'HEAD']));
59 Provides an atom feed for a given repository.
63 sub atom : Chained('find') Does('FilenameArgs') Args() {
66 my $host = lc hostname();
68 title => $host . ' - ' . Gitalist->config->{name},
69 updated => DateTime->now
72 my $repository = $c->stash->{Repository};
74 sha1 => $repository->head_hash,
75 count => Gitalist->config->{paging}{log} || 25,
76 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
80 my $mk_title = $c->stash->{short_cmt};
81 for my $commit ($repository->list_revs(%logargs)) {
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;
93 $c->response->content_type('application/atom+xml');
98 Provides an RSS feed for a given repository.
102 sub rss : Chained('find') Does('FilenameArgs') Args() {
105 my $repository = $c->stash->{Repository};
108 title => lc(Sys::Hostname::hostname()) . ' - ' . Gitalist->config->{name},
110 pubDate => DateTime->now,
111 lastBuildDate => DateTime->now,
116 sha1 => $repository->head_hash,
117 count => Gitalist->config->{paging}{log} || 25,
118 ($c->stash->{filename} ? (file => $c->stash->{filename}) : ()),
121 my $mk_title = $c->stash->{short_cmt};
122 for my $commit ($repository->list_revs(%logargs)) {
123 # XXX FIXME Needs work ....
125 title => $mk_title->($commit->comment),
126 permaLink => $c->uri_for_action('/ref/commit', [$repository->name, $commit->sha1]),
127 description => $commit->comment,
130 $c->stash(Commits => \@revs);
131 $c->response->content_type('application/rss+xml');
134 __PACKAGE__->meta->make_immutable;