Commits

offline committed b053686

paginator variable names changed

Comments (0)

Files changed (6)

simplepagination/__init__.py

-# coding: utf-8
-
 from functools import partial, update_wrapper
 
 from django.utils.datastructures import MultiValueDictKeyError
         self.key = key or self.backend.KEY
         self.per_page = per_page or self.backend.PER_PAGE
         self.frame_size = frame_size or self.backend.FRAME_SIZE
-        self.template = template or self.backend.TEMPLATE or 'paginator_%s.html' % style
+        self.template = template or self.backend.TEMPLATE or 'paginator_%s.html' % self.style
         self.user_per_page_allowed = self.backend.USER_PER_PAGE_ALLOWED
         self.user_per_page_max = self.backend.USER_PER_PAGE_MAX
         
         params = request.GET.copy()
         
         try:
-            page_num = int(params.pop('page')[0])
+            current_page = int(params.pop('page')[0])
         except (ValueError, KeyError):
-            page_num = 1
+            current_page = 1
         
         # we dont modify self.per_page because it's decorator
         # and it initialize only once.
         
         try:
             # check that asked page is exists
-            page = paginator.page(page_num)
+            page = paginator.page(current_page)
         except EmptyPage:
             raise Http404()
 
         
         # extra data that we may need to build links
         data = {}
-        data['page_num'] = page_num # active page number
+        data['current_page'] = current_page # active page number
         data['per_page'] = per_page # items per page
         data['params'] = unicode_urlencode(params) # get parameters
         data['anchor'] = self.anchor # ancor
-        data['pages'] = pages = paginator.num_pages # number of pages
-        data['paginator_template'] = self.template
+        data['number_of_pages'] = number_of_pages = paginator.num_pages # number of pages
+        data['template'] = self.template
 
         # execute the pagination function
-        data.update(self.backend.paginate(self.frame_size, pages, page_num))
+        data.update(self.backend.paginate(self.frame_size, number_of_pages, current_page))
 
         # your view now have extra key 'paginator' with all extra data inside.
         output['paginator'] = data

simplepagination/templates/paginator.html

 {% load paginator %}
 
-{% include paginator_template %}
+{% include paginator.template %}

simplepagination/templates/paginator_digg.html

 
 {% if paginator.left_page_numbers %}
   {% for i in paginator.left_page_numbers %}
-    {% ifequal i paginator.page_num %}
+    {% ifequal i paginator.current_page %}
       <span class="digg_pages_disabled">{{ i }}</span>
     {% else %}
       <a class="digg_pages" href='{% page_link i paginator.params paginator.anchor %}'>{{ i }}</a>
 {% if paginator.middle_page_numbers %}
   <span class="digg_seperator">...</span>
   {% for i in paginator.middle_page_numbers %}
-    {% ifequal i paginator.page_num %}
+    {% ifequal i paginator.current_page %}
       <span class="digg_pages_disabled">{{ i }}</span>
     {% else %}
       <a class="digg_pages" href='{% page_link i paginator.params paginator.anchor %}'>{{ i }}</a>
 {% if paginator.right_page_numbers %}
   <span class="digg_seperator">...</span>
     {% for i in paginator.right_page_numbers %}
-      {% ifequal i paginator.page_num %}
+      {% ifequal i paginator.current_page %}
         <span class="digg_pages_disabled">{{ i }}</span>
       {% else %}
         <a class="digg_pages" href='{% page_link i paginator.params paginator.anchor %}'>{{ i }}</a>

simplepagination/templates/paginator_filmfeed.html

 {% load paginator %}
 
 {% for i in paginator.page_numbers %}
-    {% ifequal i paginator.page_num %}
+    {% ifequal i paginator.current_page %}
         <span class="filmfeed_pages_disabled">{{ i }}</span>
     {% else %}
         <a href='{% page_link i paginator.params paginator.anchor %}' class="filmfeed_pages">{{ i }}</a>

simplepagination/templates/paginator_muzx.html

-{% load paginator %}
-
-<div id="muzx_paginator">
-  <div id="muzx_paginator_left">
-    {% for i in page_numbers %}
-      {% ifequal i page_num %}
-        <a href='{% page_link i params anchor %}' class="muzx_pages_current">{{ i }}</a>
-      {% else %}
-        <a href='{% page_link i params anchor %}' class="muzx_pages">{{ i }}</a>
-      {% endifequal %}
-    {% endfor %}
-  </div>
-  {% if allow_user_per_page %}
-    <div id="muzx_paginator_right">
-      <select>
-        <option value="?per_page=10">10</option>
-        <option value="?per_page=20">20</option>
-        <option value="?per_page=50">50</option>
-      </select>
-    </div>
-  {% endif %}
-</div>

simplepagination/templatetags/paginator.py

-# -*- coding: utf-8 -*-
+from django.template import Library
 
-from django.template import Library
 
 register = Library()
 
-
 @register.simple_tag
-def page_link(num_page, params, anchor):
-    link = '?page=%s' % num_page
+def page_link(page_number, params, anchor):
+    link = '?page=%s' % page_number
     if params:
         link = '%s&amp;%s' % (link, params.replace('&', '&amp;'))
     if anchor:
         link += '#%s' % anchor
     return link
-
-
-@register.inclusion_tag('paginator.html')
-def paginate(obj):
-    return obj
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.