more
This commit is contained in:
parent
7a4c875fd5
commit
3fed1d8d41
@ -41,7 +41,7 @@ class Newsgroup(models.Model):
|
|||||||
banned = models.BooleanField(default=False)
|
banned = models.BooleanField(default=False)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
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):
|
class Post(models.Model):
|
||||||
"""
|
"""
|
||||||
@ -91,11 +91,11 @@ class Post(models.Model):
|
|||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
if self.is_op():
|
if self.is_op():
|
||||||
op = util.hashid(self.msgid)
|
op = util.hashid(self.msgid)
|
||||||
return reverse('thread', args=[op])
|
return reverse('frontend:thread', args=[op])
|
||||||
else:
|
else:
|
||||||
op = util.hashid(self.reference)
|
op = util.hashid(self.reference)
|
||||||
frag = util.hashid(self.msgid)
|
frag = util.hashid(self.msgid)
|
||||||
return reverse('thread', args=[op]) + '#{}'.format(frag)
|
return reverse('frontend:thread', args=[op]) + '#{}'.format(frag)
|
||||||
|
|
||||||
def bump(self):
|
def bump(self):
|
||||||
if self.is_op():
|
if self.is_op():
|
||||||
|
@ -2,6 +2,13 @@
|
|||||||
body, html {
|
body, html {
|
||||||
background: #EEF2FF url('/static/bg.png') repeat-x 50% 0%;
|
background: #EEF2FF url('/static/bg.png') repeat-x 50% 0%;
|
||||||
}
|
}
|
||||||
|
#logo {
|
||||||
|
height: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frontpage {
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
|
|
||||||
div {
|
div {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -20,7 +20,7 @@ class Postable:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def context_for_get(self, request, defaults):
|
def context_for_get(self, request, defaults):
|
||||||
defaults['captcha'] = reverse('captcha')
|
defaults['captcha'] = reverse('frontend:captcha')
|
||||||
defaults['refresh_url'] = request.path
|
defaults['refresh_url'] = request.path
|
||||||
return defaults
|
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]
|
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'})
|
ctx = self.context_for_get(request, {'threads': roots, 'page': page, 'name': newsgroup, 'button': 'new thread'})
|
||||||
if page < group.max_pages:
|
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:
|
if page == 1:
|
||||||
ctx['prevpage'] = reverse('board-front', args=[name])
|
ctx['prevpage'] = reverse('frontend:board-front', args=[name])
|
||||||
if page > 1:
|
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)
|
return render(request, self.template_name, ctx)
|
||||||
|
|
||||||
class ThreadView(generic.View, Postable):
|
class ThreadView(generic.View, Postable):
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<div id="navbar">
|
<div id="navbar">
|
||||||
<div class="navbar left">
|
<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_title">{% block navbar_title %}{% endblock %}</div>
|
||||||
<div id="navbar_links">{% block navbar_links %}{% endblock %}</div>
|
<div id="navbar_links">{% block navbar_links %}{% endblock %}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,5 +21,6 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^webhook$', views.webhook),
|
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)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
urlpatterns.append(url(r'', views.frontpage, name='frontpage'))
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.http import HttpResponse, HttpResponseNotAllowed, JsonResponse
|
from django.http import HttpResponse, HttpResponseNotAllowed, JsonResponse
|
||||||
|
from django.shortcuts import render
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
|
||||||
from .frontend.models import Post, Attachment, Newsgroup
|
from .frontend.models import Post, Attachment, Newsgroup
|
||||||
@ -13,6 +14,13 @@ from datetime import datetime
|
|||||||
import mimetypes
|
import mimetypes
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
def frontpage(request):
|
||||||
|
"""
|
||||||
|
frontpage for entire webapp
|
||||||
|
"""
|
||||||
|
return render(request, 'frontpage.html')
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def webhook(request):
|
def webhook(request):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user