client configuration for reply-to-self

also: move data-isso-* configuration to app/config
This commit is contained in:
Martin Zimmermann 2013-11-16 22:15:31 +01:00
parent 64c0d770c6
commit edafc5f88f
6 changed files with 36 additions and 19 deletions

View File

@ -143,6 +143,10 @@ You can configure the client (the JS part) via `data-` attributes:
<script src="..." data-isso-css="false"></script> <script src="..." data-isso-css="false"></script>
``` ```
* data-isso-reply-to-self
Set to `true` when spam guard is configured with `reply-to-self = true`.
### Webserver configuration ### Webserver configuration
* nginx configuration to run Isso on `/isso`: * nginx configuration to run Isso on `/isso`:

View File

@ -205,6 +205,8 @@ reply-to-self
the comment. After the editing timeframe is gone, commenters can reply to the comment. After the editing timeframe is gone, commenters can reply to
their own comments anyways. their own comments anyways.
Do not forget to configure the client.
Appendum Appendum
--------- ---------

View File

@ -6,9 +6,6 @@ define(["q"], function(Q) {
Q.longStackSupport = true; Q.longStackSupport = true;
var salt = "Eech7co8Ohloopo9Ol6baimi", var salt = "Eech7co8Ohloopo9Ol6baimi",
config = {
"css": true
},
location = window.location.pathname; location = window.location.pathname;
var rules = { var rules = {
@ -48,16 +45,6 @@ define(["q"], function(Q) {
} else if (js[i].src.match("require\\.js$")) { } else if (js[i].src.match("require\\.js$")) {
endpoint = js[i].dataset.main.replace(/\/js\/(embed|count)$/, ""); 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) { if (! endpoint) {
@ -194,7 +181,6 @@ define(["q"], function(Q) {
return { return {
endpoint: endpoint, endpoint: endpoint,
salt: salt, salt: salt,
config: config,
remote_addr: remote_addr, remote_addr: remote_addr,

25
isso/js/app/config.js Normal file
View File

@ -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;
});

View File

@ -1,7 +1,7 @@
/* Isso Ich schrei sonst! /* Isso Ich schrei sonst!
*/ */
define(["app/text/html", "app/dom", "app/utils", "app/api", "app/markup", "app/i18n", "app/lib", "app/fancy"], define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/markup", "app/i18n", "app/lib", "app/fancy"],
function(templates, $, utils, api, Mark, i18n, lib, fancy) { function(templates, $, utils, config, api, Mark, i18n, lib, fancy) {
"use strict"; "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()); show($("a.reply", footer).detach());
} }
}; };

View File

@ -3,13 +3,13 @@
* Distributed under the MIT license * 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"; "use strict";
domready(function() { domready(function() {
if (api.config["css"]) { if (config["css"]) {
var style = $.new("style"); var style = $.new("style");
style.type = "text/css"; style.type = "text/css";
style.textContent = css.inline; style.textContent = css.inline;