make KorAP instance configurable

see example.conf

Change-Id: Ia6ece608272cf21efba29e23f948434164487f3d
diff --git a/example.conf b/example.conf
index cf8a324..4991015 100644
--- a/example.conf
+++ b/example.conf
@@ -13,7 +13,8 @@
   },
 
   w2v => {
-    vecs => "example-models/wpd19_10000/wpd19_10000.vecs"
+    vecs => "example-models/wpd19_10000/wpd19_10000.vecs",
+    # korap_url => "https://korap.ids-mannheim.de"
   },
 
   downtime_calendar_url => "https://cloud.ids-mannheim.de/remote.php/dav/public-calendars/QfRCG4HriLcZJJRd?export",
diff --git a/js/derekovecs.js b/js/derekovecs.js
index f30cd27..2b4d1bc 100644
--- a/js/derekovecs.js
+++ b/js/derekovecs.js
@@ -1,10 +1,5 @@
-function queryKorAPpoliqarp(query) {
-    window.open('http://korap.ids-mannheim.de/kalamar/?ql=poliqarp&q='+encodeURIComponent(query), 'KorAP');
-}
-
-
 function queryKorAPalternatives(alt1, alt2) {
-    queryKorAPpoliqarp("{1:[orth="+ alt1 +"]} | {2:[orth=" + alt2 +"]}");
+    queryKorAP("{1:[orth="+ alt1 +"]} | {2:[orth=" + alt2 +"]}");
 }
 
 function paradigmatorClick(e, target, paradigmator) {
diff --git a/script/derekovecs-server b/script/derekovecs-server
index dfabae7..75b29b4 100755
--- a/script/derekovecs-server
+++ b/script/derekovecs-server
@@ -16,6 +16,8 @@
 plugin Config => {file => $mojo_config};
 
 my $DEFAULT_VECS = app->config->{w2v}->{vecs} // "../models/dereko-2021-i.vecs";
+my $KORAP_URL = app->config->{w2v}->{korap_url} // "https://korap.ids-mannheim.de";
+
 my $DEFAULT_NET_NAME = "";
 if ($DEFAULT_VECS=~ /\.vecs/) {
   $DEFAULT_NET_NAME = $DEFAULT_VECS;
@@ -406,6 +408,7 @@
       lists                => \@lists,
       collocators          => $res->{syntagmatic},
       version              => $VERSION,
+      korap_url            => $KORAP_URL,
     );
   }
 } => "paradigmaticAndSyntagmaticNbs";
diff --git a/templates/index.html.ep b/templates/index.html.ep
index 6d1827f..873c0a7 100644
--- a/templates/index.html.ep
+++ b/templates/index.html.ep
@@ -116,7 +116,7 @@
        function changeCharColor(txt, heat, word) {
          var newText = "";
          for (var i=0, l=txt.length; i<l; i++) {
-           newText += (i == 5 ? txt.charAt(i) : '<a href="http://korap.ids-mannheim.de' + korapPath + '/?ql=cosmas2&q=' +
+           newText += (i == 5 ? txt.charAt(i) : "<a href=\"<%= $korap_url  %>" + korapPath + '/?ql=cosmas2&q=' +
                                                 CIIsearchWords + ' /' +  (i > 5? '%2B' : '-') + 'w' +
                                                 Math.abs(i-5) + ':' +  Math.abs(i-5) + ',s0 ' + word + korapVC +
                                                 '" target="korap"><span style="background-color:' +
@@ -699,12 +699,13 @@
      }
 
      function queryKorAP() {
-       window.open('http://korap.ids-mannheim.de' + korapPath + '?q='+queryword.value+korapVC, 'KorAP');
+       window.open("<%= $korap_url  %>" + korapPath + '?q='+queryword.value+korapVC, 'KorAP');
      }
 
      function queryKorAPCII(query) {
-       window.open('http://korap.ids-mannheim.de' +korapPath + '?ql=cosmas2&q='+query+korapVC, 'KorAP');
+       window.open("<%= $korap_url  %>" +korapPath + '?ql=cosmas2&q='+query+korapVC, 'KorAP');
      }
+
     </script>
   </head>
   <body onload="onload()">    <div style="display:none;" id="pmi_ttt">Pointwise mutual information: $$\text{MI}=\text{MI}=\log_2\frac{p(w_1,w_2)}{p(w_1) p(w_2)}$$<p class="citation">Church, K. W. and Hanks, P. (1990): Word association norms, mutual information, and lexicography. Comput. Linguist. 16, 1 (March 1990), 22-29.</p></div>