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 @@ failed to post: {{error}}
{% else %}
-{% if msgid %}
posted-{% else %} -
message was not posted-{% endif %} {% endif %} {% endblock %} diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html index c7891d0..3a99a45 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html @@ -9,7 +9,8 @@