From 518a32016bf442ecc13185620a70084b01f49e9a Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Wed, 9 Nov 2016 12:22:22 -0500 Subject: [PATCH] add initial censor ui --- .../nntpchan/frontend/static/censor.js | 28 ++++++ .../nntpchan/frontend/static/style.css | 99 +++++++++++++++---- .../django/nntpchan/nntpchan/frontend/urls.py | 3 +- .../nntpchan/nntpchan/frontend/views.py | 19 +++- .../django/nntpchan/nntpchan/settings.py | 2 +- .../nntpchan/templates/frontend/base.html | 1 + .../nntpchan/templates/frontend/board.html | 26 ++++- .../nntpchan/templates/frontend/mod.html | 1 + .../nntpchan/templates/frontend/modform.html | 2 + .../nntpchan/templates/frontend/postform.html | 39 +++++++- .../nntpchan/templates/frontend/thread.html | 22 ++++- 11 files changed, 206 insertions(+), 36 deletions(-) create mode 100644 contrib/frontends/django/nntpchan/nntpchan/frontend/static/censor.js create mode 100644 contrib/frontends/django/nntpchan/nntpchan/templates/frontend/mod.html create mode 100644 contrib/frontends/django/nntpchan/nntpchan/templates/frontend/modform.html diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/censor.js b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/censor.js new file mode 100644 index 0000000..3542e8f --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/censor.js @@ -0,0 +1,28 @@ +/** censor tools */ + + +function show_censortools() { + var e = document.getElementById("censor-tools"); + e.checked = true; +} + +function nntpchan_report_thread(posthash) { + var thread = document.getElementById(posthash); + if (!thread) return; + var posts = thread.getElementsByClassName("post"); + for (var idx = 0; idx < posts.length; idx ++ ) { + var post = posts[idx]; + nntpchan_report(post.dataset.msgid); + } +} + +function nntpchan_report(msgid) { + var e = document.getElementById("modactions"); + if (!e) return; + e.value += "delete "+msgid+"\n"; + show_censortools(); +} + +onready(function() { + +}); diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css index 85c3a09..8382f3b 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css @@ -85,11 +85,12 @@ form { width: 90%; } +.postreport { + width: 100px; +} + .postform { - flex-direction: column; - align-items: flex-start; - max-height: 25%; - width: 90%; + width: 75%; } .pf-left { @@ -98,23 +99,6 @@ form { width: 50%; } -.postform > input { - align-items: flex-start; -} - -.pf-item { - flex-basis: 100%; - flex-direction: row; -} - -.pf-inner { - align-content: flex-start; - align-self: flex-end; - flex-direction: column; - width: 100%; - flex-basis: 100%; -} - .post-header { padding-bottom: 1%; flex-basis: 100%; @@ -206,3 +190,76 @@ footer { .psy { animation: psych 2s linear infinite; } + +.postform > tr, th { + background: #98E; + font-size: 10pt; + text-align: left; + padding-right: 10px; + padding-left: 4px; +} + +.postform td{ + padding: 0px 15px 0px 4px; +} + +table { + margin: auto; +} +table.board-list-table { + width: 100%; +} + +table tbody td { + margin: 0; + padding: 4px 15px 4px 4px; + vertical-align: top; + text-align: left; +} +table thead th { + border: 1px solid #000333; + padding: 4px 15px 5px 5px; + + background: #98E; + color: #000333; + text-align: left; + white-space: nowrap; +} + +.postform td{ + padding: 0px 15px 0px 4px; +} + +input[type="text"],input[type="password"],textarea { + border: 1px solid #a9a9a9; + text-indent: 0; + text-shadow: none; + text-transform: none; + word-spacing: normal; + font-size: inherit; + font-family: sans-serif; +} + + +/** mod stuff */ +[type=checkbox] { + display: none; +} +:checked + div { + display: block !important; +} + +#censor-toggle { + font-style: italic; + text-decoration: underline; + font-weight: normal; +} + + +#censor-toggle, a { + color: #34345C; +} + +a:hover { + color: #ff0000; +} diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py index 3deeb43..6042a06 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py @@ -4,7 +4,8 @@ from . import views urlpatterns = [ url(r'^ctl-(?P[0-9]+)\.html$', views.modlog, name='old-modlog'), - url(r'^ctl/((?P[0-9]+)/)?$', views.modlog, name='modlog'), + url(r'^mod/$', views.modlog, name='modlog'), + url(r'^mod/(?P[0-9]+)$', views.modlog, name='modlog-page'), url(r'^overchan\.(?P[a-zA-Z0-9\.]+)-(?P[0-9]+)\.html$', views.BoardView.as_view(), name='old-board'), url(r'^overchan\.(?P[a-zA-Z0-9\.]+)/', views.BoardView.as_view(), name='board-alt'), url(r'^thread-(?P[a-fA-F0-9\.]{40})\.html$', views.ThreadView.as_view(), name='old-thread'), diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py index 273f8e4..70aafaf 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py @@ -121,10 +121,21 @@ class FrontPageView(generic.View): return render(request, self.template_name, ctx) -def modlog(request, page): - if page is None: - page = 0 - return HttpResponse('mod log page {}'.format(page)) +def modlog(request, page=None): + page = int(page or '0') + ctx = { + 'page': page, + } + if page > 0: + ctx['prevpage'] = reverse('frontend:modlog-page', args=[page - 1]) + + group, _ = Newsgroup.objects.get_or_create(name='ctl') + if page < group.max_pages: + ctx['nextpage'] = reverse('frontend:modlog-page', args=[page + 1]) + begin = group.posts_per_page * page + end = begin + group.posts_per_page - 1 + ctx['threads'] = Post.objects.filter(newsgroup='ctl').order_by('-last_bumped')[begin:end] + return render(request, 'frontend/board.html', ctx) def create_captcha(request): solution = util.randstr(7).lower() diff --git a/contrib/frontends/django/nntpchan/nntpchan/settings.py b/contrib/frontends/django/nntpchan/nntpchan/settings.py index 8b433d7..be92b57 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/settings.py +++ b/contrib/frontends/django/nntpchan/nntpchan/settings.py @@ -112,7 +112,7 @@ DATE_FORMAT = "r" USE_I18N = True -USE_L10N = True +USE_L10N = False USE_TZ = True diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html index b7ec67b..4cb17a9 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html @@ -10,6 +10,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 7ba0b30..3ff5a07 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html @@ -12,14 +12,25 @@ {% endif %} {% endblock %} {% block content %} +{% if captcha %} {% include "frontend/postform.html" %} +{% endif %} {% for op in threads %}
-
+
[reply]
>>{{op.shorthash}}
{% for reply in op.get_board_replies %} -
+
[reply]
>>{{reply.shorthash}}
@@ -54,7 +73,6 @@

{% endfor %} -
{% if prevpage %} prev diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/mod.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/mod.html new file mode 100644 index 0000000..88cb596 --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/mod.html @@ -0,0 +1 @@ +{% extends "frontend/base.html" %} diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/modform.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/modform.html new file mode 100644 index 0000000..e2a6f3e --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/modform.html @@ -0,0 +1,2 @@ + + diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postform.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postform.html index 2243998..cba17bc 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postform.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postform.html @@ -6,6 +6,7 @@ + Name @@ -16,6 +17,7 @@ + Subject @@ -24,9 +26,10 @@ + Message - + @@ -35,10 +38,10 @@ - + - + Captcha captcha @@ -46,11 +49,41 @@ + Solution + + + + + +
+ + + + + + + + + + + +
+ Actions: + + +
+ Secret: + + +
+
+ + diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html index 3a99a45..8f80ab2 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/thread.html @@ -7,11 +7,20 @@ {% block content %} {% include "frontend/postform.html" %}
-
+
[reply]
>>{{op.shorthash}}
{% for reply in op.get_all_replies %} -
+
[reply]
>>{{reply.shorthash}}