Fixed error message handling
diff --git a/korap.conf b/korap.conf
index 53730fb..1afb74a 100644
--- a/korap.conf
+++ b/korap.conf
@@ -4,7 +4,9 @@
'api-0.1' => 'http://10.0.10.13:7070/api/v0.1/'
},
Notifications => {
- Alertify => 1,
+ Alertify => {
+ base_timeout => 10_000
+ },
JSON => 1
},
Search => {
diff --git a/lib/Korap/Plugin/KorapSearch.pm b/lib/Korap/Plugin/KorapSearch.pm
index 29e4d2b..4ea36d9 100644
--- a/lib/Korap/Plugin/KorapSearch.pm
+++ b/lib/Korap/Plugin/KorapSearch.pm
@@ -117,7 +117,7 @@
my $total_results = $c->chi->get('total-' . $cache_url);
if (defined $total_results) {
$c->stash('search.totalResults' => $total_results);
- $c->app->log->warn('Get total result from cache');
+ $c->app->log->debug('Get total result from cache');
$url->query({cutoff => 'true'});
}
else {
@@ -150,25 +150,28 @@
my $json = $res->json;
# Reformat benchmark counter
- my $b_hit = $json->{benchmarkHitCounter};
- my $b_search = $json->{benchmarkSearchResults};
- if ($b_hit && $b_hit =~ s/\s+(m)?s$//) {
- $b_hit = sprintf("%.2f", $b_hit) . ($1 ? $1 : '') . 's';
- };
- if ($b_search && $b_search =~ s/\s+(m)?s$//) {
- $b_search = sprintf("%.2f", $b_search) . ($1 ? $1 : '') . 's';
+# my $b_hit = $json->{benchmarkHitCounter};
+# my $b_search = $json->{benchmarkSearchResults};
+# if ($b_hit && $b_hit =~ s/\s+(m)?s$//) {
+# $b_hit = sprintf("%.2f", $b_hit) . ($1 ? $1 : '') . 's';
+# };
+# if ($b_search && $b_search =~ s/\s+(m)?s$//) {
+# $b_search = sprintf("%.2f", $b_search) . ($1 ? $1 : '') . 's';
+# };
+ my $benchmark = $json->{benchmark};
+ if ($benchmark && $benchmark =~ s/\s+(m)?s$//) {
+ $benchmark = sprintf("%.2f", $benchmark) . ($1 ? $1 : '') . 's';
};
for ($c->stash) {
- $_->{'search.bm.hit'} = $b_hit;
- $_->{'search.bm.result'} = $b_search;
+ $_->{'search.benchmark'} = $benchmark;
$_->{'search.itemsPerPage'} = $json->{itemsPerPage};
$_->{'search.query'} = $json->{request}->{query};
$_->{'search.hits'} = map_matches($json->{matches});
};
if ($json->{totalResults} > -1) {
- $c->app->log->warn('Cache total result');
+ $c->app->log->debug('Cache total result');
$c->stash('search.totalResults' => $json->{totalResults});
$c->chi->set('total-' . $cache_url => $json->{totalResults}, '30min');
};
@@ -179,9 +182,12 @@
if ($json->{error}) {
$c->notify(error => $json->{error});
- };
+ }
-# $json->{}
+ # New error messages
+ elsif ($json->{errstr}) {
+ $c->notify(error => $json->{errstr});
+ };
}
# Request failed
@@ -200,7 +206,7 @@
my $v = $cb->();
# Delete useless stash keys
- foreach (qw/hits totalResults bm.hit bm.result itemsPerPage error query/) {
+ foreach (qw/hits totalResults benchmark itemsPerPage error query/) {
delete $c->stash->{'search.' . $_};
};
return $v;
diff --git a/public/sass/colors.scss b/public/sass/colors.scss
index f77f972..a5bcc5f 100644
--- a/public/sass/colors.scss
+++ b/public/sass/colors.scss
@@ -26,9 +26,10 @@
$kwic-match-color: $dark-grey;
$kwic-match-shadow: $light-shadow;
-$kwic-highlight-0: #c1002b;
-$kwic-highlight-1: $dark-blue; // #009ee0;
-$kwic-highlight-2: #f29400;
+$kwic-highlight-1: #c1002b;
+$kwic-highlight-2: $dark-blue; // #009ee0;
+$kwic-highlight-3: $dark-orange; // #f29400;
+$kwic-highlight-4: $light-green;
$pagination-bg: $light-grey;
$pagination-border: $middle-grey;
diff --git a/public/sass/kwic-4.0.scss b/public/sass/kwic-4.0.scss
index 8a16289..ee4c3af 100644
--- a/public/sass/kwic-4.0.scss
+++ b/public/sass/kwic-4.0.scss
@@ -118,9 +118,10 @@
padding-bottom: 6px;
}
-.class-0 { border-color: $kwic-highlight-0; }
.class-1 { border-color: $kwic-highlight-1; }
.class-2 { border-color: $kwic-highlight-2; }
+.class-3 { border-color: $kwic-highlight-3; }
+.class-4 { border-color: $kwic-highlight-4; }
span.more:before {
diff --git a/templates/search.html.ep b/templates/search.html.ep
index 7c96a68..47191b9 100644
--- a/templates/search.html.ep
+++ b/templates/search.html.ep
@@ -9,7 +9,7 @@
<div id="pagination"><%= pagination(stash('search.startPage'), $pages, $url) =%></div>
<p class="found">Found
<span id="total-results"><%= commify(stash('search.totalResults')) %> matches</span>
- <% if (stash 'search.bm.hit') { %> in <%= stash 'search.bm.hit' %> (<%= stash 'search.bm.result' %>)<% } %>
+ <% if (stash 'search.benchmark') { %> in <%= stash 'search.benchmark' %><% } %>
</p>
</div>
%= include 'query'