diff --git a/templates/repository/commit.html b/templates/repository/commit.html index e3de9bf..7973425 100644 --- a/templates/repository/commit.html +++ b/templates/repository/commit.html @@ -60,7 +60,7 @@



-
+
{# pygit2 appears to recompute all the stats every time we use diff.stats, # therefore we set this variable in order to compute it only once. #} diff --git a/web.py b/web.py index 26ac0c5..62a2060 100644 --- a/web.py +++ b/web.py @@ -44,6 +44,14 @@ INSTANCE_DOMAIN = 'domain.local' # How many commits to show in the log page LOG_PAGINATION = 100 +# Default options when showing diffs in "commit" page +DIFF_VIEW = 'udiff' # "udiff", "ssdiff" +DIFF_CONTEXT_LINES = 3 +DIFF_INTERHUNK_LINES = 0 +DIFF_SHOW_DIFFSTAT = False +DIFF_SIDE = 'normal' # "normal", "reverse" +DIFF_WHITESPACE = 'include' # "include", "ignore_all", "ignore_change", "ignore_eol" + @@ -167,7 +175,10 @@ template = functools.partial(template, template_settings = { 'now': lambda: datetime.datetime.now(datetime.timezone.utc), 'request': request, 'url': application.get_url, - 'zip_longest': itertools.zip_longest + 'zip_longest': itertools.zip_longest, + 'defaults': { + 'DIFF_SHOW_DIFFSTAT': DIFF_SHOW_DIFFSTAT + } }, 'autoescape': True }) @@ -545,21 +556,21 @@ def commit(repository, commit_id): # Diff options - diff_mode = 'udiff' + diff_mode = DIFF_VIEW if 'mode' in request.query: if request.query.get('mode') in [ 'udiff', 'ssdiff' ]: diff_mode = request.query.get('mode') else: bottle.abort(400, 'Bad request: mode') - try: diff_context_lines = int(request.query.get('context_lines', 3)) + try: diff_context_lines = int(request.query.get('context_lines', DIFF_CONTEXT_LINES)) except: bottle.abort(400, 'Bad request: context_lines') - try: diff_inter_hunk_lines = int(request.query.get('inter_hunk_lines', 0)) + try: diff_inter_hunk_lines = int(request.query.get('inter_hunk_lines', DIFF_INTERHUNK_LINES)) except: bottle.abort(400, 'Bad request: inter_hunk_lines') diff_flags = pygit2.GIT_DIFF_NORMAL - diff_side = 'normal' + diff_side = DIFF_SIDE if 'side' in request.query: if request.query.get('side') == 'normal': diff_side = 'normal' @@ -569,7 +580,7 @@ def commit(repository, commit_id): else: bottle.abort(400, 'Bad request: side') - diff_whitespace = 'include' + diff_whitespace = DIFF_WHITESPACE if 'whitespace' in request.query: if request.query.get('whitespace') == 'include': diff_whitespace = 'include'