Generalized the usage of the navigation helper by introducing a 'realm' parameter

Change-Id: Ief04c7884d144a60855a25498faa8cca44a8ecd2
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 933b79b..51cb8f6 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -214,14 +214,14 @@
   };
 
   # Configure documentation navigation
-  my $navi = Mojo::File->new($self->home->child('templates','doc','navigation.json'))->slurp;
-  $navi = $navi ? decode_json($navi) : [];
+  my $doc_navi = Mojo::File->new($self->home->child('templates','doc','navigation.json'))->slurp;
+  $doc_navi = $doc_navi ? decode_json($doc_navi) : [];
 
   if ($conf->{navi_ext}) {
-    push @$navi, @{$conf->{navi_ext}};
+    push @$doc_navi, @{$conf->{navi_ext}};
   };
 
-  $self->config(navi => $navi);
+  $self->config(doc_navi => $doc_navi);
 
   $self->log->info('API expected at ' . $self->korap->api);
 
diff --git a/lib/Kalamar/Controller/Documentation.pm b/lib/Kalamar/Controller/Documentation.pm
index abcaadb..bcb6633 100644
--- a/lib/Kalamar/Controller/Documentation.pm
+++ b/lib/Kalamar/Controller/Documentation.pm
@@ -22,7 +22,7 @@
   # Set navigation to sidebar
   $c->content_block(
     sidebar => {
-      inline => '<nav>' . $c->doc_navi($c->config('navi')) . '</nav>'
+      inline => '<nav>' . $c->navigation('doc', $c->config('doc_navi')) . '</nav>'
     }
   );
 
diff --git a/lib/Kalamar/Plugin/KalamarPages.pm b/lib/Kalamar/Plugin/KalamarPages.pm
index 1943542..8f4f3b5 100644
--- a/lib/Kalamar/Plugin/KalamarPages.pm
+++ b/lib/Kalamar/Plugin/KalamarPages.pm
@@ -104,7 +104,7 @@
       my $scope = shift;
       my $url;
       if ($page) {
-        $url = $c->doc->url($scope, $page);
+        $url = $c->url_with('doc', scope => $scope, page => $page);
         $url->path->canonicalize;
       }
       else {
@@ -115,8 +115,10 @@
   );
 
 
+  # DEPRECATED: 2019-10-24
   $mojo->helper(
     'doc.url' => sub {
+      deprecated 'Deprecated "doc->url" in favor of direct usage with "url_with"';
       my $c = shift;
       my $page = pop;
       my $scope = shift;
@@ -129,14 +131,25 @@
   );
 
   # Documentation navigation helper
+  # DEPRECATED: 2019-10-24
   $mojo->helper(
     doc_navi => sub {
+      deprecated 'Deprecated "docnavi" in favor of "navigation"';
       my $c = shift;
+      return $c->navigation('doc', @_)
+    }
+  );
+
+  # Navigation helper
+  $mojo->helper(
+    'navigation' => sub {
+      my $c = shift;
+      my $realm = shift;
       my $items = pop;
       my $scope = shift;
 
       # Create unordered list
-      my $html = '<ul class="nav">'."\n";
+      my $html = '<ul class="nav nav-'.$realm.'">'."\n";
 
       # Embed all link tags
       foreach (@$items) {
@@ -152,7 +165,10 @@
           my $id = $_->{id};
           $id =~ s/^#//;
 
-          $url = $c->doc->url($part_scope, $page);
+          $url = $c->url_with($realm, scope => $part_scope, page => $page);
+
+          # Canonicalize (for empty scopes)
+          $url->path->canonicalize;
           $url->fragment($id);
         }
 
@@ -165,7 +181,7 @@
           };
 
           # Generate url with query parameter inheritance
-          $url = $c->doc->url($scope, $_->{id});
+          $url = $c->url_with($realm, scope => $scope, page => $_->{id});
 
           # Canonicalize (for empty scopes)
           $url->path->canonicalize;
@@ -194,7 +210,7 @@
         if ($_->{items} && ref($_->{items}) eq 'ARRAY') {
           $html .= "\n";
           my $subscope = $scope ? scalar($scope) . '/' . $_->{id} : $_->{id};
-          $html .= $c->doc_navi($subscope, $_->{items});
+          $html .= $c->navigation($realm, $subscope, $_->{items});
           $html .= "</li>\n";
         }
         else {
@@ -292,9 +308,9 @@
 Currently not used.
 
 
-=head2 doc_navi
+=head2 navigation
 
-Returns an HTML representation of the documentation navigation,
+Returns an HTML representation of a navigation structure
 based on active navigation items.