diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index c15b34d..04fdfc7 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -77,7 +77,6 @@ pre { .code_table tr .cell1{ width: 20px; - background: #fff; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; @@ -170,7 +169,8 @@ z-index:1; } .prc { - min-width: 13px; + min-width: 22px; + text-align: center; } .prc p { diff --git a/pagure/templates/_repo_renderdiff.html b/pagure/templates/_repo_renderdiff.html index 31f32ed..fbf5e45 100644 --- a/pagure/templates/_repo_renderdiff.html +++ b/pagure/templates/_repo_renderdiff.html @@ -265,6 +265,7 @@ commit=patch_new_id, prequest=pull_request, index=loop.index, + isprdiff=True, tree_id=diff_commits[0].tree.id)}} {% endautoescape %} diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index 33bb6d6..c08e13a 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -76,7 +76,7 @@ def format_ts(string): @UI_NS.app_template_filter('format_loc') def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, - index=None): + index=None, isprdiff=False): """ Template filter putting the provided lines of code into a table """ if loc is None: @@ -108,11 +108,35 @@ def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, if filename and commit: if isinstance(filename, str) and six.PY2: filename = filename.decode('UTF-8') + + if isprdiff and (line.startswith('@@') or + line.startswith('+') or + line.startswith('-')): + if line.startswith('@@'): + output.append( + '' + % ({'cnt_lbl': cnt, 'commit': commit})) + elif line.startswith('+'): + output.append( + '' + % ({'cnt_lbl': cnt, 'commit': commit})) + elif line.startswith('-'): + output.append( + '' + % ({'cnt_lbl': cnt, 'commit': commit})) + else: + output.append( + '' + % ({'cnt_lbl': cnt, 'commit': commit})) + output.append( - '' + '' '' - '' '

' @@ -166,8 +190,29 @@ def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, '' - output.append( - '

%s
' % line) + + if isprdiff and (line.startswith('@@') or + line.startswith('+') or + line.startswith('-')): + if line.startswith('@@'): + output.append( + '\ +
%s
' + % line) + elif line.startswith('+'): + output.append( + '\ +
%s
' + % line) + elif line.startswith('-'): + output.append( + '\ +
%s
' + % line) + else: + output.append( + '
%s
' % line) + output.append('') tpl_edit = '' - '' - '
' + '' + '
' '' - '
' + '
' '%(templ_edit)s' '%(templ_delete)s' '
' diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 418b9dd..641288f 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2055,7 +2055,7 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertNotIn( 'id="show_hidden_commits"', output_text) - self.assertIn('
- Row 0
', output_text) + self.assertIn('
- Row 0
', output_text) # View inverse commits comparison output = self.app.get('/test/c/%s..%s' % (c1.oid.hex, c2.oid.hex)) self.assertEqual(output.status_code, 200) @@ -2071,7 +2071,7 @@ class PagureFlaskRepotests(tests.Modeltests): ' %s\n ..\n %s\n' % (c1.oid.hex, c2.oid.hex), output_text) - self.assertIn('
+ Row 0
', output_text) + self.assertIn('
+ Row 0
', output_text) def compare_all(c1, c3): # View commits comparison @@ -2085,9 +2085,9 @@ class PagureFlaskRepotests(tests.Modeltests): ' %s\n ..\n %s\n' % (c1.oid.hex, c3.oid.hex), output_text) - self.assertIn('
+ Row 0
', output_text) + self.assertIn('
+ Row 0
', output_text) self.assertEqual( - output_text.count('
+ Row 0
'), 2) + output_text.count('
+ Row 0
'), 2) self.assertIn( '1 more commits...', output_text) @@ -2112,8 +2112,8 @@ class PagureFlaskRepotests(tests.Modeltests): (c3.oid.hex, c1.oid.hex), output_text) self.assertIn( - '
@@ -1,2 +1,1 @@
', output_text) - self.assertIn('
- Row 0
', output_text) + '
@@ -1,2 +1,1 @@
', output_text) + self.assertIn('
- Row 0
', output_text) self.assertIn( '
1 more commits...', output_text)