From c3224379ca9a6970d3c6b80f2867e6accb777fd2 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Mon, 7 Nov 2016 07:02:03 -0500 Subject: [PATCH] more --- .../nntpchan/frontend/static/style.css | 34 ++++++++++++++++--- .../django/nntpchan/nntpchan/frontend/util.py | 8 ++--- .../nntpchan/nntpchan/frontend/views.py | 10 +++--- .../nntpchan/templates/frontend/board.html | 24 ++++++++----- .../templates/frontend/frontpage.html | 17 ++++++---- .../nntpchan/templates/frontend/thread.html | 27 ++++++++------- 6 files changed, 79 insertions(+), 41 deletions(-) diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css index a08ac09..16b1d93 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css @@ -9,6 +9,14 @@ div { font-family: sans; } +hr { + height: 0px; + border-width: 1px medium medium; + border-color: #b7c5d9; + border-style: solid none none; + width: 100%; +} + #navbar { z-index: 20; position: fixed; @@ -100,26 +108,38 @@ form { flex-basis: 100%; } -.post > .header { +.post-header { padding-bottom: 1%; + flex-basis: 100%; + flex-direction: row-reverse; } .postbody { font-family: serif; font-size: 10pt; white-space: pre-wrap; + word-wrap: break-word; } -.name { +.post-name { font-weight: bold; color: #028241; + margin-left: 1%; + margin-right: 1%; } -.subject { +.post-subject { font-weight: bold; color: #480188; + margin-left: 1%; + margin-right: 1%; } +.post-date { + font-style: italic; + margin-left: 1%; + margin-right: 1%; +} .posts { flex-direction: column; @@ -143,8 +163,12 @@ footer { padding-bottom: 5%; } -.cite { - float: right; +.post-info { + flex-basis: 100%; +} + +.post-cite { + align-self: flex-end; } .redtext { diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py index 1ab17c6..a48fc74 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py @@ -71,11 +71,11 @@ def createPost(newsgroup, ref, form, files): server = settings.NNTP_SERVER server['readermode'] = True - msgid = None + response = None try: with nntplib.NNTP(**server) as nntp: nntp.login(**settings.NNTP_LOGIN) - msgid = nntp.post(msg.as_bytes()) + response = nntp.post(msg.as_bytes()) except Exception as e: - return None, e - return msgid, None + return None, 'connection to backend failed, {}'.format(e) + return response, None diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py index 869b0c8..7376d37 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py @@ -41,8 +41,10 @@ class Postable: ctx['msgid'], ctx['error'] = self.handle_post(request, **kwargs) request.session['captcha'] = '' request.session.save() - - return render(request, 'frontend/postresult.html', ctx) + code = 201 + if ctx['error']: + code = 200 + return HttpResponse(content=render(request, 'frontend/postresult.html', ctx), status=code) class BoardView(generic.View, Postable): @@ -79,7 +81,7 @@ class BoardView(generic.View, Postable): begin = page * group.posts_per_page end = begin + group.posts_per_page - 1 roots = self.model.objects.filter(newsgroup=group, reference='').order_by('-last_bumped')[begin:end] - ctx = self.context_for_get(request, {'threads': roots, 'page': page, 'name': newsgroup}) + ctx = self.context_for_get(request, {'threads': roots, 'page': page, 'name': newsgroup, 'button': 'new thread'}) if page < group.max_pages: ctx['nextpage'] = reverse('board', args=[name]) + '?p={}'.format(page + 1) if page > 0: @@ -103,7 +105,7 @@ class ThreadView(generic.View, Postable): def get(self, request, op): posts = get_object_or_404(self.model, posthash=op) - ctx = self.context_for_get(request, {'op': posts}) + ctx = self.context_for_get(request, {'op': posts, 'button': 'reply'}) return render(request, self.template_name, ctx) class FrontPageView(generic.View): diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html index bc0961c..5926e44 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html @@ -16,12 +16,14 @@ {% for op in threads %}
-
- {{op.name}} {{op.subject}} - {{op.postdate|date}} - >>{{op.shorthash}} +
+
>>{{op.shorthash}}
+
-
{% for a in op.attachments.all %} @@ -31,10 +33,13 @@
{% for reply in op.get_board_replies %}
-
- {{reply.name}} {{reply.subject}} - {{reply.postdate|date}} - >>{{reply.shorthash}} +
+
>>{{reply.shorthash}}
+
{% for a in reply.attachments.all %} @@ -45,6 +50,7 @@
{% endfor %}
+
{% endfor %}
diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/frontpage.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/frontpage.html index 884b22d..3cbb89c 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/frontpage.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/frontpage.html @@ -4,14 +4,17 @@
{% for post in posts %}
- -
- {{post.name}} {{post.subject}} - {{post.postdate|date}} - >>{{post.shorthash}} + + +
+
>>{{post.shorthash}}
+
+
{% for a in post.attachments.all %} diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html index 8a065eb..c7891d0 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html @@ -2,19 +2,20 @@ {% load chanup %} {% block title %} {{op.subject}} {% endblock %} {% block navbar_links %} -back to {{op.newsgroup.name}} + {% endblock %} {% block content %} {% include "frontend/postform.html" %}
-
- {{op.name}} {{op.subject}} - {{op.msgid}} - {{op.postdate|date}} - >>{{op.shorthash}} +
+
>>{{op.shorthash}}
+
-
{% for a in op.attachments.all %} @@ -24,11 +25,13 @@
{% for reply in op.get_all_replies %}
-
- {{reply.name}} {{reply.subject}} - {{reply.msgid}} - {{reply.postdate|date}} - >>{{reply.shorthash}} +
+
>>{{reply.shorthash}}
+
{% for a in reply.attachments.all %}