Merge pull request #252 from blatinier/issue-27/data-attr-overide
Fix issue #27 on override thread discovery with custom data-attributes
This commit is contained in:
commit
46b2874b3d
@ -113,11 +113,10 @@ Enable or disable voting feature on the client side.
|
|||||||
data-isso-id
|
data-isso-id
|
||||||
------------
|
------------
|
||||||
|
|
||||||
Broken – do not use. https://github.com/posativ/isso/issues/27
|
Set a custom thread id, defaults to current URI. This attribute needs
|
||||||
|
to be used with the data-title attribute in order to work.
|
||||||
Set a custom thread id, defaults to current URI. If you use a comment counter,
|
If you use a comment counter, add this attribute to the link tag, too.
|
||||||
add this attribute to the link tag, too.
|
|
||||||
|
|
||||||
.. code-block:: html
|
.. code-block:: html
|
||||||
|
|
||||||
<section data-isso-id="test.abc" id="isso-thread"></section>
|
<section data-title="Yay!" data-isso-id="test.abc" id="isso-thread"></section>
|
||||||
|
@ -69,7 +69,8 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
|
|||||||
api.create($("#isso-thread").getAttribute("data-isso-id"), {
|
api.create($("#isso-thread").getAttribute("data-isso-id"), {
|
||||||
author: author, email: email, website: website,
|
author: author, email: email, website: website,
|
||||||
text: utils.text($(".textarea", el).innerHTML),
|
text: utils.text($(".textarea", el).innerHTML),
|
||||||
parent: parent || null
|
parent: parent || null,
|
||||||
|
title: $("#isso-thread").getAttribute("data-title") || null
|
||||||
}).then(function(comment) {
|
}).then(function(comment) {
|
||||||
$(".textarea", el).innerHTML = "";
|
$(".textarea", el).innerHTML = "";
|
||||||
$(".textarea", el).blur();
|
$(".textarea", el).blur();
|
||||||
|
@ -75,7 +75,7 @@ class API(object):
|
|||||||
'mode', 'created', 'modified', 'likes', 'dislikes', 'hash'])
|
'mode', 'created', 'modified', 'likes', 'dislikes', 'hash'])
|
||||||
|
|
||||||
# comment fields, that can be submitted
|
# comment fields, that can be submitted
|
||||||
ACCEPT = set(['text', 'author', 'website', 'email', 'parent'])
|
ACCEPT = set(['text', 'author', 'website', 'email', 'parent', 'title'])
|
||||||
|
|
||||||
VIEWS = [
|
VIEWS = [
|
||||||
('fetch', ('GET', '/')),
|
('fetch', ('GET', '/')),
|
||||||
@ -169,11 +169,14 @@ class API(object):
|
|||||||
|
|
||||||
with self.isso.lock:
|
with self.isso.lock:
|
||||||
if uri not in self.threads:
|
if uri not in self.threads:
|
||||||
with http.curl('GET', local("origin"), uri) as resp:
|
if 'title' not in data:
|
||||||
if resp and resp.status == 200:
|
with http.curl('GET', local("origin"), uri) as resp:
|
||||||
uri, title = parse.thread(resp.read(), id=uri)
|
if resp and resp.status == 200:
|
||||||
else:
|
uri, title = parse.thread(resp.read(), id=uri)
|
||||||
return NotFound('URI does not exist')
|
else:
|
||||||
|
return NotFound('URI does not exist %s')
|
||||||
|
else:
|
||||||
|
title = data['title']
|
||||||
|
|
||||||
thread = self.threads.new(uri, title)
|
thread = self.threads.new(uri, title)
|
||||||
self.signal("comments.new:new-thread", thread)
|
self.signal("comments.new:new-thread", thread)
|
||||||
|
Loading…
Reference in New Issue
Block a user