diff --git a/.gitignore b/.gitignore index 7262dc5..ab245b5 100644 --- a/.gitignore +++ b/.gitignore @@ -23,7 +23,6 @@ srndv2 # private key *.key -*.txt # certificates certs diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/banners.js b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/banners.js new file mode 100644 index 0000000..71a0c0d --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/banners.js @@ -0,0 +1 @@ +/** banners.js */ diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/hooks.js b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/hooks.js new file mode 100644 index 0000000..edfea6e --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/hooks.js @@ -0,0 +1,13 @@ +/** hooks.js */ + +onready_callbacks = []; +function onready(fnc) { + onready_callbacks.push(fnc); +} + +function ready() { + for (var i = 0; i < onready_callbacks.length; i++) { + onready_callbacks[i](); + } +} + diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/postform.js b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/postform.js new file mode 100644 index 0000000..7ef0ca6 --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/postform.js @@ -0,0 +1,8 @@ +/** postform.js */ + + +onready(function() { + var e = document.getElementById("postform"); + if(!e) return; // no post form on page + +}); diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/settings.js b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/settings.js new file mode 100644 index 0000000..b13cd04 --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/settings.js @@ -0,0 +1 @@ +/** settings.js */ diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css index 17b806d..e20dc52 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/static/style.css @@ -4,6 +4,7 @@ body, html { } div { + display: flex; font-size: 12px; font-family: sans; } @@ -22,30 +23,81 @@ div { color: #34345c } -#navbar_left { - float: right; +.navbar.left { + flex-basis: 100%; } +#navbar_frontpage { + flex-basis: 5%; +} + +.navbar.right { +} img.thumb { + margin: 10px; max-width: 300px; max-height: 200px; } .thread { - padding: 5%; + flex-direction: column; + background-color: rgba(214, 218, 240, 0.25); + border-radius: 10px; + margin: 1%; + width: 90%; + align-items: flex-begin; +} + +#wrapper , #content { + flex-direction: column; } .post { - margin: 2%; + margin: 1%; background-color: #d6daf0; - min-width: 500px; - width: 75%; + width: 90%; border: 2px solid #B7C5D9; border-radius: 2px 4px 4px 4px; border-left: none; border-top: none; padding: 1%; + flex-direction: column; +} + +form { + padding: 5%; + width: 90%; +} + +.postform { + flex-direction: column; + align-items: flex-start; + max-height: 25%; + width: 90%; +} + +.pf-left { + flex-direction: column; + flex-basis: 50%; + 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 { @@ -68,6 +120,7 @@ img.thumb { color: #480188; } + .frontpage.posts { width: 50%; padding-top: 10%; diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/templatetags/captcha.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/templatetags/captcha.py new file mode 100644 index 0000000..3f967ec --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/templatetags/captcha.py @@ -0,0 +1,6 @@ +from django import template + + +register = template.Library() + + diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py index 166e0ea..8f21407 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py @@ -5,9 +5,10 @@ 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'^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'), + 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'), + url(r'^b/(?P[a-zA-Z0-9]+)/$', views.BoardView.as_view(), name='board'), url(r'^t/(?P[a-fA-F0-9\.]{40})/$', views.ThreadView.as_view(), name='thread'), url(r'^$', views.FrontPageView.as_view(), name='index'), ] diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py index 0fc588d..bff8f9a 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/util.py @@ -11,7 +11,7 @@ def hashid(msgid): return h.hexdigest() def newsgroup_valid(name): - return re.match('overchan\.[a-zA-Z0-9\.]+[a-zA-Z0-9]$', name) is not None + return re.match('overchan\.[a-zA-Z0-9\.]+[a-zA-Z0-9]$', name) is not None or name == 'ctl' def hashfile(data): h = hashlib.sha512() diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py index 52e15d5..17197cf 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py @@ -6,7 +6,23 @@ from django.views import generic from .models import Post, Newsgroup -class BoardView(generic.View): +class Postable: + """ + postable view + checks captcha etc + """ + + def post(self, request, **kwargs): + ctx = { + 'error' : None + } + + + + return render(request, 'frontend/postresult.html', ctx) + + +class BoardView(generic.View, Postable): template_name = 'frontend/board.html' context_object_name = 'threads' model = Post @@ -37,8 +53,7 @@ class BoardView(generic.View): ctx['prevpage'] = reverse('board', args=[name]) + '?p={}'.format(page - 1) return render(request, self.template_name, ctx) - -class ThreadView(generic.ListView): +class ThreadView(generic.ListView, Postable): template_name = 'frontend/thread.html' model = Post context_object_name = 'op' @@ -46,8 +61,6 @@ class ThreadView(generic.ListView): def get_queryset(self): return get_object_or_404(self.model, posthash=self.kwargs['op']) - - class FrontPageView(generic.View): template_name = 'frontend/frontpage.html' model = Post diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html index 3158663..4df5f48 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/base.html @@ -4,16 +4,22 @@ {% block title %} nntpchan {% endblock %} - + + + +
{% block content %} diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html index 76c2710..bc0961c 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/board.html @@ -12,7 +12,7 @@ {% endif %} {% endblock %} {% block content %} -
+{% include "frontend/postform.html" %} {% for op in threads %}
diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postform.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postform.html new file mode 100644 index 0000000..a8f4a2f --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postform.html @@ -0,0 +1,66 @@ +{% load captcha %} +
+
+ {% csrf_token %} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + +
+ + +
+ + +
+ + + +
+ + + captcha +
+ + +
+ +
+
diff --git a/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postresult.html b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postresult.html new file mode 100644 index 0000000..b7c8bf1 --- /dev/null +++ b/contrib/frontends/django/nntpchan/nntpchan/templates/frontend/postresult.html @@ -0,0 +1,15 @@ +{% extends "frontend/base.html" %} + +{% block content %} + +{% if error %} +
 failed to post {{error}} 
+{% else %} +{% if msgid %} +
 posted as {{msgid}} 
+{% else %} +
 message was not posted 
+{% endif %} +{% endif %} + +{% endblock %} diff --git a/contrib/frontends/django/requirements.txt b/contrib/frontends/django/requirements.txt new file mode 100644 index 0000000..1d8b079 --- /dev/null +++ b/contrib/frontends/django/requirements.txt @@ -0,0 +1,2 @@ +captcha +django