本文整理汇总了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>'))
示例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)
示例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)
示例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)
示例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))
示例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)