Added settings and navi helpers

Change-Id: Id54fa79c67609abc98c9d363b49520135fa002ac
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 51cb8f6..8470db6 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -217,12 +217,18 @@
   my $doc_navi = Mojo::File->new($self->home->child('templates','doc','navigation.json'))->slurp;
   $doc_navi = $doc_navi ? decode_json($doc_navi) : [];
 
+  # TODO:
+  #   Use navi->add()
   if ($conf->{navi_ext}) {
     push @$doc_navi, @{$conf->{navi_ext}};
   };
 
+  # TODO:
+  #   Remove navi entry
   $self->config(doc_navi => $doc_navi);
 
+  $self->navi->set(doc => $doc_navi);
+
   $self->log->info('API expected at ' . $self->korap->api);
 
   # Establish routes with authentification
@@ -241,6 +247,10 @@
   $r->get('/doc')->to('documentation#page', page => 'korap')->name('doc_start');
   $r->get('/doc/:scope/:page')->to('documentation#page', scope => undef)->name('doc');
 
+  # Settings routes (deactivated)
+  # $r->get('/settings')->to(cb => sub { shift->render('settings') })->name('settings_start');
+  # $r->get('/settings/:scope/:page')->to(scope => undef, page => undef)->name('settings');
+
   # Contact route
   $r->get('/contact')->to('documentation#contact');
   $r->get('/contact')->mail_to_chiffre('documentation#contact');
diff --git a/lib/Kalamar/Controller/Documentation.pm b/lib/Kalamar/Controller/Documentation.pm
index bcb6633..6698f55 100644
--- a/lib/Kalamar/Controller/Documentation.pm
+++ b/lib/Kalamar/Controller/Documentation.pm
@@ -28,7 +28,7 @@
 
   # Render template
   $c->stash(sidebar_active => 1);
-  $c->stash(main_class => 'tutorial');
+  $c->stash(main_class => 'page tutorial');
   $c->stash(documentation => 1);
 
   return $c->render_maybe(
diff --git a/lib/Kalamar/Plugin/KalamarPages.pm b/lib/Kalamar/Plugin/KalamarPages.pm
index 8f4f3b5..b887e7d 100644
--- a/lib/Kalamar/Plugin/KalamarPages.pm
+++ b/lib/Kalamar/Plugin/KalamarPages.pm
@@ -4,6 +4,7 @@
 use Mojo::ByteStream 'b';
 use Mojo::Util qw/xml_escape deprecated/;
 
+our $navi = {};
 
 # TODO:
 #   Add documentation plugin to programmatically
@@ -148,6 +149,11 @@
       my $items = pop;
       my $scope = shift;
 
+      # Take items from central list
+      unless ($items) {
+        $items = $navi->{$realm};
+      };
+
       # Create unordered list
       my $html = '<ul class="nav nav-'.$realm.'">'."\n";
 
@@ -192,7 +198,6 @@
         push(@classes, $_->{'class'}) if $_->{'class'};
         push(@classes, 'active') if $active;
 
-
         # New list item
         $html .= '<li';
         if (@classes) {
@@ -254,6 +259,31 @@
     }
   );
 
+  # Set a navigation list to a realm
+  $mojo->helper(
+    'navi.set' => sub {
+      my $c = shift;
+      my $realm = shift;
+      my $list = shift;
+
+      $navi->{$realm} = $list;
+    }
+  );
+
+  $mojo->helper(
+    'navi.add' => sub {
+      my $c = shift;
+      my $realm = shift;
+      my $navi_realm = ($navi->{$realm} //= []);
+      my $title = shift;
+      my $id = shift;
+
+      push @$navi_realm, {
+        title => $title,
+        id => $id
+      }
+    }
+  );
 }
 
 1;