Add max_hitc to the form and make default_hitc configurable

Change-Id: Iae2061baedf2cecf4c7202d2ebb7a79a915d5511
diff --git a/.gitignore b/.gitignore
index 17e9f15..1458039 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@
 dependency-reduced-pom.xml
 /sandbox
 /Sandbox
-/target
\ No newline at end of file
+/target
+/plugin
\ No newline at end of file
diff --git a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
index be090b0..26b246c 100644
--- a/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
+++ b/src/main/java/de/ids_mannheim/korap/plkexport/Service.java
@@ -59,11 +59,10 @@
 /**
  * TODO for release:
  * - Rename to "Kalamar-Plugin-Export".
- * - Remove 'plugin' root folder.
- * - 100 matches as default for export form.
  * - Improve Readme.
  * - Add opaque source, in case source is an internal IP.
  * - Include limitation to form.
+ * - Localize javascript induced "with" in the title.
  *
  * TODO:
  * - Localize RTF export.
@@ -667,6 +666,8 @@
         String port = prop.getProperty("asset.port", "");
         String host = prop.getProperty("asset.host", "korap.ids-mannheim.de");
         String path = prop.getProperty("asset.path", "");
+        String defaultHitc = prop.getProperty("conf.default_hitc", "100");
+        int maxHitc = Integer.parseInt(prop.getProperty("conf.max_exp_limit", "10000"));
 
         UriBuilder uri = UriBuilder.fromPath("")
             .host(host)
@@ -679,6 +680,8 @@
             uri = uri.port(Integer.parseInt(port));
 
         templateData.put("assetPath", uri.build());
+        templateData.put("defaultHitc", defaultHitc);
+        templateData.put("maxHitc", maxHitc);
 
         // There is an error code to pass
         if (code != null) {
diff --git a/src/main/resources/assets/templates/export.ftl b/src/main/resources/assets/templates/export.ftl
index 748a878..4f6c481 100644
--- a/src/main/resources/assets/templates/export.ftl
+++ b/src/main/resources/assets/templates/export.ftl
@@ -107,7 +107,8 @@
 
           <fieldset class="form-line">
             <legend>${dict.hitc}</legend>
-            <input name="hitc" id="hitc" type="number" min="1" max="10000" value="20" />
+            <input name="hitc" id="hitc" type="number" min="1" max="10000" value="${defaultHitc}" />
+            <p style="font-size: 80%">${dict.max_hitc} <tt>${maxHitc}</tt></p>
           </fieldset>
 
           <progress id="progress" value="0" max="100" style="display: none;">0%</progress>
diff --git a/src/main/resources/exportPlugin.conf b/src/main/resources/exportPlugin.conf
index 96d0ddb..a76c44d 100644
--- a/src/main/resources/exportPlugin.conf
+++ b/src/main/resources/exportPlugin.conf
@@ -31,6 +31,8 @@
 # conf.file_dir=./files/
 # Defaults to the system's temp directory
 
+conf.default_hitc = 100
+
 #####################
 # RTF configuration #
 #####################
diff --git a/src/main/resources/locales/export.properties b/src/main/resources/locales/export.properties
index 221e9ba..bb54079 100644
--- a/src/main/resources/locales/export.properties
+++ b/src/main/resources/locales/export.properties
@@ -1,5 +1,6 @@
 export = Export
 file_format = File format
 hitc = Limit to the first matches:
+max_hitc = Maximum number of exportable matches:
 export_button = Exportieren
 banner = Experimental
\ No newline at end of file
diff --git a/src/main/resources/locales/export_de.properties b/src/main/resources/locales/export_de.properties
index e70ed27..e454d15 100644
--- a/src/main/resources/locales/export_de.properties
+++ b/src/main/resources/locales/export_de.properties
@@ -4,5 +4,6 @@
 
 file_format = Dateiformat
 hitc = Einschr\u00e4nken auf die ersten Treffer:
+max_hitc = Maximal zu exportierende Treffer:
 export_button = Exportieren
 banner = Experimentell
\ No newline at end of file
diff --git a/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java b/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
index a3dc27b..b6f1336 100644
--- a/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
+++ b/src/test/java/de/ids_mannheim/korap/plkexport/AssetTest.java
@@ -67,6 +67,30 @@
         assertTrue("HTTP Body (de)", str.contains("Dateiformat"));
     };
 
+    @Test
+    public void testFormHtmlMaxHitc () {
+
+        // Check german
+        Response responsehtml = target("/export").request()
+            .header("Accept-Language","fr-CH, fr;q=0.9, de;q=0.8, en;q=0.7, *;q=0.5").get();
+        assertEquals("HTTP Code",
+                     Status.OK.getStatusCode(), responsehtml.getStatus());
+        String str = responsehtml.readEntity(String.class);
+        assertTrue("HTTP Body (de)", str.contains("value=\"100\""));
+        assertTrue("HTTP Body (de)", str.contains("Maximal zu exportierende Treffer: <tt>10.000</tt>"));
+
+        
+        // Check English
+        responsehtml = target("/export").request()
+            .header("Accept-Language","fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5").get();
+        assertEquals("HTTP Code",
+                     Status.OK.getStatusCode(), responsehtml.getStatus());
+        str = responsehtml.readEntity(String.class);
+        assertTrue("HTTP Body (en)", str.contains("Maximum number of exportable matches: <tt>10.000</tt>"));
+
+    };
+
+    
     
     @Test
     public void testFormHtmlAssets () {