From edafc5f88f38ebb3c078d102fe524b95a1b546de Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Sat, 16 Nov 2013 22:15:31 +0100 Subject: [PATCH] client configuration for reply-to-self also: move data-isso-* configuration to app/config --- README.md | 4 ++++ docs/CONFIGURATION.rst | 2 ++ isso/js/app/api.js | 14 -------------- isso/js/app/config.js | 25 +++++++++++++++++++++++++ isso/js/app/isso.js | 6 +++--- isso/js/embed.js | 4 ++-- 6 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 isso/js/app/config.js diff --git a/README.md b/README.md index 92fe4bd..713090e 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,10 @@ You can configure the client (the JS part) via `data-` attributes: ``` +* data-isso-reply-to-self + + Set to `true` when spam guard is configured with `reply-to-self = true`. + ### Webserver configuration * nginx configuration to run Isso on `/isso`: diff --git a/docs/CONFIGURATION.rst b/docs/CONFIGURATION.rst index d670388..67aec97 100644 --- a/docs/CONFIGURATION.rst +++ b/docs/CONFIGURATION.rst @@ -205,6 +205,8 @@ reply-to-self the comment. After the editing timeframe is gone, commenters can reply to their own comments anyways. + Do not forget to configure the client. + Appendum --------- diff --git a/isso/js/app/api.js b/isso/js/app/api.js index 80be93d..157d36f 100644 --- a/isso/js/app/api.js +++ b/isso/js/app/api.js @@ -6,9 +6,6 @@ define(["q"], function(Q) { Q.longStackSupport = true; var salt = "Eech7co8Ohloopo9Ol6baimi", - config = { - "css": true - }, location = window.location.pathname; var rules = { @@ -48,16 +45,6 @@ define(["q"], function(Q) { } else if (js[i].src.match("require\\.js$")) { endpoint = js[i].dataset.main.replace(/\/js\/(embed|count)$/, ""); } - - [].forEach.call(js[i].attributes, function(attr) { - if (/^data-isso-/.test(attr.name)) { - try { - config[attr.name.substring(10)] = JSON.parse(attr.value); - } catch (ex) { - config[attr.name.substring(10)] = attr.value; - } - } - }); } if (! endpoint) { @@ -194,7 +181,6 @@ define(["q"], function(Q) { return { endpoint: endpoint, salt: salt, - config: config, remote_addr: remote_addr, diff --git a/isso/js/app/config.js b/isso/js/app/config.js new file mode 100644 index 0000000..d946857 --- /dev/null +++ b/isso/js/app/config.js @@ -0,0 +1,25 @@ +define(function() { + "use strict"; + + var config = { + "css": true, + "reply-to-self": false + }; + + var js = document.getElementsByTagName("script"); + + for (var i = 0; i < js.length; i++) { + [].forEach.call(js[i].attributes, function(attr) { + if (/^data-isso-/.test(attr.name)) { + try { + config[attr.name.substring(10)] = JSON.parse(attr.value); + } catch (ex) { + config[attr.name.substring(10)] = attr.value; + } + } + }); + } + + return config; + +}); diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index 405b54f..8ab7c3e 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -1,7 +1,7 @@ /* Isso – Ich schrei sonst! */ -define(["app/text/html", "app/dom", "app/utils", "app/api", "app/markup", "app/i18n", "app/lib", "app/fancy"], - function(templates, $, utils, api, Mark, i18n, lib, fancy) { +define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/markup", "app/i18n", "app/lib", "app/fancy"], + function(templates, $, utils, config, api, Mark, i18n, lib, fancy) { "use strict"; @@ -275,7 +275,7 @@ define(["app/text/html", "app/dom", "app/utils", "app/api", "app/markup", "app/i } }; - if (utils.cookie("isso-" + comment.id)) { + if (! config["reply-to-self"] && utils.cookie("isso-" + comment.id)) { show($("a.reply", footer).detach()); } }; diff --git a/isso/js/embed.js b/isso/js/embed.js index 89d9855..20532f2 100644 --- a/isso/js/embed.js +++ b/isso/js/embed.js @@ -3,13 +3,13 @@ * Distributed under the MIT license */ -require(["ready", "app/api", "app/isso", "app/count", "app/dom", "app/markup", "app/text/css"], function(domready, api, isso, count, $, Mark, css) { +require(["ready", "app/config", "app/api", "app/isso", "app/count", "app/dom", "app/markup", "app/text/css"], function(domready, config, api, isso, count, $, Mark, css) { "use strict"; domready(function() { - if (api.config["css"]) { + if (config["css"]) { var style = $.new("style"); style.type = "text/css"; style.textContent = css.inline;