Mercurial > wikked
changeset 314:59dd71d4a69a
The `url:` endpoint just returns URLs.
The new `asset:` endpoint tries to generate "appropriate" HTML tags and other
cleverness for quick handling of the majority cases.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 08 Oct 2014 23:22:02 -0700 |
parents | edefa7e66e31 |
children | e07eee5e101a |
files | wikked/formatter.py |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/wikked/formatter.py Sun Oct 05 07:48:01 2014 -0700 +++ b/wikked/formatter.py Wed Oct 08 23:22:02 2014 -0700 @@ -45,7 +45,8 @@ 'query': self._processQuery } self.endpoints = { - 'url': self._formatUrlLink + 'url': self._formatUrlLink, + 'asset': self._formatAssetLink } def formatText(self, ctx, text): @@ -192,6 +193,14 @@ mod_attr, '|'.join(processed_args)) 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 + + def _formatAssetLink(self, ctx, endpoint, value, display): img_exts = ['.jpg', '.jpeg', '.png', '.gif'] base, ext = os.path.splitext(value) if value.startswith('/'):