From 49993ae89fbe028df386635104ce11b1309a303d Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Thu, 31 Aug 2023 16:08:55 -0400 Subject: add prefix to js --- newspipe/static/js/articles.js | 6 +++--- newspipe/static/js/config.js | 7 +++++++ newspipe/templates/layout.html | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 newspipe/static/js/config.js diff --git a/newspipe/static/js/articles.js b/newspipe/static/js/articles.js index f1cee6e7..29ebac2e 100644 --- a/newspipe/static/js/articles.js +++ b/newspipe/static/js/articles.js @@ -86,7 +86,7 @@ Array.prototype.map.call(nodes, function(node) { } // sends the updates to the server - fetch(API_ROOT + "article/" + article_id, { + fetch(prefix + API_ROOT + "article/" + article_id, { method: "PUT", headers: { 'Content-Type': 'application/json', @@ -157,7 +157,7 @@ Array.prototype.map.call(nodes, function(node) { } // sends the updates to the server - fetch(API_ROOT + "article/" + article_id, { + fetch(prefix + API_ROOT + "article/" + article_id, { method: "PUT", headers: { 'Content-Type': 'application/json', @@ -189,7 +189,7 @@ Array.prototype.map.call(nodes, function(node) { data = JSON.stringify(data); // sends the updates to the server - fetch(API_ROOT + "articles", { + fetch(prefix + API_ROOT + "articles", { method: "DELETE", headers: { 'Content-Type': 'application/json', diff --git a/newspipe/static/js/config.js b/newspipe/static/js/config.js new file mode 100644 index 00000000..7fad4388 --- /dev/null +++ b/newspipe/static/js/config.js @@ -0,0 +1,7 @@ +/* + * Set variables here for the javascript used by newspipe. + */ +var prefix = "/newspipe"; + +/* Set exactly one trailing slash on prefix. */ +prefix = prefix.replace(/\/+$/,"/"); diff --git a/newspipe/templates/layout.html b/newspipe/templates/layout.html index 90919a7a..466ff4e2 100644 --- a/newspipe/templates/layout.html +++ b/newspipe/templates/layout.html @@ -150,6 +150,7 @@ {% block content %}{% endblock %} + -- cgit