当前位置: 首页>>代码示例>>Python>>正文


Python Page.get_content方法代码示例

本文整理汇总了Python中pelican.contents.Page.get_content方法的典型用法代码示例。如果您正苦于以下问题:Python Page.get_content方法的具体用法?Python Page.get_content怎么用?Python Page.get_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pelican.contents.Page的用法示例。


在下文中一共展示了Page.get_content方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_content

# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import get_content [as 别名]
    def test_get_content(self):
        # Test that the content is updated with the relative links to
        # filenames, tags and categories.
        settings = get_settings()
        args = self.page_kwargs.copy()
        args['settings'] = settings

        # Tag
        args['content'] = ('A simple test, with a '
                           '<a href="|tag|tagname">link</a>')
        page = Page(**args)
        content = page.get_content('http://notmyidea.org')
        self.assertEqual(
            content,
            ('A simple test, with a '
             '<a href="http://notmyidea.org/tag/tagname.html">link</a>'))

        # Category
        args['content'] = ('A simple test, with a '
                           '<a href="|category|category">link</a>')
        page = Page(**args)
        content = page.get_content('http://notmyidea.org')
        self.assertEqual(
            content,
            ('A simple test, with a '
             '<a href="http://notmyidea.org/category/category.html">link</a>'))
开发者ID:52M,项目名称:pelican,代码行数:28,代码来源:test_contents.py

示例2: test_category_link_syntax

# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import get_content [as 别名]
    def test_category_link_syntax(self):
        "{category} link syntax triggers url replacement."

        html = '<a href="{category}foo">link</a>'
        page = Page(content=html,
            metadata={'title': 'fakepage'}, settings=self.settings,
            source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
            context=self.context)
        content = page.get_content('')

        self.assertNotEqual(content, html)
开发者ID:Windeal,项目名称:pelican,代码行数:13,代码来源:test_contents.py

示例3: test_link_to_unknown_file

# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import get_content [as 别名]
    def test_link_to_unknown_file(self):
        "{filename} link to unknown file should trigger warning."

        html = '<a href="{filename}foo">link</a>'
        page = Page(content=html,
                    metadata={'title': 'fakepage'}, settings=self.settings,
                    source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
                    context=self.context)
        content = page.get_content('')

        self.assertEqual(content, html)
        self.assertLogCountEqual(
            count=1,
            msg="Unable to find 'foo', skipping url replacement.",
            level=logging.WARNING)
开发者ID:Starch,项目名称:pelican,代码行数:17,代码来源:test_contents.py

示例4: test_unknown_link_syntax

# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import get_content [as 别名]
    def test_unknown_link_syntax(self):
        "{unknown} link syntax should trigger warning."

        html = '<a href="{unknown}foo">link</a>'
        page = Page(content=html,
                    metadata={'title': 'fakepage'}, settings=self.settings,
                    source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
                    context=self.context)
        content = page.get_content('')

        self.assertEqual(content, html)
        self.assertLogCountEqual(
            count=1,
            msg="Replacement Indicator 'unknown' not recognized, "
                "skipping replacement",
            level=logging.WARNING)
开发者ID:52M,项目名称:pelican,代码行数:18,代码来源:test_contents.py

示例5: test_attach_link_syntax

# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import get_content [as 别名]
    def test_attach_link_syntax(self):
        """{attach} link syntax triggers output path override & url replacement.
        """
        html = '<a href="{attach}../foo.jpg">link</a>'
        page = Page(content=html,
            metadata={'title': 'fakepage'}, settings=self.settings,
            source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
            context=self.context)
        content = page.get_content('')

        self.assertNotEqual(content, html,
            "{attach} link syntax did not trigger URL replacement.")

        expected_save_as = os.path.join('outpages', 'foo.jpg')
        self.assertEqual(self.static.save_as, expected_save_as)
        self.assertEqual(self.static.url, path_to_url(expected_save_as))
开发者ID:Windeal,项目名称:pelican,代码行数:18,代码来源:test_contents.py

示例6: test_index_link_syntax

# 需要导入模块: from pelican.contents import Page [as 别名]
# 或者: from pelican.contents.Page import get_content [as 别名]
    def test_index_link_syntax(self):
        "{index} link syntax triggers url replacement."

        html = '<a href="{index}">link</a>'
        page = Page(
            content=html,
            metadata={'title': 'fakepage'},
            settings=self.settings,
            source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
            context=self.context)
        content = page.get_content('')

        self.assertNotEqual(content, html)

        expected_html = ('<a href="' +
                         '/'.join((self.settings['SITEURL'],
                                   self.settings['INDEX_SAVE_AS'])) +
                         '">link</a>')
        self.assertEqual(content, expected_html)
开发者ID:52M,项目名称:pelican,代码行数:21,代码来源:test_contents.py


注:本文中的pelican.contents.Page.get_content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。