Deprecated 'collection' parameter in favor of 'cq' - fixes #92
Change-Id: I51f0197da3a182fc4d4cd35f12ccb88cce3f8833
diff --git a/dev/demo/all.html b/dev/demo/all.html
index 8417903..bd7461c 100644
--- a/dev/demo/all.html
+++ b/dev/demo/all.html
@@ -37,12 +37,12 @@
<!-- <i class="fa fa-arrow-circle-down show-hint" onclick="hint.popUp()"></i> -->
</div>
- <!-- Search in the following virtual collection -->
+ <!-- Search in the following virtual corpus -->
<div id="vc-view"></div>
in
<input id="show" name="show" type="hidden" />
<!--<input id="collection-name" name="collection-name" type="hidden"> -->
- <input id="collection" name="collection" type="text" value="">
+ <input id="cq" name="cq" type="text" value="">
with <span class="menu select">
<select name="ql" id="ql-field">
<option value="poliqarp">Poliqarp</option>
@@ -111,7 +111,7 @@
KorAP.koralQuery = {
"matches":["..."],
- "collection":{
+ "corpus":{
"@type": "koral:docGroup",
"operation": "operation:or", "operands": [{
"@type": "koral:docGroup",
diff --git a/dev/demo/alldemo.js b/dev/demo/alldemo.js
index 6f9f60b..108bfe6 100644
--- a/dev/demo/alldemo.js
+++ b/dev/demo/alldemo.js
@@ -774,7 +774,7 @@
require(['app/en', 'init', 'hint/foundries/cnx'], function (lang) {
KorAP.hintArray = hintArray;
- // Set current virtual collection
+ // Set current virtual corpus
// KorAP.currentVC = vcExample;
// Parse and show the table
diff --git a/dev/demo/sidebar-login.html b/dev/demo/sidebar-login.html
index eb2f429..2b127f1 100644
--- a/dev/demo/sidebar-login.html
+++ b/dev/demo/sidebar-login.html
@@ -54,12 +54,12 @@
<!-- <i class="fa fa-arrow-circle-down show-hint" onclick="hint.popUp()"></i> -->
</div>
- <!-- Search in the following virtual collection -->
+ <!-- Search in the following virtual corpus -->
<div id="vc-view"></div>
in
<input id="show" name="show" type="hidden" />
- <input id="collection-name" name="collection-name" type="hidden">
- <input id="collection" name="collection" type="text" value="">
+ <!--<input id="collection-name" name="collection-name" type="hidden"> -->
+ <input id="cq" name="cq" type="text" value="">
with <span class="menu select">
<select name="ql" id="ql-field">
<option value="poliqarp">Poliqarp</option>
diff --git a/dev/demo/vcdemo.js b/dev/demo/vcdemo.js
index e0b9f16..75c7cf1 100644
--- a/dev/demo/vcdemo.js
+++ b/dev/demo/vcdemo.js
@@ -67,7 +67,7 @@
]
};
-var collections = [
+var corpora = [
{
"statistics":{
"paragraphs":2034752,
@@ -120,7 +120,7 @@
domReady(function() {
- // Create a new virtual collection by passing a based json object and
+ // Create a new virtual corpus by passing a based json object and
// field menu information
KorAP.vc = vcClass.create([
['title', 'string'],
diff --git a/dev/js/spec/tourSpec.js b/dev/js/spec/tourSpec.js
index 18d3b4e..55307b4 100644
--- a/dev/js/spec/tourSpec.js
+++ b/dev/js/spec/tourSpec.js
@@ -14,11 +14,11 @@
"<input autocapitalize='off' autocomplete='off' autocorrect='off' autofocus='autofocus' id='q-field' name='q' placeholder='Finde ...' spellcheck='false' type='search'>" +
"<button type='submit' id='qsubmit' title='Los!'><span>Los!</span></button>" +
"</div>" +
- "<!-- Search in the following virtual collection -->"+
+ "<!-- Search in the following virtual corpus -->"+
"<div id='vc-view'></div>" +
"in" +
"<span id='vc-choose' class='select'><span>allen Korpora</span></span>" +
- "<input id='collection' name='collection' type='text' style='display: none;'>" +
+ "<input id='cq' name='cq' type='text' style='display: none;'>" +
"mit" +
"<span class='select'>" +
"<select id='ql-field' name='ql' style='display: none;'>" +
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index 564b8d6..388a26d 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -1561,7 +1561,7 @@
);
});
- it('should be deserializable from collection 1', function () {
+ it('should be deserializable from collection/corpus 1', function () {
var kq = {
"matches":["..."],
"collection":{
@@ -1624,6 +1624,13 @@
var vc = vcClass.create().fromJson(kq["collection"]);
expect(vc.toQuery()).toEqual('(title = "Der Birnbaum" & pubPlace = "Mannheim" & (subTitle = "Aufzucht und Pflege" | subTitle = "Gedichte")) | pubDate since 2015-03-05');
+
+ kq["corpus"] = kq["collection"]
+ delete kq["collection"]
+
+ vc = vcClass.create().fromJson(kq["corpus"]);
+ expect(vc.toQuery()).toEqual('(title = "Der Birnbaum" & pubPlace = "Mannheim" & (subTitle = "Aufzucht und Pflege" | subTitle = "Gedichte")) | pubDate since 2015-03-05');
+
});
it('should be deserializable from collection 2', function () {
@@ -1692,6 +1699,7 @@
expect(vc.toQuery()).toEqual('availability = /CC-BY.*/ & author = "Goethe"');
});
+
it('shouldn\'t be deserializable from collection with unknown type', function () {
var kq = {
"@type" : "koral:doc",
diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index e536ea2..eae75a8 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -85,7 +85,7 @@
/**
- * Retrieve information about collections
+ * Retrieve information about virtual corpora
*/
KorAP.API.getCollections = function (cb) {
KorAP.API.getJSON(KorAP.URL + '/collection', cb, "CorpusInfo");
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index ec11cf5..6de66d8 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -95,10 +95,10 @@
};
/**
- * Replace Virtual Collection field
+ * Replace Virtual Corpus field
*/
var vcname, vcchoose;
- var input = d.getElementById('collection');
+ var input = d.getElementById('cq');
var vc = KorAP.vc;
@@ -110,9 +110,10 @@
vcname.classList.add('select');
// Load virtual corpus object
- if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
+ // Supports "collection" for legacy reasons
+ if (KorAP.koralQuery !== undefined && (KorAP.koralQuery["collection"] || KorAP.koralQuery["corpus"])) {
try {
- vc.fromJson(KorAP.koralQuery["collection"]);
+ vc.fromJson(KorAP.koralQuery["collection"] || KorAP.koralQuery["corpus"]);
}
catch (e) {
KorAP.log(0,e);
@@ -264,12 +265,12 @@
/*
- * Toggle the Virtual Collection builder
+ * Toggle the Virtual Corpus builder
*/
if (vcname) {
vc.onMinimize = function () {
vcname.classList.remove('active');
- delete show['collection'];
+ delete show['vc'];
};
vc.onOpen = function () {
@@ -279,7 +280,7 @@
if (!view.firstChild)
view.appendChild(this.element());
- show['collection'] = true;
+ show['vc'] = true;
};
var vcclick = function () {
@@ -294,7 +295,7 @@
vcname.onclick = vcclick;
// Click, if the VC should be shown
- if (show['collection']) {
+ if (show['vc']) {
vcclick.apply();
};
};
diff --git a/dev/js/src/loc/de.js b/dev/js/src/loc/de.js
index de0ab80..99d3fa3 100644
--- a/dev/js/src/loc/de.js
+++ b/dev/js/src/loc/de.js
@@ -4,14 +4,7 @@
loc.AND = 'und';
// EMPTY, DELETE
- // Virtual collection:
- /*
- loc.VC_subTitle = 'Untertitel';
- loc.VC_title = 'Titel';
- loc.VC_pubDate = 'Veröffentlichungsdatum';
- loc.VC_pubPlace = 'Veröffentlichungsort';
- */
-
+ // Virtual corpus:
loc.VC_allCorpora = 'allen Korpora';
loc.VC_oneCollection = 'einem virtuellen Korpus';
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index fd67863..5d1ccf0 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -1,6 +1,6 @@
/**
- * Create virtual collections with a visual user interface. This resembles the
- * collection type objects of a KoralQuery "collection" object.
+ * Create virtual corpora with a visual user interface. This resembles the
+ * corpus/collection type objects of a KoralQuery "collection"/"corpus" object.
*
* KoralQuery v0.3 is expected.
*
@@ -115,18 +115,18 @@
};
/**
- * Virtual Collection
+ * Virtual corpus
*/
return {
/**
- * The JSON-LD type of the virtual collection
+ * The JSON-LD type of the virtual corpus
*/
ldType : function() {
return null;
},
- // Initialize virtual collection
+ // Initialize virtual corpus
_init : function(keyList) {
// Inject localized css styles
@@ -164,7 +164,7 @@
},
/**
- * Create a new virtual collection.
+ * Create a new virtual corpus
*/
create : function(keyList) {
var obj = Object.create(this)._init(keyList);
@@ -174,8 +174,8 @@
/**
- * Create and render a new virtual collection based on a KoralQuery
- * collection document
+ * Create and render a new virtual corpus based on a KoralQuery
+ * corpus document
*/
fromJson : function(json) {
if (json !== undefined) {
@@ -255,7 +255,7 @@
},
/**
- * Get or set the root object of the virtual collection.
+ * Get or set the root object of the virtual corpus
*/
root : function(obj) {
if (arguments.length === 1) {
diff --git a/dev/js/src/vc/choosemenu.js b/dev/js/src/vc/choosemenu.js
index 84f6ae9..90660b7 100644
--- a/dev/js/src/vc/choosemenu.js
+++ b/dev/js/src/vc/choosemenu.js
@@ -1,5 +1,5 @@
/**
- * Menu showing all predefined virtual collections.
+ * Menu showing all predefined virtual corpora.
* THIS IS EXPERIMENTAL AND MAY BE REMOVED!
*/
define(['vc/menu', 'api'], function (menuClass, itemClass) {
diff --git a/dev/js/src/vc/stringval.js b/dev/js/src/vc/stringval.js
index 77c6d90..8b05787 100644
--- a/dev/js/src/vc/stringval.js
+++ b/dev/js/src/vc/stringval.js
@@ -1,5 +1,5 @@
/**
- * Add string values to the virtual collection
+ * Add string values to the virtual corpus
*/
define(['util'], {
diff --git a/dev/js/src/vc/unspecified.js b/dev/js/src/vc/unspecified.js
index 416ad85..4ffe507 100644
--- a/dev/js/src/vc/unspecified.js
+++ b/dev/js/src/vc/unspecified.js
@@ -1,5 +1,5 @@
/**
- * An unspecified criterion in a virtual collection.
+ * An unspecified criterion in a virtual corpus.
* Inherits everything from jsonld
*/
define([