Skip to content

Commit

Permalink
Fix issue isso-comments#27 on override thread discovery with custom d…
Browse files Browse the repository at this point in the history
…ata-attributes
  • Loading branch information
blatinier committed Jun 1, 2016
1 parent 4d3f6fa commit f1325cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion isso/js/app/isso.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",
api.create($("#isso-thread").getAttribute("data-isso-id"), {
author: author, email: email, website: website,
text: utils.text($(".textarea", el).innerHTML),
parent: parent || null
parent: parent || null,
title: $("#isso-thread").getAttribute("data-title") || null
}).then(function(comment) {
$(".textarea", el).innerHTML = "";
$(".textarea", el).blur();
Expand Down
15 changes: 9 additions & 6 deletions isso/views/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class API(object):
'mode', 'created', 'modified', 'likes', 'dislikes', 'hash'])

# comment fields, that can be submitted
ACCEPT = set(['text', 'author', 'website', 'email', 'parent'])
ACCEPT = set(['text', 'author', 'website', 'email', 'parent', 'title'])

VIEWS = [
('fetch', ('GET', '/')),
Expand Down Expand Up @@ -168,11 +168,14 @@ def new(self, environ, request, uri):

with self.isso.lock:
if uri not in self.threads:
with http.curl('GET', local("origin"), uri) as resp:
if resp and resp.status == 200:
uri, title = parse.thread(resp.read(), id=uri)
else:
return NotFound('URI does not exist')
if 'title' not in data:
with http.curl('GET', local("origin"), uri) as resp:
if resp and resp.status == 200:
uri, title = parse.thread(resp.read(), id=uri)
else:
return NotFound('URI does not exist %s')
else:
title = data['title']

thread = self.threads.new(uri, title)
self.signal("comments.new:new-thread", thread)
Expand Down

0 comments on commit f1325cc

Please sign in to comment.