From: Tomas Doran Date: Sun, 17 Jan 2010 21:02:08 +0000 (+0000) Subject: Get the index page working with the content in a fragment and all the URIs moved X-Git-Tag: 0.000006_01~1^2~103 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=066e9aa4ab5745fb5f09e2348830b6fb18e10bf9;p=catagits%2FGitalist.git Get the index page working with the content in a fragment and all the URIs moved --- diff --git a/lib/Gitalist/Controller/Fragment.pm b/lib/Gitalist/Controller/Fragment.pm index 869c5b7..15c4511 100644 --- a/lib/Gitalist/Controller/Fragment.pm +++ b/lib/Gitalist/Controller/Fragment.pm @@ -5,6 +5,28 @@ use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } -sub base : Chained('/root') PathPart('fragment') CaptureArgs(0) {} +sub base : Chained('/root') PathPart('fragment') CaptureArgs(0) { + my ($self, $c) = @_; + $c->stash(no_wrapper => 1); +} + +sub collectionofrepositories : Chained('base') Args(0) { + my ($self, $c) = @_; + my @list = @{ $c->model()->repositories }; + die 'No repositories found in '. $c->model->repo_dir + unless @list; + + my $search = $c->req->param('s') || ''; + if($search) { + @list = grep { + index($_->name, $search) > -1 + or ( $_->description !~ /^Unnamed repository/ and index($_->description, $search) > -1 ) + } @list + } + + $c->stash( + repositories => \@list, + ); +} __PACKAGE__->meta->make_immutable; diff --git a/lib/Gitalist/Controller/Fragment/Repository.pm b/lib/Gitalist/Controller/Fragment/Repository.pm index cee32d9..db1557e 100644 --- a/lib/Gitalist/Controller/Fragment/Repository.pm +++ b/lib/Gitalist/Controller/Fragment/Repository.pm @@ -5,10 +5,7 @@ use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } with 'Gitalist::URIStructure::Repository'; -sub base : Chained('/fragment/base') PathPart('') CaptureArgs(0) { - my ($self, $c) = @_; - $c->stash(no_wrapper => 1); -} +sub base : Chained('/fragment/base') PathPart('') CaptureArgs(0) {} after shortlog => sub { my ($self, $c) = @_; diff --git a/lib/Gitalist/Controller/Repository.pm b/lib/Gitalist/Controller/Repository.pm index b79e51b..96fe14f 100644 --- a/lib/Gitalist/Controller/Repository.pm +++ b/lib/Gitalist/Controller/Repository.pm @@ -5,6 +5,6 @@ use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } with 'Gitalist::URIStructure::Repository'; -sub base : Chained('/root') PathPart('') CaptureArgs(0) {} +sub base : Chained('/base') PathPart('') CaptureArgs(0) {} __PACKAGE__->meta->make_immutable; diff --git a/lib/Gitalist/Controller/Root.pm b/lib/Gitalist/Controller/Root.pm index c8479cd..7c55b31 100644 --- a/lib/Gitalist/Controller/Root.pm +++ b/lib/Gitalist/Controller/Root.pm @@ -46,22 +46,10 @@ sub index : Chained('base') PathPart('') Args(0) { $c->detach($c->req->param('a')) if $c->req->param('a'); - my @list = @{ $c->model()->repositories }; - die 'No repositories found in '. $c->model->repo_dir - unless @list; - my $search = $c->req->param('s') || ''; - if($search) { - @list = grep { - index($_->name, $search) > -1 - or ( $_->description !~ /^Unnamed repository/ and index($_->description, $search) > -1 ) - } @list - } $c->stash( search_text => $search, - repositories => \@list, - action => 'index', ); } @@ -86,7 +74,6 @@ sub summary : Chained('base') Args(0) { )], refs => $repository->references, heads => [ @heads[0 .. ($#heads < $maxitems ? $#heads : $maxitems)] ], - action => 'summary', ); } @@ -102,7 +89,6 @@ sub heads : Chained('base') Args(0) { $c->stash( commit => $self->_get_object($c), heads => $repository->heads, - action => 'heads', ); } @@ -118,7 +104,6 @@ sub tags : Chained('base') Args(0) { $c->stash( commit => $self->_get_object($c), tags => $repository->tags, - action => 'tags', ); } @@ -185,7 +170,6 @@ sub blob : Chained('base') Args(0) { filename => $filename, # XXX Hack hack hack, see View::SyntaxHighlight language => ($filename =~ /\.p[lm]$/i ? 'Perl' : ''), - action => 'blob', ); $c->forward('View::SyntaxHighlight') @@ -246,7 +230,6 @@ sub blobdiff : Chained('base') Args(0) { # XXX Hack hack hack, see View::SyntaxHighlight blobs => [$patch->[0]->{diff}], language => 'Diff', - action => 'blobdiff', ); $c->forward('View::SyntaxHighlight') @@ -267,7 +250,6 @@ sub commit : Chained('base') Args(0) { commit => $commit, diff_tree => ($repository->diff(commit => $commit))[0], refs => $repository->references, - action => 'commit', ); } @@ -292,7 +274,6 @@ sub commitdiff : Chained('base') Args(0) { # XXX Hack hack hack, see View::SyntaxHighlight blobs => [map $_->{diff}, @$patch], language => 'Diff', - action => 'commitdiff', ); $c->forward('View::SyntaxHighlight') @@ -337,7 +318,6 @@ sub shortlog : Chained('base') Args(0) { refs => $repository->references, page => $page, filename => $filename, - action => 'shortlog', ); } @@ -349,7 +329,6 @@ Calls shortlog internally. Perhaps that should be reversed ... sub log : Chained('base') Args(0) { $_[0]->shortlog($_[1]); - $_[1]->stash->{action} = 'log'; } # For legacy support. @@ -363,7 +342,7 @@ sub history : Chained('base') Args(0) { $c->stash->{filename} ) ); - $c->stash( action => 'history', + $c->stash( filetype => $file->type, ); } @@ -388,7 +367,6 @@ sub tree : Chained('base') Args(0) { tree => $tree, tree_list => [$repository->list_tree($tree->sha1)], path => $c->req->param('f') || '', - action => 'tree', ); } @@ -406,7 +384,6 @@ sub reflog : Chained('base') Args(0) { $c->stash( log => \@log, - action => 'reflog', ); } @@ -435,7 +412,6 @@ sub search : Chained('base') Args(0) { $c->stash( commit => $commit, results => [$repository->list_revs(%logargs)], - action => 'search', # This could be added - page => $page, ); } @@ -605,19 +581,10 @@ sub snapshot : Chained('base') Args(0) { sub base : Chained('/root') PathPart('') CaptureArgs(0) { my($self, $c) = @_; - my $repository = $c->req->param('p'); - if (defined $repository) { - eval { - $c->stash(Repository => $c->model()->get_repository($repository)); - }; - if ($@) { - $c->detach('/error_404'); - } - } - - my $a_repository = $c->stash->{Repository} || $c->model()->repositories->[0]; + my $git_version = `git --version`; + chomp($git_version); $c->stash( - git_version => $a_repository->run_cmd('--version'), + git_version => $git_version, version => $Gitalist::VERSION, # XXX Move these to a plugin! diff --git a/root/fragment/collectionofrepositories.tt2 b/root/fragment/collectionofrepositories.tt2 new file mode 100644 index 0000000..4dae472 --- /dev/null +++ b/root/fragment/collectionofrepositories.tt2 @@ -0,0 +1,15 @@ + + [% FOR p IN repositories %] + [%- repos_link = c.uri_for_action('/repository/summary', [p.name]) -%] + + [% p.name %] + [% abridged_description(p.description) %] + [% p.owner %] + [% time_since(p.last_change) %] + summary + | shortlog + | log + | tree + + [% END %] + diff --git a/root/index.tt2 b/root/index.tt2 index 9d1544d..5ab87e7 100644 --- a/root/index.tt2 +++ b/root/index.tt2 @@ -1,3 +1,13 @@ +[% BLOCK repos_table_headfoot %] + + Repository + + Description + Owner + Last Change + + +[% END %]

Search: @@ -7,39 +17,12 @@ - - - - - - - - + [% INCLUDE repos_table_headfoot %] - - - - - - - - + [% INCLUDE repos_table_headfoot %] - - [% FOR p IN repositories %] - - - - - - - - [% END %] - + [% subinclude('/fragment/collectionofrepositories') %]
RepositoryDescriptionOwnerLast Change
RepositoryDescriptionOwnerLast Change
[% p.name %][% abridged_description(p.description) %][% p.owner %][% time_since(p.last_change) %]