diff --git a/isso/js/app/api.js b/isso/js/app/api.js index 144415e..5a22ed2 100644 --- a/isso/js/app/api.js +++ b/isso/js/app/api.js @@ -122,8 +122,8 @@ define(["q"], function(Q) { return rv.substring(0, rv.length - 1); // chop off trailing "&" }; - var create = function(data) { - return curl("POST", endpoint + "/new?" + qs({uri: location}), JSON.stringify(data)).then( + var create = function(tid, data) { + return curl("POST", endpoint + "/new?" + qs({uri: tid || location}), JSON.stringify(data)).then( function (rv) { return JSON.parse(rv.body); }); }; @@ -148,9 +148,9 @@ define(["q"], function(Q) { }); }; - var fetch = function(plain) { + var fetch = function(tid) { - return curl("GET", endpoint + "/?" + qs({uri: location, plain: plain}), null).then(function (rv) { + return curl("GET", endpoint + "/?" + qs({uri: tid || location}), null).then(function (rv) { if (rv.status === 200) { return JSON.parse(rv.body); } else { @@ -159,8 +159,8 @@ define(["q"], function(Q) { }); }; - var count = function(uri) { - return curl("GET", endpoint + "/count?" + qs({uri: uri}), null).then(function(rv) { + var count = function(tid) { + return curl("GET", endpoint + "/count?" + qs({uri: tid || location}), null).then(function(rv) { return JSON.parse(rv.body); }); }; diff --git a/isso/js/app/count.js b/isso/js/app/count.js index 173dab5..077b7f5 100644 --- a/isso/js/app/count.js +++ b/isso/js/app/count.js @@ -5,11 +5,13 @@ define(["app/api", "app/dom", "app/markup"], function(api, $, Mark) { return; } - var uri = el.href.match("^(.+)#isso-thread$")[1] + var tid = el.getAttribute("data-isso-id") || + el.href.match("^(.+)#isso-thread$")[1] .replace(/^.*\/\/[^\/]+/, ''); - api.count(uri).then(function(rv) { + + api.count(tid).then(function(rv) { el.textContent = Mark.up("{{ i18n-num-comments | pluralize : `n` }}", {n: rv}); }); }); }; -}); \ No newline at end of file +}); diff --git a/isso/js/app/isso.js b/isso/js/app/isso.js index db06d40..b374614 100644 --- a/isso/js/app/isso.js +++ b/isso/js/app/isso.js @@ -59,7 +59,7 @@ define(["app/text/html", "app/dom", "app/utils", "app/config", "app/api", "app/m return; } - api.create({ + api.create($("#isso-thread").getAttribute("data-isso-id"), { author: $("[name=author]", el).value || null, email: $("[name=email]", el).value || null, text: $("textarea", el).value, diff --git a/isso/js/embed.js b/isso/js/embed.js index 20532f2..0ad860d 100644 --- a/isso/js/embed.js +++ b/isso/js/embed.js @@ -26,7 +26,7 @@ require(["ready", "app/config", "app/api", "app/isso", "app/count", "app/dom", " $("#isso-thread").append(new isso.Postbox(null)); $("#isso-thread").append('
'); - api.fetch().then(function(rv) { + api.fetch($("#isso-thread").getAttribute("data-isso-id")).then(function(rv) { if (! rv.length) { $("#isso-thread > h4").textContent = Mark.up("{{ i18n-no-comments }}"); diff --git a/isso/utils/parse.py b/isso/utils/parse.py index a03ba7b..7ed2711 100644 --- a/isso/utils/parse.py +++ b/isso/utils/parse.py @@ -76,14 +76,14 @@ def host(name): return (rv.netloc.rsplit(':')[0], rv.port or 80, rv.scheme == 'https') -def title(data, default=u"Untitled."): +def thread(data, default=u"Untitled.", id=None): """ Extract