Archived
1
0
This commit is contained in:
Jeff Becker 2016-11-07 09:52:00 -05:00
parent 7a4c875fd5
commit 3fed1d8d41
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
6 changed files with 25 additions and 9 deletions

View File

@ -41,7 +41,7 @@ class Newsgroup(models.Model):
banned = models.BooleanField(default=False)
def get_absolute_url(self):
return reverse('board-front', args=[self.name[9:]])
return reverse('frontend:board-front', args=[self.name[9:]])
class Post(models.Model):
"""
@ -91,11 +91,11 @@ class Post(models.Model):
def get_absolute_url(self):
if self.is_op():
op = util.hashid(self.msgid)
return reverse('thread', args=[op])
return reverse('frontend:thread', args=[op])
else:
op = util.hashid(self.reference)
frag = util.hashid(self.msgid)
return reverse('thread', args=[op]) + '#{}'.format(frag)
return reverse('frontend:thread', args=[op]) + '#{}'.format(frag)
def bump(self):
if self.is_op():

View File

@ -2,6 +2,13 @@
body, html {
background: #EEF2FF url('/static/bg.png') repeat-x 50% 0%;
}
#logo {
height: 500px;
}
.frontpage {
align-self: center;
}
div {
display: flex;

View File

@ -20,7 +20,7 @@ class Postable:
"""
def context_for_get(self, request, defaults):
defaults['captcha'] = reverse('captcha')
defaults['captcha'] = reverse('frontend:captcha')
defaults['refresh_url'] = request.path
return defaults
@ -80,11 +80,11 @@ class BoardView(generic.View, Postable):
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, 'button': 'new thread'})
if page < group.max_pages:
ctx['nextpage'] = reverse('board', args=[name, page + 1])
ctx['nextpage'] = reverse('frontend:board', args=[name, page + 1])
if page == 1:
ctx['prevpage'] = reverse('board-front', args=[name])
ctx['prevpage'] = reverse('frontend:board-front', args=[name])
if page > 1:
ctx['prevpage'] = reverse('board', args=[name, page - 1])
ctx['prevpage'] = reverse('frontend:board', args=[name, page - 1])
return render(request, self.template_name, ctx)
class ThreadView(generic.View, Postable):

View File

@ -14,7 +14,7 @@
<div id="wrapper">
<div id="navbar">
<div class="navbar left">
<div id="navbar_frontpage"><a href="{% url 'frontpage' %}">nntpchan</a></div> |
{% block navbar_frontpage %}<div id="navbar_frontpage"><a href="{% url 'frontend:frontpage' %}">nntpchan</a></div> |{% endblock %}
<div id="navbar_title">{% block navbar_title %}{% endblock %}</div>
<div id="navbar_links">{% block navbar_links %}{% endblock %}</div>
</div>

View File

@ -21,5 +21,6 @@ from . import views
urlpatterns = [
url(r'^webhook$', views.webhook),
url(r'^nntpchan/', include('nntpchan.frontend.urls'))
url(r'^nntpchan/', include('nntpchan.frontend.urls', namespace='frontend'), name='nntpchan'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns.append(url(r'', views.frontpage, name='frontpage'))

View File

@ -1,5 +1,6 @@
from django.conf import settings
from django.http import HttpResponse, HttpResponseNotAllowed, JsonResponse
from django.shortcuts import render
from django.views.decorators.csrf import csrf_exempt
from .frontend.models import Post, Attachment, Newsgroup
@ -13,6 +14,13 @@ from datetime import datetime
import mimetypes
import os
def frontpage(request):
"""
frontpage for entire webapp
"""
return render(request, 'frontpage.html')
@csrf_exempt
def webhook(request):
"""