Esempio n. 1
0
    def test_custom_pagination_pattern(self):
        from pelican.paginator import PaginationRule
        settings = get_settings()
        settings['PAGINATION_PATTERNS'] = [PaginationRule(*r) for r in [
            (1, '/{url}', '{base_name}/index.html'),
            (2, '/{url}{number}/', '{base_name}/{number}/index.html')
        ]]

        self.page_kwargs['metadata']['author'] = Author('Blogger', settings)
        object_list = [Article(**self.page_kwargs),
                       Article(**self.page_kwargs)]
        paginator = Paginator('blog/index.html', '//blog.my.site/',
                              object_list, settings, 1)
        page1 = paginator.page(1)
        self.assertEqual(page1.save_as, 'blog/index.html')
        self.assertEqual(page1.url, '//blog.my.site/')
        page2 = paginator.page(2)
        self.assertEqual(page2.save_as, 'blog/2/index.html')
        self.assertEqual(page2.url, '//blog.my.site/2/')
    def test_custom_pagination_pattern(self):
        from pelican.paginator import PaginationRule
        settings = get_settings()
        settings['PAGINATION_PATTERNS'] = [
            PaginationRule(*r)
            for r in [(1, '/{url}', '{base_name}/index.html'),
                      (2, '/{url}{number}/',
                       '{base_name}/{number}/index.html')]
        ]

        self.page_kwargs['metadata']['author'] = Author('Blogger', settings)
        object_list = [
            Article(**self.page_kwargs),
            Article(**self.page_kwargs)
        ]
        paginator = Paginator('blog/index.html', '//blog.my.site/',
                              object_list, settings, 1)
        page1 = paginator.page(1)
        self.assertEqual(page1.save_as, 'blog/index.html')
        self.assertEqual(page1.url, 'blog.my.site/')
        page2 = paginator.page(2)
        self.assertEqual(page2.save_as, 'blog/2/index.html')
        self.assertEqual(page2.url, 'blog.my.site/2/')
    def test_save_as_preservation(self):
        settings = get_settings()
        # fix up pagination rules
        from pelican.paginator import PaginationRule

        pagination_rules = [
            PaginationRule(*r) for r in settings.get("PAGINATION_PATTERNS", DEFAULT_CONFIG["PAGINATION_PATTERNS"])
        ]
        settings["PAGINATION_PATTERNS"] = sorted(pagination_rules, key=lambda r: r[0])

        self.page_kwargs["metadata"]["author"] = Author("Blogger", settings)
        object_list = [Article(**self.page_kwargs), Article(**self.page_kwargs)]
        paginator = Paginator("foobar.foo", object_list, settings)
        page = paginator.page(1)
        self.assertEqual(page.save_as, "foobar.foo")
Esempio n. 4
0
    def test_save_as_preservation(self):
        settings = get_settings()
        # fix up pagination rules
        from pelican.paginator import PaginationRule
        pagination_rules = [
            PaginationRule(*r) for r in settings.get(
                'PAGINATION_PATTERNS',
                DEFAULT_CONFIG['PAGINATION_PATTERNS'],
            )
        ]
        settings['PAGINATION_PATTERNS'] = sorted(
            pagination_rules,
            key=lambda r: r[0],
        )

        object_list = [Article(**self.page_kwargs), Article(**self.page_kwargs)]
        paginator = Paginator('foobar.foo', object_list, settings)
        page = paginator.page(1)
        self.assertEqual(page.save_as, 'foobar.foo')
Esempio n. 5
0
    def test_save_as_preservation(self):
        settings = get_settings()
        # fix up pagination rules
        from pelican.paginator import PaginationRule
        pagination_rules = [
            PaginationRule(*r) for r in settings.get(
                'PAGINATION_PATTERNS',
                DEFAULT_CONFIG['PAGINATION_PATTERNS'],
            )
        ]
        settings['PAGINATION_PATTERNS'] = sorted(
            pagination_rules,
            key=lambda r: r[0],
        )

        object_list = [
            Article(**self.page_kwargs),
            Article(**self.page_kwargs)
        ]
        paginator = Paginator('foobar.foo', object_list, settings)
        page = paginator.page(1)
        self.assertEqual(page.save_as, 'foobar.foo')