Browse Source

Small hax on pagination to combat duplicate content errors

Ralfp 12 years ago
parent
commit
d13d0efe9f
1 changed files with 9 additions and 0 deletions
  1. 9 0
      misago/utils/pagination.py

+ 9 - 0
misago/utils/pagination.py

@@ -4,6 +4,15 @@ from django.http import Http404
 def make_pagination(page, total, per):
 def make_pagination(page, total, per):
     pagination = {'start': 0, 'stop': 0, 'prev':-1, 'next':-1}
     pagination = {'start': 0, 'stop': 0, 'prev':-1, 'next':-1}
     page = int(page)
     page = int(page)
+
+    if page == 1:
+        # This is fugly abuse of "wrong page" handling
+        # It's done to combat "duplicate content" errors
+        # If page is 1 instead of 0, that suggests user came
+        # to page from somewhere/1/ instead of somewhere/
+        # when this happens We raise 404 to drop /1/ part from url
+        raise Http404()
+
     if page > 0:
     if page > 0:
         pagination['start'] = (page - 1) * per
         pagination['start'] = (page - 1) * per