def new_index_page(page_to_copy, page_num, count, total_posts, posts_per_page, path): index_page = Page() index_page.copy(page_to_copy) index_page.url = '/' + path + '/index-%s' % count index_page.template = template.get_template('post.html') apply_filter('page-head', index_page) apply_filter('page-meta', index_page) apply_filter('page-menu', index_page) apply_filter('page-foot', index_page) total_pages = math.ceil(total_posts / posts_per_page) - 1 if page_num > 0: index_page.template.set_value('prevpage', '<< Newer posts') if page_num - 1 == 0: index_page.template.set_attribute('prevpage', 'href', 'index.html') else: index_page.template.set_attribute('prevpage', 'href', 'index-%s.html' % (page_num - 1)) if page_num < total_pages: index_page.template.set_value('nextpage', 'Older posts >>') index_page.template.set_attribute('nextpage', 'href', 'index-%s.html' % (page_num + 1)) if page_num > 0 and page_num < total_pages: index_page.template.set_value('pagelinksep', ' | ') index_page.template.repeat('posts', min(posts_per_page, total_posts - count)) return index_page