Mercurial > wikked
diff tests/__init__.py @ 464:1dc6a0a74da3
wiki: Improve consistency of absolute/relative links.
- Make links from endpoint pages go to the same endpoint by default.
- Add support for `:` (empty) endpoint to link outside of endpoints.
- Add unit tests.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 06 Oct 2018 19:40:52 -0700 |
parents | 666a9d0981bb |
children | 0bfd648aca6a |
line wrap: on
line diff
--- a/tests/__init__.py Sat Oct 06 19:37:23 2018 -0700 +++ b/tests/__init__.py Sat Oct 06 19:40:52 2018 -0700 @@ -1,6 +1,6 @@ import os import os.path -import urllib.request, urllib.parse, urllib.error +import urllib.request, urllib.parse, urllib.error # noqa import shutil import unittest from wikked.wiki import Wiki @@ -64,15 +64,26 @@ wiki.reset() -def format_link(title, url, missing=False, mod=None): - res = '<a class=\"wiki-link' +def format_link(title, url, missing=False, mod=None, endpoint=None): + res = '<a class="wiki-link' if missing: res += ' missing' + res += '"' + + if endpoint: + url = '%s:%s' % (endpoint, url) url = urllib.parse.quote(url) - res += '\" data-wiki-url=\"' + url + '\"' + res += ' data-wiki-url="%s"' % url + if mod: - res += ' data-wiki-mod=\"' + mod + '\"' - res += ' href="/read' + url + '"' + res += ' data-wiki-mod="%s"' % mod + + if endpoint: + res += ' href="/read/%s"' % url + res += ' data-wiki-endpoint="%s"' % endpoint + else: + res += ' href="/read' + url + '"' + res += '>' + title + '</a>' return res