author | Alberto Bertogli
<albertito@blitiri.com.ar> 2013-11-02 21:12:50 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2013-11-02 21:12:50 UTC |
parent | a42d7da6a4c33d12c0af1847ba4512b1a3f70287 |
git-arr | +5 | -0 |
utils.py | +9 | -6 |
views/blob.html | +2 | -2 |
diff --git a/git-arr b/git-arr index 9b3c246..a9737ac 100755 --- a/git-arr +++ b/git-arr @@ -55,6 +55,8 @@ def load_config(path): 'web_url_file': 'web_url', 'git_url': '', 'git_url_file': 'cloneurl', + 'embed_markdown': 'yes', + 'embed_images': 'no', } config = configparser.SafeConfigParser(defaults) @@ -115,6 +117,9 @@ def load_config(path): if not r.info.git_url and os.path.isfile(git_url_file): r.info.git_url = open(git_url_file).read() + r.info.embed_markdown = config.getboolean(s, 'embed_markdown') + r.info.embed_images = config.getboolean(s, 'embed_images') + repos[r.name] = r def find_git_dir(path): diff --git a/utils.py b/utils.py index b40624b..51141e4 100644 --- a/utils.py +++ b/utils.py @@ -48,20 +48,23 @@ def can_colorize(s): return True -def can_markdown(fname): +def can_markdown(repo, fname): """True if we can process file through markdown, False otherwise.""" if markdown is None: return False + if not repo.info.embed_markdown: + return False + return fname.endswith(".md") -def can_embed_image(fname): +def can_embed_image(repo, fname): """True if we can embed image file in HTML, False otherwise.""" - exts = [ 'jpg', 'jpeg', 'png', 'gif' ] - if '.' in fname and fname.split('.')[-1].lower() in exts: - return True + if not repo.info.embed_images: + return False - return False + return (('.' in fname) and + (fname.split('.')[-1].lower() in [ 'jpg', 'jpeg', 'png', 'gif' ])) def colorize_diff(s): lexer = lexers.DiffLexer(encoding = 'utf-8') diff --git a/views/blob.html b/views/blob.html index 320cc89..9d0e9ff 100644 --- a/views/blob.html +++ b/views/blob.html @@ -36,9 +36,9 @@ <a href="">{{!fname.html}}</a> </h3> -% if can_embed_image(fname.unicode): +% if can_embed_image(repo, fname.unicode): {{!embed_image_blob(repo, dirname.raw, fname.raw)}} -% elif can_markdown(fname.unicode): +% elif can_markdown(repo, fname.unicode): {{!markdown_blob(blob)}} % elif can_colorize(blob): {{!colorize_blob(fname.unicode, blob)}}