Add CSP compliance to plugins
Change-Id: Ia13082bbad5348c8cbb5f5cb976bfe32c9fe0a27
diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index 75a4e68..cfc0625 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -107,7 +107,15 @@
let url = KorAP.URL + "/corpus?cq=" + encodeURIComponent(cq);
KorAP.API.getJSON(url, cb, "CorpusInfo: " + cq);
};
-
+
+
+ /**
+ * Retrieve a list of all plugin objects to
+ * establish in the frontend.
+ */
+ KorAP.API.getPluginList = function (url, cb) {
+ KorAP.API.getJSON(url, cb, "Plugin-List")
+ };
/**
* General method to retrieve JSON information
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index ef6dfcf..4f6074f 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -436,28 +436,35 @@
/**
* Initialize Plugin registry.
*/
- let p = KorAP.Plugins;
- if (p && p.length > 0) {
- // Load Plugin Server first
- KorAP.Plugin = pluginClass.create();
+ let pe;
+ if (pe = d.getElementById("kalamar-plugins")) {
+ let url = pe.getAttribute('data-plugins');
+ if (url !== undefined) {
+ KorAP.API.getPluginList(url, function (json) {
+ if (json && json.length > 0) {
+ // Load Plugin Server first
+ KorAP.Plugin = pluginClass.create();
- // Add services container to head
- d.head.appendChild(KorAP.Plugin.element());
+ // Add services container to head
+ d.head.appendChild(KorAP.Plugin.element());
- // Add pipe form
- KorAP.Pipe = pipeClass.create();
- d.getElementById("searchform").appendChild(KorAP.Pipe.element());
-
- try {
-
- // Register all plugins
- p.forEach(i => KorAP.Plugin.register(i));
- }
- catch (e) {
- KorAP.log(0, e);
- }
+ // Add pipe form
+ KorAP.Pipe = pipeClass.create();
+ d.getElementById("searchform").appendChild(KorAP.Pipe.element());
+
+ try {
+
+ // Register all plugins
+ json.forEach(i => KorAP.Plugin.register(i));
+ }
+ catch (e) {
+ KorAP.log(0, e);
+ }
+ }
+ });
+ };
};
-
+
return obj;
});