Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split subincludes out into their own /fragment controllers.
This moves most of the logic round, and adds a role which I called ::URIStructure::XX as that is what it was conceptually for. However as it seems to have the repos lookup (and as we need to lookup the repos to work out if it exists in the top level for 404) - it's no longer so clean at all.. I think that I'm going to add a ->has_project method to the model which I can call for the 404 in the wrapped page, then the actual 'get project' logic can just be in the /fragment code and the conceptual purity of 'URIStructure' is restored somewhat..
- Loading branch information
Showing
11 changed files
with
129 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package Gitalist::Controller::Fragment; | ||
|
||
use Moose; | ||
use namespace::autoclean; | ||
|
||
BEGIN { extends 'Catalyst::Controller' } | ||
|
||
sub base : Chained('/root') PathPart('fragment') CaptureArgs(0) {} | ||
|
||
__PACKAGE__->meta->make_immutable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package Gitalist::Controller::Fragment::Repository; | ||
use Moose; | ||
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); | ||
} | ||
|
||
after shortlog => sub { | ||
my ($self, $c) = @_; | ||
$c->forward('/shortlog'); | ||
}; | ||
|
||
after heads => sub { | ||
my ($self, $c) = @_; | ||
$c->stash( | ||
heads => $c->stash->{Repository}->heads, | ||
); | ||
}; | ||
|
||
after log => sub { | ||
my ($self, $c) = @_; | ||
$c->stash( | ||
template => 'log.tt2', | ||
); | ||
$c->forward('/log'); | ||
}; | ||
|
||
__PACKAGE__->meta->make_immutable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,10 @@ | ||
package Gitalist::Controller::Repository; | ||
|
||
use Moose; | ||
use Moose::Autobox; | ||
use Try::Tiny qw/try catch/; | ||
use namespace::autoclean; | ||
|
||
BEGIN { extends 'Catalyst::Controller' } | ||
with 'Gitalist::URIStructure::Repository'; | ||
|
||
sub base : Chained('/root') PathPart('') CaptureArgs(0) { | ||
my ($self, $c) = @_; | ||
$c->stash(_do_not_mangle_uri_for => 1); | ||
} | ||
|
||
sub find : Chained('base') PathPart('') CaptureArgs(1) { | ||
my ($self, $c, $repository) = @_; | ||
try { | ||
$c->stash(Repository => $c->model()->get_repository($repository)); | ||
} | ||
catch { | ||
$c->detach('/error_404'); | ||
}; | ||
} | ||
|
||
sub summary : Chained('find') PathPart('') Args(0) {} | ||
|
||
sub shortlog : Chained('find') Args(0) { | ||
my ($self, $c) = @_; | ||
$c->stash(no_wrapper => 1); | ||
$c->forward('/shortlog'); | ||
} | ||
|
||
sub heads : Chained('find') Args(0) { | ||
my ($self, $c) = @_; | ||
$c->stash( | ||
no_wrapper => 1, | ||
heads => $c->stash->{Repository}->heads, | ||
); | ||
} | ||
|
||
sub log : Chained('find') Args(0) { | ||
my ($self, $c) = @_; | ||
$c->stash(template => 'log.tt2'); | ||
$c->forward('/log'); | ||
} | ||
sub base : Chained('/root') PathPart('') CaptureArgs(0) {} | ||
|
||
__PACKAGE__->meta->make_immutable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package Gitalist::URIStructure::Repository; | ||
use MooseX::MethodAttributes::Role; | ||
use Try::Tiny qw/try catch/; | ||
use namespace::autoclean; | ||
|
||
requires 'base'; | ||
|
||
after 'base' => sub { | ||
my ($self, $c) = @_; | ||
$c->stash(_do_not_mangle_uri_for => 1); | ||
}; | ||
|
||
sub find : Chained('base') PathPart('') CaptureArgs(1) { | ||
my ($self, $c, $repository) = @_; | ||
try { | ||
$c->stash(Repository => $c->model()->get_repository($repository)); | ||
} | ||
catch { | ||
$c->detach('/error_404'); | ||
}; | ||
} | ||
|
||
sub summary : Chained('find') PathPart('') Args(0) {} | ||
|
||
sub shortlog : Chained('find') Args(0) {} | ||
|
||
sub heads : Chained('find') Args(0) {} | ||
|
||
sub log : Chained('find') Args(0) {} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<table class='[% action %] listing'> | ||
<thead> | ||
<tr> | ||
<th>HEAD</th> | ||
<th>age</th> | ||
<th>branch</th> | ||
<th>actions</th> | ||
</tr> | ||
</thead> | ||
<tfoot> | ||
<tr> | ||
<td>HEAD</td> | ||
<td>age</td> | ||
<td>branch</td> | ||
<td>actions</td> | ||
</tr> | ||
</tfoot> | ||
|
||
<tbody> | ||
[% FOREACH head IN heads %] | ||
<tr> | ||
<td class='sha1' title='[% head.sha1 %]'>[% INCLUDE '_chroma_hash.tt2' sha1 = head.sha1.substr(0,7) %]</td> | ||
<td class='time-since' title='[% head.last_change %]'>[% time_since(head.last_change) %]</td> | ||
<td class='head[% head.sha1 == HEAD ? ' current' : '' %]'>[% head.name %]</td> | ||
<td class='action-list'> | ||
<a href="[% c.uri_for("shortlog", {h='refs/heads/' _ head.name}) %]">shortlog</a> | ||
<a href="[% c.uri_for("log", {h='refs/heads/' _ head.name}) %]">log</a> | ||
<a href="[% c.uri_for("tree", {h='refs/heads/' _ head.name, hb=head.name}) %]">tree</a> | ||
</td> | ||
</tr> | ||
[% END %] | ||
</tbody> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class='content'> | ||
[% | ||
INCLUDE '_log_pager.tt2'; | ||
INCLUDE '_shortlog.tt2'; | ||
INCLUDE '_log_pager.tt2'; | ||
%] | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<dl> | ||
<dt>description</dt><dd>[% Repository.description %]</dd> | ||
<dt>owner</dt><dd>[% Repository.owner %]</dd> | ||
<dt>last change</dt><dd>[% Repository.last_change %]</dd> | ||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,2 @@ | ||
<table class='[% action %] listing'> | ||
<thead> | ||
<tr> | ||
<th>HEAD</th> | ||
<th>age</th> | ||
<th>branch</th> | ||
<th>actions</th> | ||
</tr> | ||
</thead> | ||
<tfoot> | ||
<tr> | ||
<td>HEAD</td> | ||
<td>age</td> | ||
<td>branch</td> | ||
<td>actions</td> | ||
</tr> | ||
</tfoot> | ||
|
||
<tbody> | ||
[% FOREACH head IN heads %] | ||
<tr> | ||
<td class='sha1' title='[% head.sha1 %]'>[% INCLUDE '_chroma_hash.tt2' sha1 = head.sha1.substr(0,7) %]</td> | ||
<td class='time-since' title='[% head.last_change %]'>[% time_since(head.last_change) %]</td> | ||
<td class='head[% head.sha1 == HEAD ? ' current' : '' %]'>[% head.name %]</td> | ||
<td class='action-list'> | ||
<a href="[% c.uri_for("shortlog", {h='refs/heads/' _ head.name}) %]">shortlog</a> | ||
<a href="[% c.uri_for("log", {h='refs/heads/' _ head.name}) %]">log</a> | ||
<a href="[% c.uri_for("tree", {h='refs/heads/' _ head.name, hb=head.name}) %]">tree</a> | ||
</td> | ||
</tr> | ||
[% END %] | ||
</tbody> | ||
</table> | ||
[% INCLUDE 'nav/actions.tt2' object = commit %] | ||
[% subinclude('/fragment/repository/heads', c.req.captures) %] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,2 @@ | ||
<div class='content'> | ||
[% | ||
INCLUDE '_log_pager.tt2'; | ||
INCLUDE '_shortlog.tt2'; | ||
INCLUDE '_log_pager.tt2'; | ||
%] | ||
</div> | ||
[% INCLUDE 'nav/actions.tt2' object = commit %] | ||
[% subinclude('/fragment/repository/shortlog', c.req.captures) %] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
[% PROCESS 'nav/actions.tt2' object = commit %] | ||
|
||
<div class='summary content'> | ||
<dl> | ||
<dt>description</dt><dd>[% Repository.description %]</dd> | ||
<dt>owner</dt><dd>[% Repository.owner %]</dd> | ||
<dt>last change</dt><dd>[% Repository.last_change %]</dd> | ||
</dl> | ||
[% subinclude('/fragment/repository/summary', c.req.captures) %] | ||
|
||
<h2><a href='[% c.uri_for(c.controller.action_for('shortlog'), c.req.captures) %]'>shortlog</a></h2> | ||
[% subinclude('/repository/shortlog', c.req.captures) %] | ||
[% subinclude('/fragment/repository/shortlog', c.req.captures) %] | ||
|
||
<h2><a href='[% c.uri_for(c.controller.action_for('heads'), c.req.captures) %]'>branches</a></h2> | ||
[% subinclude('/repository/heads', c.req.captures) %] | ||
[% subinclude('/fragment/repository/heads', c.req.captures) %] | ||
</div> |