diff --git a/static/css/clif.css b/static/css/clif.css index be6f73a..85e0be8 100644 --- a/static/css/clif.css +++ b/static/css/clif.css @@ -393,6 +393,13 @@ div.commit { margin-top: .5rem; } + div.commit .raw_diff { + margin-top: 1rem; + font-family: monospace; + font-size: 1rem; + white-space: pre-wrap; + } + div.commit details.diff_view { border: 1px solid black; border: 1px solid #d4d4d4; diff --git a/templates/repository/commit.html b/templates/repository/commit.html index f89aea7..6f3d68e 100644 --- a/templates/repository/commit.html +++ b/templates/repository/commit.html @@ -101,6 +101,7 @@ + @@ -145,6 +146,12 @@ + {% if mode == 'udiff_raw' %} + +
{{ diff.patch|highlight_udiff|safe }}
+ + {% else %} + {% for patch in diff %}
@@ -345,6 +352,8 @@
{% endfor %} + + {% endif %} {% endblock %} diff --git a/web.py b/web.py index 1e36c61..eae3fc6 100644 --- a/web.py +++ b/web.py @@ -19,7 +19,7 @@ import subprocess import timeago from pygments import highlight -from pygments.lexers import guess_lexer, guess_lexer_for_filename +from pygments.lexers import guess_lexer, guess_lexer_for_filename, DiffLexer from pygments.formatters import HtmlFormatter @@ -45,7 +45,7 @@ INSTANCE_DOMAIN = 'domain.local' LOG_PAGINATION = 100 # Default options for showing diffs in "commit" page -DIFF_VIEW = 'udiff' # "udiff", "ssdiff" +DIFF_VIEW = 'udiff' # "udiff", "udiff_raw" "ssdiff" DIFF_CONTEXT_LINES = 3 DIFF_INTERHUNK_LINES = 0 DIFF_SIDE = 'normal' # "normal", "reverse" @@ -170,6 +170,7 @@ template = functools.partial(template, template_settings = { 'filemode': stat.filemode, # Human-friendly file size: 'human_size': human_size, + 'highlight_udiff': lambda string: highlight(string, DiffLexer(), HtmlFormatter()) }, 'globals': { 'commit_time': humanct, @@ -562,7 +563,7 @@ def commit(repository, commit_id): diff_mode = DIFF_VIEW if 'mode' in request.query: - if request.query.get('mode') in [ 'udiff', 'ssdiff' ]: + if request.query.get('mode') in [ 'udiff', 'udiff_raw', 'ssdiff' ]: diff_mode = request.query.get('mode') else: bottle.abort(400, 'Bad request: mode')