--- a/__init__.py Mon May 13 21:22:16 2013 +0700
+++ b/__init__.py Tue May 14 11:44:47 2013 +0700
@@ -70,6 +70,7 @@
try:
fctx = webutil.filectx(web.repo, req)
+ changeid = fctx.hex()[0:12]
text = fctx.data().decode("utf-8")
except ErrorResponse, inst:
try:
@@ -80,7 +81,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,