# HG changeset patch # User Chris Eldredge # Date 1344634896 -3600 # Node ID b9bf34a94aad712a0058782542d68005846a1ca8 # Parent 1d3416da68e052588f4c60daa512e6a9b2031151 Send requests with empty path or non-markdown files to "file" command. diff -r 1d3416da68e0 -r b9bf34a94aad __init__.py --- a/__init__.py Thu Aug 09 23:47:58 2012 +0100 +++ b/__init__.py Fri Aug 10 22:41:36 2012 +0100 @@ -11,16 +11,19 @@ logging.basicConfig() def filerevision_markdown(web, req, tmpl): - f = req.form.get('file', [''])[0] - parts = os.path.splitext(f) + path = webutil.cleanpath(web.repo, req.form.get('file', [''])[0]) + parts = os.path.splitext(path) + + if not parts[1] == '.markdown' and not parts[1] == '.md': + return webcommands.file(web, req, tmpl) - if not parts[1] == '.markdown' and not parts[1] == '.md': - return rawfile(web, req, tmpl) + if not path: + return webcommands.file(web, req, tmpl) previewMode = 'node' in req.form and req.form['node'][0] == '_preview' if previewMode: - text = file(web.repo.root + "/" + f).read() + text = file(web.repo.root + "/" + path).read() else: fctx = webutil.filectx(web.repo, req) text = fctx.data() @@ -32,9 +35,9 @@ md = markdown.Markdown(extensions=['wikilinks(base_url={0},end_url={1})'.format('', parts[1])]) html = md.convert(text) - args = {'file':f, + args = {'file':path, 'readmefilename':parts[0].split('/')[-1], - 'path':webutil.up(f), + 'path':webutil.up(path), 'readme':html} if previewMode: