Tutorial: Introduce legacy links
Change-Id: If7bcc7ab5a9e16c0a83602a4617d51ae5a82397e
diff --git a/Changes b/Changes
index 7882ef8..dc1d6fc 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.43 2021-09-08
+0.43 2021-09-09
- New menu class that has an entry at the very end,
similar to the input text prefix,
that is always available. (lerepp)
@@ -25,6 +25,7 @@
- Fix tests on text method to accept undef for Mojo >= 9.21.
- Plugin::TagHelpers::ContenBlock now on CPAN.
- Fix navigation behaviour for folded subdirectories.
+ - Introduce legacy redirects for tutorial links.
0.42 2021-06-18
- Added GitHub based CI for perl.
diff --git a/kalamar.dict b/kalamar.dict
index 09bdc64..05db62d 100644
--- a/kalamar.dict
+++ b/kalamar.dict
@@ -170,7 +170,7 @@
data => {
'annotation' => 'doc/data/annotation'
},
- korap => {
+ development => {
'kalamar' => 'doc/development/kalamar',
'karang' => 'doc/development/karang',
'koral' => 'doc/development/koral',
diff --git a/lib/Kalamar/Controller/Documentation.pm b/lib/Kalamar/Controller/Documentation.pm
index 6b83dd5..762ab25 100644
--- a/lib/Kalamar/Controller/Documentation.pm
+++ b/lib/Kalamar/Controller/Documentation.pm
@@ -32,11 +32,23 @@
$c->stash(documentation => 1);
$c->stash('robots' => 'index,follow');
- return $c->render_maybe(
+ my $render = $c->render_maybe(
template => $c->loc('Template_' . join('_', @path), join('/', @path))
) || $c->render_maybe(
template => $c->loc('Template_' . join('_', 'custom', @path), join('/', 'custom', @path))
- ) || $c->reply->not_found;
+ );
+ return $render if $render;
+
+ # Legacy links
+ if ($scope) {
+ if ($scope eq 'korap') {
+ return $c->redirect_to('doc', scope => 'development');
+ };
+ } elsif ($page eq 'korap') {
+ return $c->redirect_to('doc', page => 'development');
+ };
+
+ return $c->reply->not_found;
};
@@ -116,7 +128,7 @@
=head1 COPYRIGHT AND LICENSE
-Copyright (C) 2015-2018, L<IDS Mannheim|http://www.ids-mannheim.de/>
+Copyright (C) 2015-2021, L<IDS Mannheim|http://www.ids-mannheim.de/>
Author: L<Nils Diewald|http://nils-diewald.de/>
Kalamar is developed as part of the L<KorAP|http://korap.ids-mannheim.de/>
diff --git a/t/doc_legacy.t b/t/doc_legacy.t
new file mode 100644
index 0000000..8cbe3bd
--- /dev/null
+++ b/t/doc_legacy.t
@@ -0,0 +1,49 @@
+use Mojo::Base -strict;
+use Test::More;
+use Test::Mojo;
+
+# Test legacy links for documentation
+
+my $t = Test::Mojo->new('Kalamar');
+
+my $h = $t->get_ok('/doc/korap')
+ ->status_is(302)
+ ->header_like('Location',qr!/doc/+development!)
+ ->tx->res->headers->header('Location')
+ ;
+
+$t->get_ok($h)
+ ->status_is(200)
+ ;
+
+$h = $t->get_ok('/doc/korap/kalamar')
+ ->status_is(302)
+ ->header_like('Location',qr!/doc/+development/+kalamar!)
+ ->tx->res->headers->header('Location')
+ ;
+
+$t->get_ok($h)
+ ->status_is(200)
+ ;
+
+$t->get_ok('/doc/korap/karang')
+ ->status_is(302)
+ ->header_like('Location',qr!/doc/+development/+karang!)
+ ;
+
+$t->get_ok('/doc/korap/koral')
+ ->status_is(302)
+ ->header_like('Location',qr!/doc/+development/+koral!)
+ ;
+
+$t->get_ok('/doc/korap/krill')
+ ->status_is(302)
+ ->header_like('Location',qr!/doc/+development/+krill!)
+ ;
+
+$t->get_ok('/doc/korap/kustvakt')
+ ->status_is(302)
+ ->header_like('Location',qr!/doc/+development/+kustvakt!)
+ ;
+
+done_testing();