Some canges in the tutorial section
diff --git a/lib/Korap/Info.pm b/lib/Korap/Info.pm
index b4c5d91..2780ebb 100644
--- a/lib/Korap/Info.pm
+++ b/lib/Korap/Info.pm
@@ -19,7 +19,9 @@
return $c->respond_to(
json => sub {
- $c->render(json => $c->notifications(json => $c->match_info($corpus_id, $doc_id, $match_id, %query)))
+ $c->render(json => $c->notifications(
+ json => $c->match_info($corpus_id, $doc_id, $match_id, %query))
+ )
},
html => sub {
my $match = $c->match_info($corpus_id, $doc_id, $match_id);
@@ -40,7 +42,6 @@
# Todo: Return info for all collections
sub about_collection {
my $c = shift;
- my $api = $c->config('KorAP')->{'api0.1'};
my $src = $c->stash('collection_id');
if ($src) {
$c->render(
diff --git a/lib/Korap/Plugin/KorapInfo.pm b/lib/Korap/Plugin/KorapInfo.pm
index 946c997..4de0406 100644
--- a/lib/Korap/Plugin/KorapInfo.pm
+++ b/lib/Korap/Plugin/KorapInfo.pm
@@ -26,7 +26,7 @@
state $json = decode_json(b(join('', <DATA>))->encode);
# Get the API endpoint
- my $api = $param->{api};
+ my $api = $param->{'api-0.1'};
# Todo: Make this recognize the user!
$mojo->helper(
@@ -42,9 +42,11 @@
};
# Rename info endpoints and build URL
- $src = 'VirtualCollection' if $src eq 'collection';
- $src = 'Corpus' if $src eq 'corpus';
- my $url = Mojo::URL->new($api)->path('resource/' . $src);
+ $src = 'virtualcollection' if $src eq 'collection';
+ $src = 'corpus' if $src eq 'corpus';
+ my $url = Mojo::URL->new($api)->path($src);
+
+ $c->app->log->debug($url);
# Check for cached information
if (my $json = $c->chi->get($url->to_string)) {
@@ -156,7 +158,7 @@
"id":1,
"managed":true,
"created":1401193381119,
- "stats":{
+ "statistics":{
"documents":196510,
"tokens":51545081,
"sentences":4116282,
diff --git a/lib/Korap/Plugin/KorapTagHelpers.pm b/lib/Korap/Plugin/KorapTagHelpers.pm
index b2b9a4e..25ca691 100644
--- a/lib/Korap/Plugin/KorapTagHelpers.pm
+++ b/lib/Korap/Plugin/KorapTagHelpers.pm
@@ -9,12 +9,30 @@
$mojo->helper(
korap_tut_query => sub {
my ($c, $ql, $q) = @_;
+ my $onclick = 'top.useQuery(this)';
+ if ($c->param('embedded')) {
+ $onclick = 'setTutorialPage(this);' . $onclick;
+ };
$q = xml_escape $q;
- b('<pre class="query tutorial" onclick="top.useQuery(this)" ' .
+ b('<pre class="query tutorial" onclick="' . $onclick . '" ' .
qq!data-query="$q" data-query-language="$ql"><code>! .
$q . '</code></pre>');
}
);
+
+ $mojo->helper(
+ korap_tut_link_to => sub {
+ my $c = shift;
+ my $title = shift;
+ my $link = shift;
+ my $url = Mojo::URL->new($link);
+ if ($c->param('embedded')) {
+ $url->query({ embedded => 1 });
+ return $c->link_to($title, $url, onclick => 'setTutorialPage("' . $url . '")');
+ };
+ return $c->link_to($title, $url);
+ }
+ );
};
1;
diff --git a/lib/Korap/Tutorial.pm b/lib/Korap/Tutorial.pm
index 3da233a..f9d99da 100644
--- a/lib/Korap/Tutorial.pm
+++ b/lib/Korap/Tutorial.pm
@@ -14,10 +14,10 @@
$c->title('KorAP');
my $page = $c->stash('tutorial');
-
- $c->render(template => 'tutorial');
+ return $c->render(template => 'tutorial/' . $page);
};
+
1;