summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorAlberto Bertogli <albertito@blitiri.com.ar>2013-11-02 22:12:50 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2013-11-02 22:12:50 +0100
commit54026b7585badf3736ad97f6f6e1d656d9f469e2 (patch)
tree044e2ce2a547c1a21148c4f3d8e439696c1e2679 /utils.py
parenta42d7da6a4c33d12c0af1847ba4512b1a3f70287 (diff)
downloadgit-arr-fork-54026b7585badf3736ad97f6f6e1d656d9f469e2.zip
Make embedding markdown and images configurable per-repo
This patch introduces the embed_markdown and embed_images configuration options, so users can enable and disable those features on a per-repository basis. Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py15
1 files changed, 9 insertions, 6 deletions
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')