Turned code templates into embedded static assets and draft config page

Change-Id: Ifcab25a9620b9b8dde3a3b26b2420dbbc5b15fdd
diff --git a/cmd/koralmapper/static/config.html b/cmd/koralmapper/static/config.html
new file mode 100644
index 0000000..a946501
--- /dev/null
+++ b/cmd/koralmapper/static/config.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>{{.Title}}</title>
+    <link rel="stylesheet" href="/static/style.css">
+    <script src="{{.SDK}}"
+            data-server="{{.Server}}"></script>
+</head>
+<body>
+    <div class="container" data-service-url="{{.ServiceURL}}">
+        <h1>{{.Title}}</h1>
+        <p>{{.Description}}</p>
+
+        {{if .AnnotationMappings}}
+        <section class="mapping-section">
+            <h2>Query</h2>
+            {{range .AnnotationMappings}}
+            <div class="mapping" data-id="{{.ID}}" data-type="annotation"
+                 data-default-foundry-a="{{.FoundryA}}" data-default-layer-a="{{.LayerA}}"
+                 data-default-foundry-b="{{.FoundryB}}" data-default-layer-b="{{.LayerB}}">
+                <h3>{{.ID}}</h3>
+                {{if .Description}}<p class="desc">{{.Description}}</p>{{end}}
+                <div class="mapping-row">
+                    <label><input type="checkbox" class="request-cb" name="request"> Request:</label>
+                    <input type="text" class="foundryA" value="{{.FoundryA}}" size="8">/<input type="text" class="layerA" value="{{.LayerA}}" size="4">
+                    <button type="button" class="dir-arrow" data-dir="atob">&rarr;</button>
+                    <input type="text" class="foundryB" value="{{.FoundryB}}" size="8">/<input type="text" class="layerB" value="{{.LayerB}}" size="4">
+                </div>
+                <div class="mapping-row">
+                    <label><input type="checkbox" class="response-cb" name="response"> Response:</label>
+                    <input type="text" class="foundryA" value="{{.FoundryA}}" size="8">/<input type="text" class="layerA" value="{{.LayerA}}" size="4">
+                    <button type="button" class="dir-arrow" data-dir="atob">&rarr;</button>
+                    <input type="text" class="foundryB" value="{{.FoundryB}}" size="8">/<input type="text" class="layerB" value="{{.LayerB}}" size="4">
+                </div>
+            </div>
+            {{end}}
+        </section>
+        {{end}}
+
+        {{if .CorpusMappings}}
+        <section class="mapping-section">
+            <h2>Corpus</h2>
+            {{range .CorpusMappings}}
+            <div class="mapping" data-id="{{.ID}}" data-type="corpus">
+                <h3>{{.ID}}</h3>
+                {{if .Description}}<p class="desc">{{.Description}}</p>{{end}}
+                <div class="mapping-row">
+                    <label><input type="checkbox" class="request-cb" name="request"> Request</label>
+                </div>
+                <div class="mapping-row">
+                    <label><input type="checkbox" class="response-cb" name="response"> Response</label>
+                </div>
+            </div>
+            {{end}}
+        </section>
+        {{end}}
+
+        <h2>Plugin Information</h2>
+        <p><strong>Version:</strong> <tt>{{.Version}}</tt></p>
+        <p><strong>Build Date:</strong> <tt>{{.Date}}</tt></p>
+        <p><strong>Build Hash:</strong> <tt>{{.Hash}}</tt></p>
+    </div>
+    <script src="/static/config.js"></script>
+</body>
+</html>
diff --git a/cmd/koralmapper/static/config.js b/cmd/koralmapper/static/config.js
new file mode 100644
index 0000000..3918c74
--- /dev/null
+++ b/cmd/koralmapper/static/config.js
@@ -0,0 +1 @@
+"use strict";
diff --git a/cmd/koralmapper/static/plugin.html b/cmd/koralmapper/static/plugin.html
new file mode 100644
index 0000000..2000c06
--- /dev/null
+++ b/cmd/koralmapper/static/plugin.html
@@ -0,0 +1,76 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>{{.Title}}</title>
+    <script src="{{.SDK}}"
+            data-server="{{.Server}}"></script>
+</head>
+<body>
+    <div class="container">
+        <h1>{{.Title}}</h1>
+        <p>{{.Description}}</p>
+
+        <p>Map ID: {{.MapID}}</p>
+
+        <h2>Plugin Information</h2>
+        <p><strong>Version:</strong> <tt>{{.Version}}</tt></p>
+        <p><strong>Build Date:</strong> <tt>{{.Date}}</tt></p>
+        <p><strong>Build Hash:</strong> <tt>{{.Hash}}</tt></p>
+
+        <h2>Available API Endpoints</h2>
+        <dl>
+            <dt><tt><strong>GET</strong> /:map</tt></dt>
+            <dd><small>Kalamar integration</small></dd>
+
+            <dt><tt><strong>POST</strong> /:map/query</tt></dt>
+            <dd><small>Transform JSON query objects using term mapping rules</small></dd>
+
+            <dt><tt><strong>POST</strong> /:map/response</tt></dt>
+            <dd><small>Transform JSON response objects using term mapping rules</small></dd>
+        </dl>
+
+        <h2>Available Term Mappings</h2>
+        <dl>
+            {{range .Mappings}}
+            <dt><tt>{{.ID}}</tt></dt>
+            <dd>{{.Description}}</dd>
+            {{end}}
+        </dl>
+    </div>
+
+    <script>
+      <!-- activates/deactivates Mapper. -->
+      let qdata = {
+        'action'  : 'pipe',
+        'service' : '{{.QueryURL}}'
+      };
+
+      let rdata = {
+        'action'  : 'pipe',
+        'service' : '{{.ResponseURL}}'
+      };
+
+      function pluginit (p) {
+        p.onMessage = function(msg) {
+          if (msg.key == 'koralmapper') {
+            if (msg.value) {
+              qdata['job'] = 'add';
+            }
+            else {
+              qdata['job'] = 'del';
+            };
+            KorAPlugin.sendMsg(qdata);
+            if (msg.value) {
+              rdata['job'] = 'add-after';
+            }
+            else {
+              rdata['job'] = 'del-after';
+            };
+            KorAPlugin.sendMsg(rdata);
+          };
+        };
+      };
+    </script>
+</body>
+</html>
diff --git a/cmd/koralmapper/static/style.css b/cmd/koralmapper/static/style.css
new file mode 100644
index 0000000..693ce9b
--- /dev/null
+++ b/cmd/koralmapper/static/style.css
@@ -0,0 +1 @@
+body { font-family: sans-serif; }