diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py index 3e38604..661ea55 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/urls.py @@ -8,7 +8,8 @@ urlpatterns = [ 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\.]+[a-zA-Z0-9])/$', views.BoardView.as_view(), name='board'), + url(r'^b/(?P[a-zA-Z0-9\.]+[a-zA-Z0-9])/$', views.BoardView.as_view(), name='board-front'), + url(r'^b/(?P[a-zA-Z0-9\.]+[a-zA-Z0-9])/(?P[0-9]+)/$', views.BoardView.as_view(), name='board'), url(r'^t/(?P[a-fA-F0-9\.]{40})/$', views.ThreadView.as_view(), name='thread'), url(r'captcha.png', views.create_captcha, name='captcha'), url(r'^$', views.FrontPageView.as_view(), name='index'), diff --git a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py index 7376d37..7d108bf 100644 --- a/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py +++ b/contrib/frontends/django/nntpchan/nntpchan/frontend/views.py @@ -62,10 +62,7 @@ class BoardView(generic.View, Postable): return util.createPost(name, None, request.POST, request.FILES) - def get(self, request, name): - page = 0 - if 'p' in request.GET: - page = request.GET['p'] + def get(self, request, name, page="0"): newsgroup = 'overchan.{}'.format(name) try: page = int(page or "0") @@ -83,9 +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]) + '?p={}'.format(page + 1) - if page > 0: - ctx['prevpage'] = reverse('board', args=[name]) + '?p={}'.format(page - 1) + ctx['nextpage'] = reverse('board', args=[name, page + 1]) + if page == 1: + ctx['prevpage'] = reverse('board-front', args=[name]) + if page > 1: + ctx['prevpage'] = reverse('board', args=[name, page - 1]) return render(request, self.template_name, ctx) class ThreadView(generic.View, Postable):