Add configurable Kalamar integration

Change-Id: Ic07423dd7cc605509a364154bf4f37e4c13dc0d1
diff --git a/cmd/termmapper/main.go b/cmd/termmapper/main.go
index 211dadc..60dc0a0 100644
--- a/cmd/termmapper/main.go
+++ b/cmd/termmapper/main.go
@@ -33,6 +33,8 @@
 	Hash        string
 	Date        string
 	Description string
+	Server      string
+	SDK         string
 	MappingIDs  []string
 }
 
@@ -114,7 +116,7 @@
 	}
 }
 
-func setupRoutes(app *fiber.App, m *mapper.Mapper, yamlConfig *config.MappingLists) {
+func setupRoutes(app *fiber.App, m *mapper.Mapper, yamlConfig *config.MappingConfig) {
 	// Health check endpoint
 	app.Get("/health", func(c *fiber.Ctx) error {
 		return c.SendString("OK")
@@ -224,7 +226,7 @@
 	return nil
 }
 
-func handleKalamarPlugin(yamlConfig *config.MappingLists) fiber.Handler {
+func handleKalamarPlugin(yamlConfig *config.MappingConfig) fiber.Handler {
 	return func(c *fiber.Ctx) error {
 		// Get list of available mapping IDs
 		var mappingIDs []string
@@ -232,6 +234,10 @@
 			mappingIDs = append(mappingIDs, list.ID)
 		}
 
+		// Use values from config (defaults are already applied during parsing)
+		server := yamlConfig.Server
+		sdk := yamlConfig.SDK
+
 		// Prepare template data
 		data := TemplateData{
 			Title:       config.Title,
@@ -239,6 +245,8 @@
 			Hash:        config.Buildhash,
 			Date:        config.Buildtime,
 			Description: config.Description,
+			Server:      server,
+			SDK:         sdk,
 			MappingIDs:  mappingIDs,
 		}
 
@@ -258,6 +266,8 @@
 <head>
     <meta charset="UTF-8">
     <title>` + data.Title + `</title>
+    <script src="` + data.SDK + `"
+            data-server="` + data.Server + `"></script>
 </head>
 <body>
     <div class="container">
@@ -291,6 +301,29 @@
 
 	html += `
     </ul>
+
+    <script>
+  		<!-- activates/deactivates Mapper. -->
+  		  
+       let data = {
+         'action'  : 'pipe',
+         'service' : 'https://korap.ids-mannheim.de/plugin/termmapper/query'
+       };
+
+       function pluginit (p) {
+         p.onMessage = function(msg) {
+           if (msg.key == 'termmapper') {
+             if (msg.value) {
+               data['job'] = 'add';
+             }
+             else {
+               data['job'] = 'del';
+             };
+             KorAPlugin.sendMsg(data);
+           };
+         };
+       };
+    </script>
   </body>
 </html>`