Simplified documentation routing
Change-Id: Ie2e3907133e12b245b8ebb03b18f70af5b8cfe89
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index a47bb2d..322f118 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -239,8 +239,7 @@
# Documentation routes
$r->get('/doc')->to('documentation#page', page => 'korap')->name('doc_start');
- $r->get('/doc/:page')->to('documentation#page')->name('doc1');
- $r->get('/doc/*scope/:page')->to('documentation#page')->name('doc2');
+ $r->get('/doc/:scope/:page')->to('documentation#page', scope => undef)->name('doc');
# Contact route
$r->get('/contact')->to('documentation#contact');
diff --git a/lib/Kalamar/Plugin/KalamarPages.pm b/lib/Kalamar/Plugin/KalamarPages.pm
index 66ee72b..4c49854 100644
--- a/lib/Kalamar/Plugin/KalamarPages.pm
+++ b/lib/Kalamar/Plugin/KalamarPages.pm
@@ -25,8 +25,9 @@
($page, my $fragment) = split '#', $page;
- my $url = $c->doc->url($scope, $page);
+ my $url = $c->url_with('doc' => page => $page, scope => $scope);
$url->fragment($fragment) if $fragment;
+ $url->path->canonicalize;
return $c->link_to(
$title,
@@ -112,17 +113,10 @@
my $c = shift;
my $page = pop;
my $scope = shift;
- if ($scope) {
- return $c->url_with(
- 'doc2',
- page => $page,
- scope => $scope
- );
- };
-
return $c->url_with(
- 'doc1',
- page => $page
+ 'doc',
+ page => $page,
+ scope => $scope
);
}
);