more
This commit is contained in:
parent
3c2da5f25b
commit
14c68abf9d
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,7 +23,6 @@ srndv2
|
||||
|
||||
# private key
|
||||
*.key
|
||||
*.txt
|
||||
|
||||
# certificates
|
||||
certs
|
||||
|
@ -0,0 +1 @@
|
||||
/** banners.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]();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
/** postform.js */
|
||||
|
||||
|
||||
onready(function() {
|
||||
var e = document.getElementById("postform");
|
||||
if(!e) return; // no post form on page
|
||||
|
||||
});
|
@ -0,0 +1 @@
|
||||
/** settings.js */
|
@ -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%;
|
||||
|
@ -0,0 +1,6 @@
|
||||
from django import template
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -5,9 +5,10 @@ from . import views
|
||||
urlpatterns = [
|
||||
url(r'^ctl-(?P<page>[0-9]+)\.html$', views.modlog, name='old-modlog'),
|
||||
url(r'^ctl/((?P<page>[0-9]+)/)?$', views.modlog, name='modlog'),
|
||||
url(r'^overchan\.(?P<name>[a-zA-z0-9\.]+)-(?P<page>[0-9]+)\.html$', views.BoardView.as_view(), name='old-board'),
|
||||
url(r'^overchan\.(?P<name>[a-zA-z0-9\.]+)/', views.BoardView.as_view(), name='board'),
|
||||
url(r'^overchan\.(?P<name>[a-zA-Z0-9\.]+)-(?P<page>[0-9]+)\.html$', views.BoardView.as_view(), name='old-board'),
|
||||
url(r'^overchan\.(?P<name>[a-zA-Z0-9\.]+)/', views.BoardView.as_view(), name='board-alt'),
|
||||
url(r'^thread-(?P<op>[a-fA-F0-9\.]{40})\.html$', views.ThreadView.as_view(), name='old-thread'),
|
||||
url(r'^b/(?P<name>[a-zA-Z0-9]+)/$', views.BoardView.as_view(), name='board'),
|
||||
url(r'^t/(?P<op>[a-fA-F0-9\.]{40})/$', views.ThreadView.as_view(), name='thread'),
|
||||
url(r'^$', views.FrontPageView.as_view(), name='index'),
|
||||
]
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -4,16 +4,22 @@
|
||||
<head>
|
||||
<title>{% block title %} nntpchan {% endblock %}</title>
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'style.css' %}" />
|
||||
<script type="text/javascript" href="{% static 'nntpchan.js' %}">
|
||||
</script>
|
||||
<script type="text/javascript" src="{% static 'hooks.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'postform.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'banners.js' %}"></script>
|
||||
<script type="text/javascript" src="{% static 'settings.js' %}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<div id="navbar">
|
||||
<span id="navbar_frontpage"><a href="/">nntpchan</a></span> |
|
||||
<span id="navbar_title">{% block navbar_title %}{% endblock %}</span> |
|
||||
<span id="navbar_links">{% block navbar_links %}{% endblock %}</span> |
|
||||
<span id="navbar_left">{% block navbar_left %}| <a href="#" onclick="nntpchan_toggle_settings()">settings</a>{% endblock %}</span>
|
||||
<div class="navbar left">
|
||||
<div id="navbar_frontpage"><a href="/">nntpchan</a></div> |
|
||||
<div id="navbar_title">{% block navbar_title %}{% endblock %}</div>
|
||||
<div id="navbar_links">{% block navbar_links %}{% endblock %}</div>
|
||||
</div>
|
||||
<div class="navbar right">
|
||||
<div>{% block navbar_left %}| <a href="#" onclick="nntpchan_toggle_settings_pane()">settings</a>{% endblock %}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
{% block content %}
|
||||
|
@ -12,7 +12,7 @@
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<hr />
|
||||
{% include "frontend/postform.html" %}
|
||||
{% for op in threads %}
|
||||
<div id="{{op.posthash}}" class="thread">
|
||||
<div class="post op">
|
||||
|
@ -0,0 +1,66 @@
|
||||
{% load captcha %}
|
||||
<div class="postform">
|
||||
<form id="postform" method="post" action="">
|
||||
{% csrf_token %}
|
||||
<table class="postform">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>
|
||||
</th>
|
||||
<td>
|
||||
<span>
|
||||
<input type="text" name="name" value="" id="postform_name" />
|
||||
<span id="postform_msg"></span>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="subject" value="" id="postform_subject" />
|
||||
<input type="submit" value="{{button}}" class="button" id="postform_submit" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
</th>
|
||||
<td>
|
||||
<textarea id="postform_message" name="message" cols=40 rows=5></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
</th>
|
||||
<td>
|
||||
<input class="postform_attachment" id="postform_attachments" type="file" name="attachment_uploaded" multiple />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
|
||||
</th>
|
||||
<td>
|
||||
<input type="checkbox" name="dubs" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
|
||||
</th>
|
||||
<td>
|
||||
<img id="captcha_img" src="{{ captcha }}" alt="captcha" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
</th>
|
||||
<td>
|
||||
<input type="text" name="captcha" autocomplete="off" id="captcha_solution" height="175" width="350"/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
</div>
|
@ -0,0 +1,15 @@
|
||||
{% extends "frontend/base.html" %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
{% if error %}
|
||||
<pre class="error"> failed to post {{error}} </pre>
|
||||
{% else %}
|
||||
{% if msgid %}
|
||||
<pre class="posted"> posted as {{msgid}} </pre>
|
||||
{% else %}
|
||||
<pre class="posted"> message was not posted </pre>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
2
contrib/frontends/django/requirements.txt
Normal file
2
contrib/frontends/django/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
captcha
|
||||
django
|
Reference in New Issue
Block a user