Adjustments for subdirectory serving
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index bf7c206..7938a9e 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -16,6 +16,23 @@
domReady,
hintArray,
alertifyClass) {
+
+ // Set hint array for hint helper
+ KorAP.hintArray = hintArray;
+
+ // Override KorAP.log
+ window.alertify = alertifyClass;
+ KorAP.log = function (type, msg) {
+
+ // Use alertify to log errors
+ alertifyClass.log(
+ (type === 0 ? '' : type + ': ') +
+ msg,
+ 'error',
+ 5000
+ );
+ };
+
domReady(function (event) {
var obj = {};
@@ -147,21 +164,6 @@
// tutorial pages as well!
obj.hint = hintClass.create();
- // Set hint array for hint helper
- KorAP.hintArray = hintArray;
-
- // Override KorAP.log
- KorAP.log = function (type, msg) {
-
- // Use alertify to log errors
- alertifyClass.log(
- (type === 0 ? '' : type + ': ') +
- msg,
- 'error',
- 5000
- );
- };
-
return obj;
});
});
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 4204d48..10d2e53 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -18,6 +18,16 @@
# Add additional plugin path
push(@{$self->plugins->namespaces}, __PACKAGE__ . '::Plugin');
+ # korap.ids-mannheim.de specific
+ $self->hook(
+ before_dispatch => sub {
+ my $c = shift;
+ my $host = $c->req->headers->header('X-Forwarded-Host');
+ if ($host && $host eq 'korap.ids-mannheim.de') {
+ $c->req->url->base->path('/kalamar/');
+ };
+ }) if $self->mode eq 'production';
+
# Set secrets for signed cookies
if (-e (my $secret = $self->home . '/kalamar.secret')) {
$self->secrets([
@@ -80,8 +90,14 @@
=pod
-To get started, you'll need npm. Then you can install and run grunt:
+The static files are generated using Grunt.
+To get started with Grunt, you need NodeJS > 0.8 ..., you'll need npm. Then you can install and run grunt:
sudo npm install -g grunt-cli
npm install
grunt
+
+
+Some perl modules are not on github yet, so you need to install them from github using cpanm:
+
+ cpanm git://github.com/Akron/Mojolicious-Plugin-Localize.git
diff --git a/templates/doc/data/corpus.html.ep b/templates/doc/data/corpus.html.ep
new file mode 100644
index 0000000..17dbda0
--- /dev/null
+++ b/templates/doc/data/corpus.html.ep
@@ -0,0 +1,5 @@
+% layout 'main', title => 'KorAP: Corpora';
+
+<h2>Corpora</h2>
+
+%= doc_uc
diff --git a/templates/exception.html.ep b/templates/exception.html.ep
deleted file mode 100644
index 8d3e656..0000000
--- a/templates/exception.html.ep
+++ /dev/null
@@ -1 +0,0 @@
-% notify('error' => '500: Server Error');
diff --git a/templates/exception.production.html.ep b/templates/exception.production.html.ep
new file mode 100644
index 0000000..7d8af3b
--- /dev/null
+++ b/templates/exception.production.html.ep
@@ -0,0 +1,6 @@
+% my $msg = $exception->message // '500: Internal Server Error';
+% layout 'main', title => 'KorAP: ' . $msg;
+
+<p id="no-results"><%= $msg %></p>
+
+% notify('error' => $msg);
diff --git a/templates/layouts/main.html.ep b/templates/layouts/main.html.ep
index cb72f8a..6280855 100644
--- a/templates/layouts/main.html.ep
+++ b/templates/layouts/main.html.ep
@@ -6,7 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=false, user-scalable=no" />
<link href="/img/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<link href="/css/kalamar-<%= $Kalamar::VERSION %>.css" type="text/css" rel="stylesheet" />
- <script src="/js/<%== loc('jsFile', 'kalamar-' . $Kalamar::VERSION . '-en.js') %>" type="text/javascript" async="async"></script>
</head>
% my $embedded = 0;
% $embedded = 1 if stash('embedded');
@@ -33,13 +32,15 @@
<a href="http://korap.ids-mannheim.de/"><%= loc 'about' %></a>
<%= doc_link_to 'V '. $Kalamar::VERSION, 'korap', 'kalamar' %>
</footer>
- %= notifications 'Alertify', -no_include
% };
+
+%= javascript '/js/' . loc('jsFile', 'kalamar-' . $Kalamar::VERSION . '-en.js')
%= javascript begin
window.KorAP = window.KorAP || {};
% my $api = url_for('index')->to_abs;
% $api =~ s!/$!!;
KorAP.URL = '<%== $api %>';
% end
+%= notifications 'Alertify', -no_include
</body>
</html>
diff --git a/templates/not_found.production.html.ep b/templates/not_found.production.html.ep
new file mode 100644
index 0000000..ee74676
--- /dev/null
+++ b/templates/not_found.production.html.ep
@@ -0,0 +1,6 @@
+% my $msg = '404: Page not found';
+% layout 'main', title => 'KorAP: ' . $msg;
+
+<p id="no-results"><%= $msg %></p>
+
+% notify('warn' => $msg);