--- a/__init__.py Mon May 13 21:49:24 2013 +0100
+++ b/__init__.py Mon May 20 22:02:59 2013 +0700
@@ -74,6 +74,7 @@
try:
fctx = webutil.filectx(web.repo, req)
+ changeid = fctx.hex()[0:12]
text = fctx.data().decode("utf-8")
except LookupError, inst:
try:
@@ -84,7 +85,23 @@
if util.binary(text):
return webcommands.rawfile(web, req, tmpl)
- md = markdown.Markdown(extensions=['wikilinks(base_url={0},end_url={1})'.format('', parts[1])])
+ base_url = tmpl.defaults['url'] + 'file/' + changeid + "/"
+ base_raw_url = tmpl.defaults['url'] + 'rawfile/' + changeid + "/"
+
+ def rebase(proc, e, attr):
+ uri = e.get(attr, '')
+ if '://' in uri or uri.startswith('/'):
+ return
+ base = base_url
+ if attr == 'src':
+ base = base_raw_url
+ e.set(attr, proc.rebase(base, uri))
+
+ ext = mdx_urlrebase.UrlRebaseExtension(configs=[('rebase', rebase)])
+ md = markdown.Markdown(
+ extensions=[ext, 'wikilinks'],
+ extension_configs={
+ 'wikilinks' : [('base_url', ""), ('end_url', parts[-1])]})
html = md.convert(text).encode("utf-8")
args = {'file':f,