# HG changeset patch # User Jeff Hammel # Date 1340253281 25200 # Node ID d29100da202a18952a37295278412065fcff0972 # Parent 7f7f7313b4c4a3340749e5ddb394f0f6ec1b2f2b fix ?posts=5 diff -r 7f7f7313b4c4 -r d29100da202a bitsyblog/bitsyblog.py --- a/bitsyblog/bitsyblog.py Thu Nov 17 16:06:23 2011 -0800 +++ b/bitsyblog/bitsyblog.py Wed Jun 20 21:34:41 2012 -0700 @@ -156,7 +156,8 @@ """returns material pertaining to the root of the site""" path = request.path_info.strip('/') - n_links = self.number_of_links(request) + n_posts = self.number_of_posts(request) + n_links = self.number_of_links(request, n_posts) ### the front page if not path: @@ -164,8 +165,6 @@ ### feeds - n_posts = self.number_of_posts(request) - # site rss if path == 'rss': if n_posts is None: @@ -204,6 +203,7 @@ feed = None # not an rss/atom feed by default (flag) n_posts = self.number_of_posts(request, user) + n_links = self.number_of_links(request, n_posts, user) # special paths if path == [ 'post' ]: @@ -259,8 +259,6 @@ if request.GET.get('sort') == 'forward': blog = list(reversed(blog)) - n_links = self.number_of_links(request, user) - # write the blog if request.GET.get('format') == 'text': content = self.text_blog(blog) @@ -501,13 +499,11 @@ if n_posts is not None: try: n_posts = int(n_posts) - if n_links > 0 and n_links > n_posts: - n_links = n_posts # don't display more links than posts except (TypeError, ValueError): n_posts = None return n_posts - def number_of_links(self, request, user=None): + def number_of_links(self, request, n_posts=None, user=None): """return the number of links to display in the navigation""" n_links = request.GET.get('n') if n_links == 'all': @@ -516,6 +512,8 @@ n_links = int(n_links) except (TypeError, ValueError): n_links = self.n_links + if n_posts and n_links > 0 and n_links > n_posts: + n_links = n_posts # don't display more links than posts return n_links def get_blog(self, user, path, role='public', n_items=None): diff -r 7f7f7313b4c4 -r d29100da202a setup.py --- a/setup.py Thu Nov 17 16:06:23 2011 -0800 +++ b/setup.py Wed Jun 20 21:34:41 2012 -0700 @@ -1,7 +1,7 @@ from setuptools import setup, find_packages import sys, os -version = '2.4.1' +version = '2.4.2' try: description = file('README.txt').read()