Merge branch 'new-krill-api'

Conflicts:
	kalamar.conf
diff --git a/Gruntfile.js b/Gruntfile.js
index 8b90975..7dd4651 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -114,7 +114,7 @@
 	files: ['dev/scss/{util,base,fonts,kalamar,media}.scss',
 		'dev/scss/footer/footer.scss',
 		'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
-		'dev/scss/main/{alertify,highlight,kwic,logos,' +
+		'dev/scss/main/{alertify,koralquery,highlight,kwic,logos,' +
 		'main,matchinfo,pagination,query,'+
 		'resultinfo,sidebar,tutorial}.scss'
 	       ],
diff --git a/dev/demo/all.html b/dev/demo/all.html
index 70457e7..f4adf40 100644
--- a/dev/demo/all.html
+++ b/dev/demo/all.html
@@ -15,7 +15,7 @@
 	<a href="#" class="login"><span>Login</span></a>
       </div>
 
-      <form autocomplete="off" action="/kalamar">
+      <form autocomplete="off" action="/kalamar" id="searchform">
 	<div id="searchbar">
 	  <input type="search"
 		 placeholder="Find ..."
@@ -25,9 +25,12 @@
 	  <button type="submit"><span>Go</span></button>
 	  <!-- <i class="fa fa-arrow-circle-down show-hint" onclick="hint.popUp()"></i> -->
 	</div>
-	<div id="vc-view"></div>
-	in <input type="hidden" id="vc-name" name="vc-name" value="Wikipedia" />
-	<input type="text" name="vc" id="vc" value="corpusID = Wikipedia" />
+
+        <!-- Search in the following virtual collection -->
+        <div id="vc-view"></div>
+        in
+        <input id="vc-name" name="vc-name" type="hidden" value>
+        <input id="collection" name="collection" type="text" value="">
 	with <span class="select">
 	  <!-- Change this to js-menu -->
 	  <select name="ql" id="ql-field">
diff --git a/dev/demo/alldemo.js b/dev/demo/alldemo.js
index 1bc0ddf..25aade7 100644
--- a/dev/demo/alldemo.js
+++ b/dev/demo/alldemo.js
@@ -532,10 +532,9 @@
   }
 });
 
-// KorAP.currentQuery = queryExample;
+KorAP.currentQuery = queryExample;
 
-require(['init'], function (init) {
-
+require(['app/en', 'init'], function (lang, init) {
   KorAP.hintArray = hintArray;
 
   // Set current virtual collection
diff --git a/dev/demo/vcdemo.js b/dev/demo/vcdemo.js
index 53ab75e..73cb805 100644
--- a/dev/demo/vcdemo.js
+++ b/dev/demo/vcdemo.js
@@ -64,6 +64,35 @@
   ]
 };
 
+var collections = [
+  {
+    "statistics":{
+      "paragraphs":2034752,
+      "documents":196510,
+      "tokens":51545081,
+      "sentences":4116282
+    },
+    "query":[
+      {
+	"@value":{
+	  "@field":"korap:field#corpusID",
+	  "@value":"WPD",
+	  "@type":"korap:term"
+	},
+	"@type":"korap:meta-filter"
+      }
+    ],
+    "name":"Wikipedia",
+    "path":"Wikipedia",
+    "description":"Die freie Enzyklopädie",
+    "shared":false,
+    "managed":true,
+    "created":"2015-04-01T23:04:32.000+02:00",
+    "foundries":"",
+    "id":"ZGU0ZTllNTFkYzc3M2VhZmViYzdkYWE2ODI5NDc3NTk4NGQ1YThhOTMwOTNhOWYxNWMwN2M3Y2YyZmE3N2RlNQ=="
+  }
+];
+
 require(['vc','lib/domReady', 'lib/highlight/highlight.pack'], function (vcClass, domReady) {
 
   var loc = KorAP.Locale;
diff --git a/dev/js/spec/matchSpec.js b/dev/js/spec/matchSpec.js
index 28eb844..1af080f 100644
--- a/dev/js/spec/matchSpec.js
+++ b/dev/js/spec/matchSpec.js
@@ -564,7 +564,7 @@
       expect(menu.element().style.opacity).toEqual("0");
       expect(menu.limit()).toEqual(6);
       menu.show();
-      expect(menu.item(0).active()).toBe(true);
+      expect(menu.item(0).active()).toBe(false);
     });
   });
 
