Author
|
zPlus <zplus@peers.community>
2022-08-08 07:13:55
|
Committer
|
zPlus <zplus@peers.community>
2022-08-08 07:13:55
|
Commit
|
0b2642a
(patch)
|
Tree
|
011a557
|
Parent(s)
|
|
Add option for showing raw udiff in commit page.
commits diff:
0f8df23..0b2642a
3 files changed,
20 insertions,
3 deletions
—
download
Diffstat
Diff options
+7/-0
M static/css/clif.css
393
|
393
|
|
margin-top: .5rem;
|
394
|
394
|
|
}
|
395
|
395
|
|
|
|
396
|
+ |
div.commit .raw_diff {
|
|
397
|
+ |
margin-top: 1rem;
|
|
398
|
+ |
font-family: monospace;
|
|
399
|
+ |
font-size: 1rem;
|
|
400
|
+ |
white-space: pre-wrap;
|
|
401
|
+ |
}
|
|
402
|
+ |
|
396
|
403
|
|
div.commit details.diff_view {
|
397
|
404
|
|
border: 1px solid black;
|
398
|
405
|
|
border: 1px solid #d4d4d4;
|
+9/-0
M templates/repository/commit.html
101
|
101
|
|
</td>
|
102
|
102
|
|
<td>
|
103
|
103
|
|
<label><input type="radio" name="mode" value="udiff" {{ 'checked' if mode == 'udiff' }}>Unified</label>
|
|
104
|
+ |
<label><input type="radio" name="mode" value="udiff_raw" {{ 'checked' if mode == 'udiff_raw' }}>Unified (raw)</label>
|
104
|
105
|
|
<label><input type="radio" name="mode" value="ssdiff" {{ 'checked' if mode == 'ssdiff' }}>Side by side</label>
|
105
|
106
|
|
</td>
|
106
|
107
|
|
</tr>
|
145
|
146
|
|
</form>
|
146
|
147
|
|
</details>
|
147
|
148
|
|
|
|
149
|
+ |
{% if mode == 'udiff_raw' %}
|
|
150
|
+ |
|
|
151
|
+ |
<div class="raw_diff">{{ diff.patch|highlight_udiff|safe }}</div>
|
|
152
|
+ |
|
|
153
|
+ |
{% else %}
|
|
154
|
+ |
|
148
|
155
|
|
{% for patch in diff %}
|
149
|
156
|
|
|
150
|
157
|
|
<details class="diff_view" {{ 'open' if defaults.DIFF_EXPAND }}>
|
345
|
352
|
|
</details>
|
346
|
353
|
|
|
347
|
354
|
|
{% endfor %}
|
|
355
|
+ |
|
|
356
|
+ |
{% endif %}
|
348
|
357
|
|
</div>
|
349
|
358
|
|
|
350
|
359
|
|
{% endblock %}
|
+4/-3
M web.py
19
|
19
|
|
import timeago
|
20
|
20
|
|
|
21
|
21
|
|
from pygments import highlight
|
22
|
|
- |
from pygments.lexers import guess_lexer, guess_lexer_for_filename
|
|
22
|
+ |
from pygments.lexers import guess_lexer, guess_lexer_for_filename, DiffLexer
|
23
|
23
|
|
from pygments.formatters import HtmlFormatter
|
24
|
24
|
|
|
25
|
25
|
|
|
45
|
45
|
|
LOG_PAGINATION = 100
|
46
|
46
|
|
|
47
|
47
|
|
# Default options for showing diffs in "commit" page
|
48
|
|
- |
DIFF_VIEW = 'udiff' # "udiff", "ssdiff"
|
|
48
|
+ |
DIFF_VIEW = 'udiff' # "udiff", "udiff_raw" "ssdiff"
|
49
|
49
|
|
DIFF_CONTEXT_LINES = 3
|
50
|
50
|
|
DIFF_INTERHUNK_LINES = 0
|
51
|
51
|
|
DIFF_SIDE = 'normal' # "normal", "reverse"
|
170
|
170
|
|
'filemode': stat.filemode,
|
171
|
171
|
|
# Human-friendly file size:
|
172
|
172
|
|
'human_size': human_size,
|
|
173
|
+ |
'highlight_udiff': lambda string: highlight(string, DiffLexer(), HtmlFormatter())
|
173
|
174
|
|
},
|
174
|
175
|
|
'globals': {
|
175
|
176
|
|
'commit_time': humanct,
|
562
|
563
|
|
|
563
|
564
|
|
diff_mode = DIFF_VIEW
|
564
|
565
|
|
if 'mode' in request.query:
|
565
|
|
- |
if request.query.get('mode') in [ 'udiff', 'ssdiff' ]:
|
|
566
|
+ |
if request.query.get('mode') in [ 'udiff', 'udiff_raw', 'ssdiff' ]:
|
566
|
567
|
|
diff_mode = request.query.get('mode')
|
567
|
568
|
|
else:
|
568
|
569
|
|
bottle.abort(400, 'Bad request: mode')
|