Mercurial > wikked
changeset 334:be7275021f3a
Fix asset URL formatting.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 19 Apr 2015 19:58:49 -0700 |
parents | 861b581749b0 |
children | cc038c636901 |
files | tests/test_page.py wikked/formatter.py |
diffstat | 2 files changed, 6 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_page.py Wed Mar 11 15:35:17 2015 -0700 +++ b/tests/test_page.py Sun Apr 19 19:58:49 2015 -0700 @@ -75,7 +75,6 @@ '/sub_dir/Second.txt': "Go back to [[../First]], or to [[Second Sibling]].", '/sub_dir/Second Sibling.txt': "Go back to [[Second]]." }) - print str(list(wiki.getPageUrls())) first = wiki.getPage('/First') self.assertEqual(['/First Sibling'], first.links) first2 = wiki.getPage('/First Sibling') @@ -94,7 +93,7 @@ def testImageUrl(self): wiki = self._getWikiFromStructure({ - '/foo.txt': "URL: [[blah|url:/blah/boo/image.png]]" + '/foo.txt': "URL: [[blah|asset:/blah/boo/image.png]]" }) foo = wiki.getPage('/foo') self.assertEqual("URL: <img src=\"/files/blah/boo/image.png\" alt=\"blah\"></img>", foo.getFormattedText())
--- a/wikked/formatter.py Wed Mar 11 15:35:17 2015 -0700 +++ b/wikked/formatter.py Sun Apr 19 19:58:49 2015 -0700 @@ -194,11 +194,11 @@ def _formatUrlLink(self, ctx, endpoint, value, display): if value.startswith('/'): - return '/files' + value - - abs_url = os.path.join('/files', ctx.urldir, value) - abs_url = os.path.normpath(abs_url).replace('\\', '/') - return abs_url + abs_url = '/files' + value + else: + abs_url = os.path.join('/files', ctx.urldir, value) + abs_url = os.path.normpath(abs_url).replace('\\', '/') + return '<a class="wiki-asset" href="%s">%s</a>' % (abs_url, display) def _formatAssetLink(self, ctx, endpoint, value, display): img_exts = ['.jpg', '.jpeg', '.png', '.gif']