changeset 8584:d9116644696b

diff: allow commenting on meta lines (Issue #329) There is no good reason it only should be possible to comment on content lines. Other lines might not have an obvious locator, but we can live with that as long as each comment only apply in one place. With this, we actually want the comment bubble on all lines with bubble markup, so we can loosen the css selector.
author Mads Kiilerich <mads@kiilerich.com>
date Thu, 11 Jun 2020 23:04:31 +0200
parents 9038c1a443a0
children 1de3e5d104bf
files kallithea/front-end/kallithea-diff.less kallithea/lib/diffs.py
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/front-end/kallithea-diff.less	Thu Jun 11 22:48:50 2020 +0200
+++ b/kallithea/front-end/kallithea-diff.less	Thu Jun 11 23:04:31 2020 +0200
@@ -168,10 +168,7 @@
   left: -8px;
   box-sizing: border-box;
 }
-/* comment bubble, only visible when in a commentable diff */
-.commentable-diff tr.line.add:hover td .add-bubble,
-.commentable-diff tr.line.del:hover td .add-bubble,
-.commentable-diff tr.line.unmod:hover td .add-bubble {
+.commentable-diff tr.line:hover td .add-bubble {
   display: block;
   z-index: 1;
 }
--- a/kallithea/lib/diffs.py	Thu Jun 11 22:48:50 2020 +0200
+++ b/kallithea/lib/diffs.py	Thu Jun 11 23:04:31 2020 +0200
@@ -77,6 +77,7 @@
     })
 
     for file_info in parsed_lines:
+        count_no_lineno = 0  # counter to allow comments on lines without new/old line numbers
         for chunk in file_info['chunks']:
             _html_empty = False
             for change in chunk:
@@ -127,7 +128,13 @@
                     ###########################################################
                     # NO LINE NUMBER
                     ###########################################################
-                    _html.append('''\t<td class="%(olc)s" colspan="2">''' % {
+                    anchor = "%(filename)s_%(count_no_lineno)s" % {
+                        'filename': _safe_id(file_info['filename']),
+                        'count_no_lineno': count_no_lineno,
+                    }
+                    count_no_lineno += 1
+                    _html.append('''\t<td id="%(anchor)s" class="%(olc)s" colspan="2">''' % {
+                        'anchor': anchor,
                         'olc': no_lineno_class,
                     })
                     _html.append('''</td>\n''')