From e036db805e73226abe63424e2fb7338bcd062826 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 8 Nov 2016 07:22:43 -0500 Subject: [PATCH] more --- .../nntpchan/nntpchan/frontend/static/cite.js | 19 +++++++++++++++++++ .../nntpchan/frontend/static/hooks.js | 6 ++++++ .../django/nntpchan/nntpchan/frontend/util.py | 3 +-- .../nntpchan/nntpchan/frontend/views.py | 2 +- .../nntpchan/templates/frontend/base.html | 1 + .../nntpchan/templates/frontend/board.html | 6 ++++-- .../templates/frontend/postresult.html | 4 ---- .../nntpchan/templates/frontend/thread.html | 6 ++++-- 8 files changed, 36 insertions(+), 11 deletions(-) create mode 100644 contrib/frontends/django/nntpchan/nntpchan/frontend/static/cite.js diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/cite.js b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/cite.js new file mode 100644 index 0000000..13408f2 --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/cite.js @@ -0,0 +1,19 @@ +/** cite.js */ + + +function thread_citepost(hash) { + var e = document.getElementById("postform_message"); + if (!e) return; // no postform element + e.value += ">>"+hash.slice(0, 18) + "\n"; +} + +function board_postcite(hash) { + // TODO implement +} + +onready(function() { + // inject postciter + forEachInClass("post-cite", function(elem) { + + }); +}); diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/hooks.js b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/hooks.js index edfea6e..abf2b48 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/hooks.js +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/hooks.js @@ -11,3 +11,9 @@ function ready() { } } +function forEachInClass(clazz, cb) { + var elems = document.getElementsByClassName(clazz); + for (var idx = 0; idx < elems.length; idx ++) { + cb(elems[idx]); + } +} diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py index bcd4382..b554c1d 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py @@ -48,7 +48,6 @@ def createPost(newsgroup, ref, form, files): msg['Content-Type'] = 'multipart/mixed' msg["Subject"] = form["subject"] or "None" msg['Date'] = email.utils.format_datetime(datetime.now()) - msg['Message-ID'] = email.utils.make_msgid(randstr(13), settings.FRONTEND_NAME) if ref and not msgid_valid(ref): return None, "invalid reference: {}".format(ref) if ref: @@ -80,4 +79,4 @@ def createPost(newsgroup, ref, form, files): return None, 'connection to backend failed, {}'.format(e) if ref: return ref, None - return msg["Message-ID"], None + return None, None diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py index af803d6..273f8e4 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py @@ -44,7 +44,7 @@ class Postable: code = 201 if ctx['error']: code = 200 - else: + elif ctx['msgid']: ctx['refresh_url'] = reverse('frontend:thread', args=[util.hashid(ctx['msgid'])]) return HttpResponse(content=render(request, 'frontend/postresult.html', ctx), status=code) diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html index 143d1cb..b7ec67b 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html @@ -9,6 +9,7 @@ + {% block head %}{% endblock %} diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html index 5926e44..7ba0b30 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html @@ -17,7 +17,8 @@
-
>>{{op.shorthash}}
+
[reply]
+
>>{{op.shorthash}}