Skip to content

Commit

Permalink
Change pagination to use page numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
robhardwick committed Dec 5, 2011
1 parent 9ac23c9 commit 6a3e6a1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions main.py
Expand Up @@ -66,16 +66,16 @@ def get_nav(self, test, pos):
""" Get pagination nav URL"""
return None if test else '/%d' % (pos,)

def get(self, start=0):
def get(self, page=1):
"""Lists all available albums."""
start = int(start)
start = (int(page)-1) * settings.RPP
gifs = gif_gif.all().fetch(settings.RPP, start)
count = len(gifs)
self.render_to_response('index.html', {
'gifs': gifs,
'count': count,
'prev': self.get_nav(start < 1, start - settings.RPP),
'next': self.get_nav(count != settings.RPP, start + settings.RPP),
'prev': self.get_nav(start < 1, start - 1),
'next': self.get_nav(count != settings.RPP, start + 1),
})

application = webapp.WSGIApplication([
Expand Down
6 changes: 4 additions & 2 deletions templates/index.html
Expand Up @@ -16,6 +16,8 @@
</li>
{% endfor %}
</ul>
{% if prev %}<a class="prev" href="{{ prev }}">Previous</a>{% endif %}
{% if next %}<a class="next" href="{{ next }}">Next</a>{% endif %}
<div class="nav">
{% if prev %}<a class="prev" href="{{ prev }}">Previous</a>{% endif %}
{% if next %}<a class="next" href="{{ next }}">Next</a>{% endif %}
</div>
{% endblock %}

0 comments on commit 6a3e6a1

Please sign in to comment.