diff --git a/dev/js/spec/menuSpec.js b/dev/js/spec/menuSpec.js
index 999ec2b..00fb8af 100644
--- a/dev/js/spec/menuSpec.js
+++ b/dev/js/spec/menuSpec.js
@@ -360,6 +360,7 @@
       ];
 
       var menu = KorAP.OwnMenu.create(list);
+      menu._firstActive = true;
       expect(menu.itemClass()).toEqual(KorAP.OwnMenuItem);
       expect(menu.element().nodeName).toEqual('UL');
       expect(menu.element().style.opacity).toEqual("0");
@@ -462,6 +463,7 @@
 
     it('should be nextable', function () {
       var menu = KorAP.HintMenu.create("cnx/", list);
+      menu._firstActive = true;
 
       // Show only 3 items
       menu.limit(3);
@@ -538,6 +540,7 @@
 
     it('should be prevable', function () {
       var menu = KorAP.HintMenu.create("cnx/", list);
+      menu._firstActive = true;
       menu.limit(3);
       expect(menu.show()).toBe(true);
 
@@ -626,6 +629,7 @@
 
     it('should be navigatable and filterable (prefix = "o")', function () {
       var menu = KorAP.HintMenu.create("cnx/", list);
+      menu._firstActive = true;
       menu.limit(2);
 
       expect(menu.prefix("o").show()).toBe(true);
@@ -680,6 +684,7 @@
 
     it('should be navigatable and filterable (prefix = "ex", "e")', function () {
       var menu = KorAP.HintMenu.create("cnx/", list);
+      menu._firstActive = true;
 
       menu.limit(2);
       expect(menu.prefix("ex").show()).toBe(true);
@@ -773,6 +778,8 @@
 
     it('should be navigatable with prefix', function () {
       var menu = KorAP.HintMenu.create("cnx/", demolist);
+      menu._firstActive = true;
+
       menu.limit(3);
 
       expect(menu.show()).toBe(true);
@@ -908,6 +915,8 @@
 
     it('should be navigatable with a prefix (1)', function () {
       var menu = KorAP.HintMenu.create("cnx/", demolist);
+      menu._firstActive = true;
+
       menu.limit(3);
 
       expect(menu.show()).toBe(true);
@@ -967,6 +976,8 @@
 
     it('should be navigatable with a prefix (2)', function () {
       var menu = KorAP.HintMenu.create("cnx/", demolist);
+      menu._firstActive = true;
+
       menu.limit(3);
       expect(menu.show()).toBe(true);
       expect(menu.prefix()).toEqual("");
@@ -1010,6 +1021,7 @@
 
     it('should be navigatable with a prefix (3)', function () {
       var menu = KorAP.HintMenu.create("cnx/", demolist);
+      menu._firstActive = true;
       menu.limit(3);
       expect(menu.show()).toBe(true);
       expect(menu.prefix()).toEqual("");
diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index d6493cb..87073d6 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -10,6 +10,9 @@
 
   KorAP.API = KorAP.API || {};
 
+  /**
+   * Retrieve information about a match
+   */
   KorAP.API.getMatchInfo = function (match, param, cb) {
 
     // match is a KorAP.Match object
@@ -38,6 +41,16 @@
     KorAP.API.getJSON(url, cb);
   };
 
+  /**
+   * Retrieve information about collections
+   */
+  KorAP.API.getCollections = function (cb) {
+    KorAP.API.getJSON(KorAP.URL + '/collection', cb);
+  };
+
+  /**
+   * General method to retrieve JSON information
+   */
   KorAP.API.getJSON = function (url, onload) {
     var req = new XMLHttpRequest();
 
diff --git a/dev/js/src/app/de.js b/dev/js/src/app/de.js
index f5be5ec..332ee07 100644
--- a/dev/js/src/app/de.js
+++ b/dev/js/src/app/de.js
@@ -1,26 +1,3 @@
-require(['init'], function () {
-  var loc = KorAP.Locale;
-  loc.OR = 'oder';
-  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';
-
-  // Date picker:
-  loc.WDAY = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
-  loc.MONTH = [
-    'Januar', 'Februar', 'März', 'April',
-    'Mai', 'Juni', 'Juli', 'August',
-    'September', 'Oktober', 'November',
-    'Dezember'
-  ];
-
-  // Match view
-  loc.ADDTREE  = 'Baumansicht hinzufügen';
-  loc.SHOWINFO = 'Informationen';
-  loc.CLOSE    = 'Schließen';
-});
+window.KorAP = window.KorAP || {};
+KorAP.Locale = KorAP.Locale || {};
+require(['loc/de','init']);
diff --git a/dev/js/src/app/en.js b/dev/js/src/app/en.js
index c7a4e5c..e851239 100644
--- a/dev/js/src/app/en.js
+++ b/dev/js/src/app/en.js
@@ -1 +1,3 @@
+window.KorAP = window.KorAP || {};
+KorAP.Locale = KorAP.Locale || {};
 require(['init']);
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index a414020..4e37a9b 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -21,6 +21,11 @@
   // Set hint array for hint helper
   KorAP.hintArray = hintArray;
 
+  // Localization values
+  var loc = KorAP.Locale;
+  loc.VC_allCorpora    = loc.VC_allCorpora  || 'all Corpora';
+  loc.VC_oneCollection = loc.VC_oneCollection  || 'one Collection';
+
   // Override KorAP.log
   window.alertify = alertifyClass;
   KorAP.log = function (code, msg) {
@@ -51,14 +56,16 @@
      * Replace Virtual Collection field
      */
     var vcname;
-    var input = document.getElementById('vc');
+    var input = document.getElementById('collection');
     if (input) {
       input.style.display = 'none';
       vcname = document.createElement('span');
       vcname.setAttribute('id', 'vc-choose');
+
       vcname.appendChild(
 	document.createTextNode(
-	  document.getElementById('vc-name').value
+	  document.getElementById('vc-name').value ||
+	  (KorAP.currentVC !== undefined) ? loc.VC_oneCollection : loc.VC_allCorpora
 	)
       );
       input.parentNode.insertBefore(vcname, input);
@@ -125,18 +132,8 @@
 
 	// The vc is not visible
 	else {
-	  // The vc is not rendered yet
-	  if (vc === undefined) {
-	    vc = vcClass.create([
-	      ['title', 'string'],
-	      ['subTitle', 'string'],
-	      ['pubDate', 'date'],
-	      ['author', 'string']
-	    ]);
-
-	    if (KorAP.currentVC !== undefined)
-	      vc.fromJson(KorAP.currentVC);
-	  };
+	  if (vc === undefined)
+	    vc = _getCurrentVC(vcClass);
 	  view.appendChild(vc.element());
 	  this.classList.add('active');
 	};
@@ -166,16 +163,33 @@
     // Initialize documentation links
     obj.tutorial.initDocLinks(document);
 
-/*
+    // There is a currentQuery
     if (KorAP.currentQuery !== undefined) {
-      var sb = document.getElementById('searchbar');
       var kq = document.createElement('div');
       kq.setAttribute('id', 'koralquery');
-      sb.parentNode.insertBefore(kq, sb.nextSibling);
-      kq.innerHTML = JSON.stringify(KorAP.currentQuery, null, '  ');
-      hljs.highlightBlock(kq);
+
+      var kqInner = document.createElement('div');
+      kq.appendChild(kqInner);
+      kqInner.innerHTML = JSON.stringify(KorAP.currentQuery, null, '  ');
+      hljs.highlightBlock(kqInner);
+
+      var sb = document.getElementById('search');
+      sb.insertBefore(kq, sb.firstChild);
     };
-*/
+
+    /**
+     * Add VC creation on submission.
+     */
+    var form = document.getElementById('searchform');
+    if (form !== undefined) {
+      form.addEventListener('submit', function (e) {
+	if (vc === undefined)
+	  vc = _getCurrentVC(vcClass);
+
+	if (vc !== undefined)
+	  input.value = vc.toQuery();
+      });
+    };
 
     /**
      * Init hint helper
@@ -189,3 +203,20 @@
     return obj;
   });
 });
+
+// Render Virtual collection
+// TODO:: Use currentQuery!!!
+function _getCurrentVC (vcClass) {
+  var vc = vcClass.create([
+    ['title', 'string'],
+    ['subTitle', 'string'],
+    ['pubDate', 'date'],
+    ['author', 'string'],
+    ['corpusID', 'string']
+  ]);
+  if (KorAP.currentVC !== undefined)
+    vc.fromJson(KorAP.currentVC);
+
+  return vc;
+};
+
diff --git a/dev/js/src/loc/de.js b/dev/js/src/loc/de.js
new file mode 100644
index 0000000..a9eb389
--- /dev/null
+++ b/dev/js/src/loc/de.js
@@ -0,0 +1,28 @@
+define(function () {
+  var loc = KorAP.Locale;
+  loc.OR = 'oder';
+  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';
+  loc.VC_allCorpora = 'allen Korpora';
+  loc.VC_oneCollection = 'einer Kollektion';
+
+  // Date picker:
+  loc.WDAY = ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So'];
+  loc.MONTH = [
+    'Januar', 'Februar', 'März', 'April',
+    'Mai', 'Juni', 'Juli', 'August',
+    'September', 'Oktober', 'November',
+    'Dezember'
+  ];
+
+  // Match view
+  loc.ADDTREE  = 'Baumansicht hinzufügen';
+  loc.SHOWINFO = 'Informationen';
+  loc.CLOSE    = 'Schließen';
+});
diff --git a/dev/js/src/util.js b/dev/js/src/util.js
index 9a1f884..f17ec2a 100644
--- a/dev/js/src/util.js
+++ b/dev/js/src/util.js
@@ -37,6 +37,7 @@
 
 
 define(function () {
+  // Todo: That's double now!
   KorAP.API = KorAP.API || {};
   KorAP.Locale = KorAP.Locale || {};
 
diff --git a/dev/js/src/vc/chooseitem.js b/dev/js/src/vc/chooseitem.js
new file mode 100644
index 0000000..81ee4ca
--- /dev/null
+++ b/dev/js/src/vc/chooseitem.js
@@ -0,0 +1,89 @@
+define(['menu/item', 'util'], function (itemClass) {
+
+  var loc = KorAP.Locale;
+
+  return {
+
+    /**
+     * Create new menu item.
+     * Pass two parameters: value and type.
+     * the value may be localized by a name in
+     * KorAP.Locale with the prefix 'VC_',
+     * e.g. 'VC_subTitle'.
+     */
+    create : function (params) {
+      return Object.create(itemClass)
+	.upgradeTo(this)
+	._init(params);
+    },
+
+    // Initialize item object
+    _init : function (params) {
+      if (params[0] === undefined)
+	throw new Error("Missing parameters");
+      
+      this._id  = params[0];
+      this._name = params[1];
+      this._desc  = params[2];
+
+      this._lcField =  ' ' + this._name.toLowerCase();
+      this._lcField += ' ' + this._desc.toLowerCase();
+
+      return this;
+    },
+
+    /**
+     * Override click event by passing all clicks
+     * to the menu object.
+     */
+    onclick : function (e) {
+      this.menu().release(
+	this._id,
+	this._name
+      );
+      e.halt();
+    },
+
+    /**
+     * Get the name of the item.
+     */
+    name : function () {
+      return this._name;
+    },
+
+    /**
+     * Get the identifier of the item.
+     */
+    id : function () {
+      return this._id;
+    },
+
+    /**
+     * Get the description of the item.
+     */
+    desc : function () {
+      return this._desc;
+    },
+
+    /**
+     * Get the HTML element associated with the item. 
+     */
+    element : function () {
+
+      // already defined
+      if (this._element !== undefined)
+	return this._element;
+
+      // Create list item
+      var li = document.createElement("li");
+      li.setAttribute("data-type", this._type);
+      li.setAttribute("data-key",  this._key);
+
+      // Connect action
+      li["onclick"] = this.onclick.bind(this);
+
+      li.ap   pendChild(document.createTextNode(this._name));
+      return this._element = li;
+    }
+  }
+});
diff --git a/dev/js/src/vc/choosemenu.js b/dev/js/src/vc/choosemenu.js
new file mode 100644
index 0000000..7e00d44
--- /dev/null
+++ b/dev/js/src/vc/choosemenu.js
@@ -0,0 +1,21 @@
+/**
+ * Menu showing all predefined virtual collections.
+ * THIS IS EXPERIMENTAL AND MAY BE REMOVED!
+ */
+define(['vc/menu', 'api'], function (menuClass, itemClass) {
+  return {
+    create : function (params) {
+      return Object.create(menuClass)
+	.upgradeTo(this)
+	._init(itemClass, undefined, params);
+    },
+
+    /**
+     * A click event was released
+     */
+    release : function (id, name) {
+      if (this._cb !== undefined)
+	this._cb(id, name);
+    }
+  };
+}); 
diff --git a/dev/scss/header/searchbar.scss b/dev/scss/header/searchbar.scss
index e0f241e..d383e73 100644
--- a/dev/scss/header/searchbar.scss
+++ b/dev/scss/header/searchbar.scss
@@ -74,21 +74,6 @@
   }
 }
 
-#koralquery {
-  margin-top: 10px;
-  margin-right: 40px;
-  border: {
-    radius: $standard-border-radius;
-    color: $dark-green;
-    style: solid;
-    width: $border-size;
-  }
-  white-space: pre;
-  background-color: $nearly-white;
-  color: $dark-grey;
-}
-
-
 /**
  * Checkbox styling
  * http://stackoverflow.com/questions/4148499/how-to-style-checkbox-using-css
diff --git a/dev/scss/header/vc.scss b/dev/scss/header/vc.scss
index 559a982..45899da 100644
--- a/dev/scss/header/vc.scss
+++ b/dev/scss/header/vc.scss
@@ -218,10 +218,11 @@
   div.value {
     position: absolute;
     display: inline-block;
+    z-index: 8000;
     @include choose-item;
     box-shadow: $choose-box-shadow;
     padding: 4pt;
-    margin-top: -2pt;
+    margin-top: -6pt;
     border: {
       width: $border-size;
       style: solid;
@@ -302,7 +303,7 @@
   }
 }
 
-#vc {
+#collection {
   line-height: 1em;
   border-radius: $standard-border-radius;
 }
diff --git a/dev/scss/main/koralquery.scss b/dev/scss/main/koralquery.scss
new file mode 100644
index 0000000..d569d77
--- /dev/null
+++ b/dev/scss/main/koralquery.scss
@@ -0,0 +1,19 @@
+@charset "utf-8";
+@import "../util";
+
+$border-size: 2px;
+
+#koralquery {
+  border: 1px solid $kwic-border;
+  white-space: pre;
+  background-color: $dark-orange;
+  > div {
+    background-color: $nearly-white;
+    margin: {
+      top: 2pt;
+      right: $right-match-distance; // 3em;
+      bottom: 2pt;
+      left: 2pt;
+    }
+  }
+}
diff --git a/dev/scss/main/main.scss b/dev/scss/main/main.scss
index f0ff84b..2bd308d 100644
--- a/dev/scss/main/main.scss
+++ b/dev/scss/main/main.scss
@@ -7,6 +7,7 @@
 @import "resultinfo"; // Information on results
 @import "sidebar";    // Navigation on the left side
 @import "tutorial";   // Embedded and non-embedded tutorial
+@import "koralquery"; // KoralQuery
 @import "alertify";
 
 div.intro {
diff --git a/kalamar.conf b/kalamar.conf
index dc3c5f0..18c7d0a 100644
--- a/kalamar.conf
+++ b/kalamar.conf
@@ -1,15 +1,12 @@
 {
-  Kalamar => {
-    'api-0.1' => 'http://10.0.10.13:7070/api/v0.1/'
-  },
   Notifications => {
     'Kalamar::Plugin::Notifications' => 1,
     JSON => 1
   },
   Search => {
     engine => 'Kalamar::API',
-#    api => 'http://10.0.10.13:7070/api/v0.1/'
-    api => 'http://localhost:9999/api/v0.1/'
+    api => 'http://10.0.10.13:7070/api/v0.1/'
+#    api => 'http://localhost:9999/api/v0.1/'
   },
   CHI => {
     default => {
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 60833a8..7369598 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -82,6 +82,10 @@
   # Base query route
   $r->get('/')->to('search#query')->name('index');
 
+  # Collection route
+  $r->get('/collection')->to('Search#collections')->name('collections');
+  $r->get('/collection/:id')->to('Search#collection')->name('collection');
+
   # Documentation routes
   $r->get('/doc')->to('documentation#page', page => 'korap')->name('doc_start');
   $r->get('/doc/:page')->to('documentation#page', scope => undef);
@@ -97,6 +101,9 @@
   my $text   = $doc->get('/:text_id');
   my $match  = $text->get('/:match_id');
   $match->to('search#match_info')->name('match');
+
+  # Default user is called 'korap'
+  # $r->route('/user/:user/:collection')
 };
 
 
diff --git a/lib/Kalamar/API.pm b/lib/Kalamar/API.pm
index ab4cabe..4ae79e3 100644
--- a/lib/Kalamar/API.pm
+++ b/lib/Kalamar/API.pm
@@ -27,7 +27,8 @@
 			 _api_cache
 			 api_response
 			 benchmark
-			 query_jsonld/]);
+			 query_jsonld
+			 collection_jsonld/]);
   $index_class->attr(no_cache => 0);
 };
 
@@ -347,7 +348,85 @@
 
   # Set result values
   $index->items_per_page($json->{itemsPerPage});
-  $index->query_jsonld($json->{request}->{query});
+
+  # Bouncing query
+  if ($json->{query}) {
+    $index->query_jsonld($json->{query});
+  }
+  # Legacy
+  elsif ($json->{request}->{query}) {
+    $index->query_jsonld($json->{request}->{query});
+  };
+
+  # Temporary:
+  my $collection_query = {
+    '@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"
+      }
+    ]
+  };
+
+
+  # Bouncing collection query
+  if ($json->{collection}) {
+    $index->collection_jsonld($json->{collection});
+  }
+
+  # Legacy
+  elsif ($json->{request}->{collection}) {
+    $index->collection_jsonld($json->{request}->{collection});
+  };
+
+  # Temp
+  $index->collection_jsonld($collection_query);
+
   $index->results(_map_matches($json->{matches}));
 
   # Total results not set by stash
diff --git a/lib/Kalamar/Controller/Search.pm b/lib/Kalamar/Controller/Search.pm
index c0c3e6e..8445c9f 100644
--- a/lib/Kalamar/Controller/Search.pm
+++ b/lib/Kalamar/Controller/Search.pm
@@ -121,6 +121,23 @@
 };
 
 
+# Get information about collections
+sub collections {
+  my $c = shift;
+
+  # Async
+  $c->render_later;
+
+  # Get resource (for all)
+  $c->search->resource(
+    type => 'collection',
+    sub {
+      my $notes = $c->notifications(json => $c->stash('search.resource'));
+      return $c->render(json => $notes);
+    }
+  );
+};
+
 1;
 
 
diff --git a/templates/partial/header.html.ep b/templates/partial/header.html.ep
index a090b76..017d818 100644
--- a/templates/partial/header.html.ep
+++ b/templates/partial/header.html.ep
@@ -7,17 +7,18 @@
        title="<%= loc 'login' %>"><span><%= loc 'login' %></span></a>
 -->
   </div>
-  <form autocomplete="off" action="<%= url_for 'index' %>">
+  <form autocomplete="off" action="<%= url_for 'index' %>" id="searchform">
     <div id="searchbar">
       %= search_field 'q', id => 'q-field', autofocus => 'autofocus', placeholder => loc('searchplaceholder'), spellcheck => 'false', autocomplete => 'off', autocorrect => 'off', autocapitalize => 'off'
       <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' %>
+    %= hidden_field 'vc-name' => stash('vc-name'), id => 'vc-name' 
+    %= text_field 'collection', id => 'collection'
+
     <%= 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..47ec86a 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,16 +17,23 @@
 % };
 </div>
 
-% if (search->total_results != 0 && search->results->size) {
+% if (search->collection_jsonld) {
+%=  javascript begin
+KorAP.currentVC = <%== encode_json search->collection_jsonld %>;
+%   end
+% };
+
+
 <div id="search">
+% if (search->total_results != 0 && search->results->size) {
   <ol class="align-left">
 %=  search_results begin
 %=    include 'match', match => $_
 %   end
   </ol>
-</div>
 % } else {
 <p id="no-results"><%== loc 'noMatches', q => search->query %></p>
 % }
+</div>
 
 %= include 'query'