Fixed test bug and make the plain diffs plainer.
[catagits/Gitalist.git] / lib / Gitalist / Controller / LegacyURI.pm
CommitLineData
319537bf 1package Gitalist::Controller::LegacyURI;
2use Moose;
9c515df2 3use Moose::Autobox;
319537bf 4use namespace::autoclean;
5
6BEGIN { extends 'Gitalist::Controller' }
7
8sub handler : Chained('/base') PathPart('legacy') Args() {
20503690 9 my ( $self, $c, $repos ) = @_;
10 my ($action, @captures);
ad6d2173 11 if (my $a = $c->req->param('a')) {
12 $a eq 'opml' && do { $action = '/opml/opml'; };
13 $a eq 'project_index' && do { $action = '/legacyuri/project_index'; };
20503690 14 $a =~ /^(summary|heads|tags)$/ && do { $action = "/repository/$1"; push(@captures, $repos); };
ad6d2173 15 }
16 die("Not supported") unless $action;
20503690 17 $c->res->redirect($c->uri_for_action($action, \@captures));
ad6d2173 18 $c->res->status(301);
319537bf 19}
20
ad6d2173 21sub project_index : Chained('/base') Args(0) {
9c515df2 22 my ( $self, $c ) = @_;
23
24 $c->response->content_type('text/plain');
25 $c->response->body(
26 join "\n", map $_->name, $c->model()->repositories->flatten
27 ) or die 'No repositories found in '. $c->model->repo_dir;
28}
29
319537bf 30__PACKAGE__->meta->make_immutable;