1 package Gitalist::Controller::Root;
5 use Sys::Hostname qw/hostname/;
6 use XML::OPML::SimpleGen;
8 use Gitalist::Utils qw/ age_string /;
10 use namespace::autoclean;
12 BEGIN { extends 'Gitalist::Controller' }
14 __PACKAGE__->config->{namespace} = '';
16 sub root : Chained('/') PathPart('') CaptureArgs(0) {}
18 sub index : Chained('base') PathPart('') Args(0) {
19 my ( $self, $c ) = @_;
21 my $search = $c->req->param('s') || '';
24 search_text => $search,
30 Provides some help for the search form.
34 sub search_help : Chained('base') Args(0) {}
36 sub opml : Chained('base') Args(0) {
39 my $opml = XML::OPML::SimpleGen->new();
41 $opml->head(title => lc(hostname()) . ' - ' . Gitalist->config->{name});
43 my @list = @{ $c->model()->repositories };
44 die 'No repositories found in '. $c->model->repo_dir
47 for my $proj ( @list ) {
48 $opml->insert_outline(
49 text => $proj->name. ' - '. $proj->description,
50 xmlUrl => $c->uri_for(rss => {p => $proj->name}),
54 $c->response->body($opml->as_string);
55 $c->response->content_type('application/rss');
56 $c->response->status(200);
59 sub base : Chained('/root') PathPart('') CaptureArgs(0) {
62 my $git_version = `git --version`;
65 git_version => $git_version,
66 version => $Gitalist::VERSION,
68 # XXX Move these to a plugin!
70 return 'never' unless $_[0];
71 return age_string(time - $_[0]->epoch);
75 my($line) = split /\n/, $cmt;
76 $line =~ s/^(.{70,80}\b).*/$1 \x{2026}/;
79 abridged_description => sub {
80 join(' ', grep { defined } (split / /, shift)[0..10]);
85 sub end : ActionClass('RenderView') {
87 # Give repository views the current HEAD.
88 if ($c->stash->{Repository}) {
89 $c->stash->{HEAD} = $c->stash->{Repository}->head_hash;
93 sub error_404 : Action {
95 $c->response->status(404);
96 $c->response->body('Page not found');
99 __PACKAGE__->meta->make_immutable;
105 Gitalist::Controller::Root - Root controller for the application
109 This controller handles all of the root level paths for the application
115 Root of chained actions
119 Populate the header and footer. Perhaps not the best location.
123 Provides the repository listing.
127 Attempt to render a view, if needed.
137 =head2 repository_index
141 See L<Gitalist> for authors.
145 See L<Gitalist> for the license.