# HG changeset patch # User Ludovic Chabant # Date 1412835722 25200 # Node ID 59dd71d4a69a7cfeb3fc6748c522029f8e934f0e # Parent edefa7e66e31d5cd65b1e1dacfea0d94982a424d 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. diff -r edefa7e66e31 -r 59dd71d4a69a wikked/formatter.py --- 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('/'):