Minor changes to the UI and fixes to empty corpus queries

Change-Id: If9dce8fd2cdfe441a6637d6caaaa334e6921d420
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java
index 51bfb7a..eab7f3d 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/IdsExportService.java
@@ -55,6 +55,7 @@
  * - Add hitc to form.
  * - Add infos to JsonExporter.
  * - Add date info.
+ * - Adjust count, if hitc < count.
  */
 
 @Path("/")
@@ -173,7 +174,7 @@
             .queryParam("ql", ql)
             ;
 
-        if (cq != null)
+        if (cq != null && cq.length() > 0)
             uri = uri.queryParam("cq", cq);
         
         if (path != "") {
@@ -204,6 +205,7 @@
             resp = authBuilder(reqBuilder, xff, auth).get(String.class);
             
         } catch (Exception e) {
+            System.err.println("Unable to reach: " + uri.build());
             throw new WebApplicationException(
                 responseForm(Status.BAD_GATEWAY, "Unable to reach Backend")
                 );
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java
index 8bbd366..d51c2e7 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/PluginServer.java
@@ -60,7 +60,7 @@
                 properties.getProperty("api.scheme") +
                 "://" +
                 properties.getProperty("api.host") +
-                properties.getProperty("api.path") + ":" +
+                properties.getProperty("api.path","") + ":" +
                 properties.getProperty("api.port")
                 );
             jettyServer.join();
diff --git a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
index b3aa445..7c0f7bc 100644
--- a/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
+++ b/plugin/src/main/java/de/ids_mannheim/korap/plkexport/RtfExporter.java
@@ -148,13 +148,16 @@
 
     private void addInfoTable (Writer w) throws IOException {
 
+        String q = this.getQueryString();
+
         // Add Information table
-        if (this.getQueryString() != null) {
+        if (q != null && q.length() > 0) {
             this.addInfoRow(w, "Query", this.getQueryString());
         };
 
-        if (this.getCorpusQueryString() != null) {
-            this.addInfoRow(w, "Corpus", this.getCorpusQueryString());
+        q = this.getCorpusQueryString();
+        if (q != null && q.length() > 0) {
+            this.addInfoRow(w, "Corpus", q);
         };
 
         if (this.getTotalResults() != -1) {
@@ -175,8 +178,9 @@
             this.addInfoRow(w, "Fetched", this.getMaxResults());
         };
 
-        if (this.getSource() != null) {
-            this.addInfoRow(w, "Source", this.getSource());
+        q = this.getSource();
+        if (q != null && q.length() > 0) {
+            this.addInfoRow(w, "Source", q);
         };
 
         if (this.getMeta() != null && this.getMeta().has("version")) {
diff --git a/plugin/src/main/resources/assets/templates/export.ftl b/plugin/src/main/resources/assets/templates/export.ftl
index da0046c..5633e22 100644
--- a/plugin/src/main/resources/assets/templates/export.ftl
+++ b/plugin/src/main/resources/assets/templates/export.ftl
@@ -16,29 +16,35 @@
           <input type="hidden"  id="q" name="q">
           <input type="hidden" id="ql" name="ql">
           <input type="hidden" id="cq" name="cq">
-          
+
           <fieldset class="form-line">
             <legend>Dateiformat</legend>
-            <input type="radio" id="formatjson" name="format" value="json">
-            <label for="formatjson">JSON</label>
-            
-            <input type="radio" checked="checked" id="formathtml" name="format" value="rtf">  
-            <label for="formatrtf">RTF</label>
+
+            <div style="margin-top: 1em">
+              <input type="radio" checked="checked" id="formathtml" name="format" value="rtf" style="vertical-align: top">
+              <label for="formatrtf">
+                RTF
+                <br /><span style="font-size:8pt">Rich Text Format (Word etc.)</span>
+              </label>
+            </div>
+
+            <div style="margin-top: 1em">
+              <input type="radio" id="formatjson" name="format" value="json" style="vertical-align: top">
+              <label for="formatjson">
+                JSON
+                <br /><span style="font-size:8pt">Programmierung (JavaScript etc.)</span>
+              </label>
+            </div>
           </fieldset>
 
-          <!--
-              <div>
-                <label>
-                  <input type="checkbox" name="islimit" checked="checked" value="limited">
-                  Beschränken auf 
-                  <input name="hitc" type="number" min="1" max="1000" value="20">
-                  Treffer 
-                </label>
-              </div>
-              -->
-          <input type="submit" value="Exportieren">
+          <!-- <input type="checkbox" name="islimit" checked="checked" value="limited"> -->
+          
+          <fieldset class="form-line">
+            <legend>Zu exportierender Treffer</legend>
+            <input name="hitc" id="hitc" type="number" min="1" max="10000" value="20" />
+          </fieldset>
 
-          <p style="font-size: 80%">Das Export-Plugin befindet sich noch in einer experimentellen Phase. Derzeit können nur die ersten 50 Treffer exportiert werden.</p>
+          <input type="submit" value="Exportieren">
 
         </fieldset>
       </form>