Improved tutorials
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 1f55517..abd4d5e 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -13,11 +13,55 @@
my $pkg = b($self->home . '/package.json')->slurp;
$Kalamar::VERSION = decode_json($pkg)->{version};
+ # Load documentation navigation
+ my $navi = b($self->home . '/templates/doc/_nav.json')->slurp;
+
+ # Add additional plugin path
+ push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin');
+
+ # Load plugins
+ foreach (qw/Config
+ Localize
+ Notifications
+ DocNavi
+ KalamarTagHelpers/) {
+ $self->plugin($_);
+ };
+
+ $self->config(navi => decode_json($navi));
+
+ $self->plugin('MailException' => $self->config('MailException'));
+
+ # Establish routes
+ my $r = $self->routes;
+
+ $r->get('/')->to(
+ cb => sub {
+ return shift->render(template => 'intro');
+ });
+
+ # Base query page
+ $r->get('/')->to('search#query')->name('index');
+
+
+ # Documentation
+ $r->get('/doc')->to('documentation#page', page => 'korap');
+ $r->get('/doc/:page')->to('documentation#page', scope => undef);
+ $r->get('/doc/*scope/:page')->to('documentation#page')->name('doc');
+};
+
+
+1;
+
+
+__END__
+
+
# Set default totle
- $self->defaults(
- layout => 'main',
- title => 'KorAP - Corpus Analysis Platform'
- );
+# $self->defaults(
+# layout => 'main',
+# title => 'KorAP - Corpus Analysis Platform'
+# );
# Set secret for signed cookies
$self->secrets([
@@ -42,25 +86,20 @@
$h->header( 'Access-Control-Allow-Headers' => 'Content-Type, Authorization, X-Requested-With' );
});
- # Add additional plugin path
- push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin');
# Load plugins
- foreach (qw/Config
- CHI
+ foreach (qw/CHI
TagHelpers::Pagination
- Notifications
Number::Commify
Search
KalamarHelpers
- KalamarTagHelpers/) {
+ /) {
$self->plugin($_);
};
# $self->plugin(AssetPack => { minify => 1 });
$self->plugin('AssetPack');
$self->plugin('AssetPack::LibSass');
- $self->plugin('MailException' => $self->config('MailException'));
# Add assets for AssetPack
$self->asset(
@@ -107,8 +146,6 @@
}
);
- # Routes
- my $r = $self->routes;
# Base search route
$r->get('/')->to('search#query')->name('index');
@@ -124,10 +161,6 @@
$r->get('/tutorial')->to('tutorial#page', tutorial => 'index');
$r->get('/tutorial/(*tutorial)')->to('tutorial#page')->name('tutorial');
- $r->get('/doc/korap')->to(
- cb => sub {
- return shift->render(template => 'doc/korap');
- });
# Todo: The FAQ-Page has a contact form for new questions
};
diff --git a/lib/Kalamar/Controller/Documentation.pm b/lib/Kalamar/Controller/Documentation.pm
new file mode 100644
index 0000000..31d11cf
--- /dev/null
+++ b/lib/Kalamar/Controller/Documentation.pm
@@ -0,0 +1,37 @@
+package Kalamar::Controller::Documentation;
+use Mojo::Base 'Mojolicious::Controller';
+
+# Show documentation page
+sub page {
+ my $c = shift;
+ if ($c->param('embedded')) {
+ $c->stash(embedded => 1);
+ };
+
+ my @path = ('doc');
+
+ # There is a scope defined
+ my $scope = $c->stash('scope');
+ push(@path, $scope) if $scope;
+
+ # Use the defined page
+ my $page = $c->stash('page');
+ push(@path, $page);
+
+ $c->content_for(
+ sidebar => '<nav>' . $c->doc_navi($c->config('navi')) . '</nav>'
+ );
+
+ # Render template
+ return $c->render(
+ sidebar_active => 1,
+ main_class => 'tutorial',
+ template => join('/', @path)
+ );
+};
+
+
+1;
+
+
+__END__
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index f56ca77..25954d4 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -3,13 +3,26 @@
# Add X-Forwarded-For to user agent call everywhere
-
-# Query the KorAP backends and render a template
sub query {
my $c = shift;
my $query = $c->param('q');
+ # No query
+ unless ($query) {
+ return $c->render(template => 'index');
+ }
+};
+
+
+1;
+
+
+__END__
+
+# Query the KorAP backends and render a template
+sub query {
+
# Base parameters for remote access
my %param = (
query_language => scalar $c->param('ql'),
diff --git a/lib/Kalamar/Controller/Tutorial.pm b/lib/Kalamar/Controller/Tutorial.pm
deleted file mode 100644
index db86998..0000000
--- a/lib/Kalamar/Controller/Tutorial.pm
+++ /dev/null
@@ -1,33 +0,0 @@
-package Kalamar::Controller::Tutorial;
-use Mojo::Base 'Mojolicious::Controller';
-
-# Todo: Set title as defaults
-
-sub page {
- my $c = shift;
-
- # Show tutorial embedded
- if ($c->param('embedded')) {
- $c->layout('snippet');
- $c->stash(embedded => 1);
- }
-
- # Show tutorial in full screen
- else {
- $c->layout('default');
- };
-
- # Title should be "KorAP"
- $c->title('KorAP');
-
- my $page = $c->stash('tutorial');
- return $c->render(
- template => 'tutorial/' . $page
- );
-};
-
-
-1;
-
-
-__END__