mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Prepend siteurl (or relative_url) to {tag} and {category} links
This commit is contained in:
parent
ef96705677
commit
89f5cadef2
2 changed files with 24 additions and 7 deletions
|
|
@ -244,9 +244,10 @@ class Content(object):
|
|||
"Other resources were not found"
|
||||
" and their urls not replaced"))
|
||||
elif what == 'category':
|
||||
origin = Category(path, self.settings).url
|
||||
origin = '/'.join((siteurl,
|
||||
Category(path, self.settings).url))
|
||||
elif what == 'tag':
|
||||
origin = Tag(path, self.settings).url
|
||||
origin = '/'.join((siteurl, Tag(path, self.settings).url))
|
||||
|
||||
# keep all other parts, such as query, fragment, etc.
|
||||
parts = list(value)
|
||||
|
|
|
|||
|
|
@ -212,17 +212,33 @@ class TestPage(unittest.TestCase):
|
|||
'<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="tag/tagname.html">link</a>'))
|
||||
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="category/category.html">link</a>'))
|
||||
self.assertEqual(
|
||||
content,
|
||||
'A simple test, with a '
|
||||
'<a href="http://notmyidea.org/category/category.html">link</a>'
|
||||
)
|
||||
|
||||
# relative_url
|
||||
args['content'] = ('A simple test, with a '
|
||||
'<a href="|category|category">link</a>')
|
||||
page = Page(**args)
|
||||
content = page.get_content('../../..')
|
||||
self.assertEqual(
|
||||
content,
|
||||
'A simple test, with a '
|
||||
'<a href="../../../category/category.html">link</a>'
|
||||
)
|
||||
|
||||
def test_intrasite_link(self):
|
||||
# type does not take unicode in PY2 and bytes in PY3, which in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue