Exemple #1
0
    def run(self, posts=None):
        posts = posts or self.posts
        page = Pagination(posts, base_url=self.base_url, posts_per_page=self.num_per_page)

        for n, p in enumerate(page.iterate()):
            content = self.render(p)
            logging.debug("Write file %s", p.file_path, prefix="   ↳  ")
            self.write_to_file(p.file_path, content)
Exemple #2
0
    def run(self, posts=None):
        posts = posts or self.posts
        page = Pagination(posts,
                          base_url=self.base_url,
                          posts_per_page=self.num_per_page)

        for n, p in enumerate(page.iterate()):
            content = self.render(p)
            logging.debug('Write file %s', p.file_path, prefix='   ↳  ')
            self.write_to_file(p.file_path, content)
Exemple #3
0
    def test_pagination(self):
        posts = []
        for i in range(0, 10):
            title = "post_{}".format(i)
            posts.append(Post(title, title, title))

        page = Pagination(posts, base_url="tags/test/", posts_per_page=2)

        self.assertEqual(page.page, 1)
        self.assertEqual(page.total, 5)
        self.assertListEqual(page.posts, posts[0:2])

        self.assertIsNone(page.prev)

        next = page.next
        self.assertListEqual(next.posts, posts[2:4])

        n = 0
        for p in page.iterate():
            self.assertEqual(p.page, n + 1)
            self.assertListEqual(p.posts, posts[n * 2 : n * 2 + 2])
            n += 1
Exemple #4
0
    def test_pagination(self):
        posts = []
        for i in range(0, 10):
            title = 'post_{}'.format(i)
            posts.append(Post(title, title, title))

        page = Pagination(posts, base_url='tags/test/', posts_per_page=2)

        self.assertEqual(page.page, 1)
        self.assertEqual(page.total, 5)
        self.assertListEqual(page.posts, posts[0:2])

        self.assertIsNone(page.prev)

        next = page.next
        self.assertListEqual(next.posts, posts[2:4])

        n = 0
        for p in page.iterate():
            self.assertEqual(p.page, n + 1)
            self.assertListEqual(p.posts, posts[n * 2:n * 2 + 2])
            n += 1