Started vc integration in frontend
diff --git a/dev/js/src/app/de.js b/dev/js/src/app/de.js
index f5be5ec..6576051 100644
--- a/dev/js/src/app/de.js
+++ b/dev/js/src/app/de.js
@@ -9,6 +9,7 @@
loc.VC_title = 'Titel';
loc.VC_pubDate = 'Veröffentlichungsdatum';
loc.VC_pubPlace = 'Veröffentlichungsort';
+ loc.VC_allCorpora = 'allen Korpora';
// Date picker:
loc.WDAY = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 7c403aa..09804ca 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -21,6 +21,10 @@
// Set hint array for hint helper
KorAP.hintArray = hintArray;
+ // Localization values
+ var loc = KorAP.Locale;
+ loc.VC_allCorpora = loc.VC_allCorpora || 'all Corpora';
+
// Override KorAP.log
window.alertify = alertifyClass;
KorAP.log = function (type, msg) {
@@ -48,7 +52,7 @@
vcname.setAttribute('id', 'vc-choose');
vcname.appendChild(
document.createTextNode(
- document.getElementById('vc-name').value
+ document.getElementById('vc-name').value || loc.VC_allCorpora
)
);
input.parentNode.insertBefore(vcname, input);
diff --git a/lib/Kalamar/API.pm b/lib/Kalamar/API.pm
index fc49af8..596b75b 100644
--- a/lib/Kalamar/API.pm
+++ b/lib/Kalamar/API.pm
@@ -25,7 +25,8 @@
_api_cache
api_response
benchmark
- query_jsonld/]);
+ query_jsonld
+ collection_jsonld/]);
$index_class->attr(no_cache => 0);
};
@@ -351,6 +352,63 @@
# Set result values
$index->items_per_page($json->{itemsPerPage});
$index->query_jsonld($json->{request}->{query});
+
+ # Temporary
+ # $json->{request}->{collection}
+ $index->collection_jsonld({
+ '@type' => "koral:docGroup",
+ "operation" => "operation:or",
+ "operands" => [
+ {
+ '@type' => "koral:docGroup",
+ "operation" => "operation:and",
+ "operands" => [
+ {
+ '@type' => "koral:doc",
+ "key" => "title",
+ "match" => "match:eq",
+ "value" => "Der Birnbaum",
+ "type" => "type:string"
+ },
+ {
+ '@type' => "koral:doc",
+ "key" => "pubPlace",
+ "match" => "match:eq",
+ "value" => "Mannheim",
+ "type" => "type:string"
+ },
+ {
+ '@type' => "koral:docGroup",
+ "operation" => "operation:or",
+ "operands" => [
+ {
+ '@type' => "koral:doc",
+ "key" => "subTitle",
+ "match" => "match:eq",
+ "value" => "Aufzucht oder Pflege",
+ "type" => "type:string"
+ },
+ {
+ '@type' => "koral:doc",
+ "key" => "subTitle",
+ "match" => "match:eq",
+ "value" => "Gedichte",
+ "type" => "type:string"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ '@type' => "koral:doc",
+ "key" => "pubDate",
+ "match" => "match:geq",
+ "value" => "2015-03-05",
+ "type" => "type:date"
+ }
+ ]
+ });
+
$index->results(_map_matches($json->{matches}));
# Total results not set by stash
diff --git a/templates/partial/header.html.ep b/templates/partial/header.html.ep
index a090b76..f714af8 100644
--- a/templates/partial/header.html.ep
+++ b/templates/partial/header.html.ep
@@ -13,11 +13,10 @@
<button type="submit" title="<%= loc 'go' %>"><span><%= loc 'go' %></span></button>
</div>
<!-- Search in the following virtual collection -->
- <!--
<div id="vc-view"></div>
- <%= loc 'in' %> <input type="hidden" id="vc-name" name="vc-name" value="Wikipedia" />
- <input type="text" name="vc" id="vc" value="corpusID = Wikipedia" />
- -->
+ <%= loc 'in' %> <input type="hidden" id="vc-name" name="vc-name" value="<%= stash('vc-name') %>" />
+ <input type="text" name="vc" id="vc" value="<%= stash 'vc-query' %>" />
+
<%= loc 'with' %>
<span class="select">
%= select_field 'ql', [[Poliqarp => 'poliqarp'], ['Cosmas II' => 'cosmas2'], ['Annis' => 'annis'], ['CQL v1.2' => 'cql']], id => 'ql-field'
diff --git a/templates/search.html.ep b/templates/search.html.ep
index a0e26b6..20353d0 100644
--- a/templates/search.html.ep
+++ b/templates/search.html.ep
@@ -1,4 +1,5 @@
% layout 'main', title => loc('searchtitle', q => search->query, ql => search->query_language);
+% use Mojo::JSON 'encode_json';
<div class="resultinfo">
<div id="pagination"><%= pagination(search->start_page, search->total_pages, url_with->query(['p' => '{page}'])) =%></div>
@@ -16,6 +17,13 @@
% };
</div>
+% if (search->collection_jsonld) {
+%= javascript begin
+KorAP.currentVC = <%== encode_json search->collection_jsonld %>;
+% end
+% };
+
+
% if (search->total_results != 0 && search->results->size) {
<div id="search">
<ol class="align-left">