mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Add categories and tags to the replacement mechanism.
This commit is contained in:
parent
2a599b8646
commit
e2ca6d7608
3 changed files with 32 additions and 0 deletions
|
|
@ -459,6 +459,10 @@ following to ``pelicanconf.py``::
|
|||
|
||||
And then the ``pdfs`` directory would also be copied to ``output/static/``.
|
||||
|
||||
You can also link to categories or tags, using the `|tag|tagname` and
|
||||
`|category|foobar` syntax.
|
||||
|
||||
|
||||
Importing an existing blog
|
||||
--------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -216,6 +216,10 @@ class Content(object):
|
|||
else:
|
||||
logger.warning("Unable to find {fn}, skipping url"
|
||||
" replacement".format(fn=value))
|
||||
elif what == 'category':
|
||||
origin = Category(value, self.settings).url
|
||||
elif what == 'tag':
|
||||
origin = Tag(value, self.settings).url
|
||||
|
||||
return ''.join((m.group('markup'), m.group('quote'), origin,
|
||||
m.group('quote')))
|
||||
|
|
|
|||
|
|
@ -180,6 +180,30 @@ class TestPage(unittest.TestCase):
|
|||
Page(**self.page_kwargs)
|
||||
self.assertTrue(content_object_init.has_receivers_for(Page))
|
||||
|
||||
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.assertEquals(content, ('A simple test, with a '
|
||||
'<a href="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.assertEquals(content,
|
||||
('A simple test, with a '
|
||||
'<a href="category/category.html">link</a>'))
|
||||
|
||||
|
||||
class TestArticle(TestPage):
|
||||
def test_template(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue