Commit | Line | Data |
319537bf |
1 | package Gitalist::Controller::LegacyURI; |
2 | use Moose; |
9c515df2 |
3 | use Moose::Autobox; |
319537bf |
4 | use namespace::autoclean; |
5 | |
6 | BEGIN { extends 'Gitalist::Controller' } |
7 | |
8 | sub 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 |
21 | sub 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; |