From 89f5cadef245dec1bf7b8407ac816a26b2041850 Mon Sep 17 00:00:00 2001 From: Daniel Richman Date: Sun, 10 Nov 2013 12:30:26 +0000 Subject: [PATCH] Prepend siteurl (or relative_url) to {tag} and {category} links --- pelican/contents.py | 5 +++-- pelican/tests/test_contents.py | 26 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/pelican/contents.py b/pelican/contents.py index 615a7fd8..85543985 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -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) diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index 3c0f8d75..2d21fd24 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -212,17 +212,33 @@ class TestPage(unittest.TestCase): 'link') page = Page(**args) content = page.get_content('http://notmyidea.org') - self.assertEqual(content, ('A simple test, with a ' - 'link')) + self.assertEqual( + content, + 'A simple test, with a ' + 'link' + ) # Category args['content'] = ('A simple test, with a ' 'link') page = Page(**args) content = page.get_content('http://notmyidea.org') - self.assertEqual(content, - ('A simple test, with a ' - 'link')) + self.assertEqual( + content, + 'A simple test, with a ' + 'link' + ) + + # relative_url + args['content'] = ('A simple test, with a ' + 'link') + page = Page(**args) + content = page.get_content('../../..') + self.assertEqual( + content, + 'A simple test, with a ' + 'link' + ) def test_intrasite_link(self): # type does not take unicode in PY2 and bytes in PY3, which in