Add javascript plugin capabilities

Change-Id: I36af515651adbb5a2c20eca14f8a3d2b16ccfa69
diff --git a/.gitignore b/.gitignore
index 5baa59d..7ba9c90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
-db
\ No newline at end of file
+db
+sandbox
+todo.org
\ No newline at end of file
diff --git a/assets/mainfest.json b/assets/mainfest.json
new file mode 100644
index 0000000..f24a032
--- /dev/null
+++ b/assets/mainfest.json
@@ -0,0 +1,13 @@
+{
+  "name" : "Externak Sale",
+  "desc" : "Buy content from an external provider",
+  "embed" : [{
+    "panel" : "match",
+    "title" : "Buy",
+    "classes" : ["cart"],
+    "onClick" : {
+      "action" : "addWidget",
+      "template" : "http://localhost:3003/demo/plugin-client.html"
+    }
+  }]
+}
\ No newline at end of file
diff --git a/service.go b/service.go
index 5d82e15..2e641d6 100644
--- a/service.go
+++ b/service.go
@@ -72,7 +72,6 @@
 
 	r.GET("/index", func(c *gin.Context) {
 		c.HTML(http.StatusOK, "main.html", gin.H{
-			"title":       "External Sale Plugin",
 			"korapServer": "https://korap.ids-mannheim.de/",
 		})
 	})
diff --git a/service_test.go b/service_test.go
index 5527c31..1a1d468 100644
--- a/service_test.go
+++ b/service_test.go
@@ -45,5 +45,5 @@
 
 	assert.Equal(t, http.StatusOK, w.Code)
 	assert.Contains(t, w.Body.String(), "data-server=\"https://korap.ids-mannheim.de/\"")
-	assert.Contains(t, w.Body.String(), "<title>External Sale Plugin</title>")
+	assert.Contains(t, w.Body.String(), "<title>External Sale</title>")
 }
diff --git a/templates/main.html b/templates/main.html
index 3b41330..3898767 100644
--- a/templates/main.html
+++ b/templates/main.html
@@ -1,9 +1,42 @@
 <!DOCTYPE html>
 <html>
   <head>
+    <title>External Sale</title>
     <script data-server="{{ .korapServer }}" src="client.js"></script>
-    <title>{{ .title }}</title>
+    <script><!--
+"use strict";
+
+function pluginit(P) {
+
+  // Request metadata from the embedding match
+  P.requestMsg(
+    {
+      'action':'get',
+      'key':'textSigle'
+    }, function (d) {
+      var textSigle = d.value.value;
+      var xhttp = new XMLHttpRequest();
+      xhttp.onload = function() {
+        document.getElementById("buy").innerHTML = this.responseText;
+        P.resize();
+      }
+      xhttp.open("GET", textSigle, true);
+      xhttp.send();
+    }
+  );
+
+  if (window.dynCall) {
+    window.dynCall(P)
+  };
+
+  // Set plugin object globally
+  window.Plugin = P;
+
+};
+-->
+    </script>
   </head>
   <body>
+    <p id="buy">...</p>
   </body>
 </html>