Mercurial > kallithea
changeset 6980:ceaa65df5add
diff: use fontello icon-diff-* names in generated html
This way we need less style code ... but generate slightly bigger html.
Also move the style code to kallithea-diff.less and remove the now obsolete
comment.
author | domruf <dominikruf@gmail.com> |
---|---|
date | Wed, 25 Oct 2017 22:57:31 +0200 |
parents | b66e4d720198 |
children | a92a06789f56 |
files | kallithea/lib/diffs.py kallithea/public/css/contextbar.css kallithea/public/css/style.css kallithea/public/less/kallithea-diff.less kallithea/tests/functional/test_compare_local.py kallithea/tests/models/test_diff_parsers.py |
diffstat | 6 files changed, 96 insertions(+), 98 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/lib/diffs.py Wed Oct 25 23:16:34 2017 +0200 +++ b/kallithea/lib/diffs.py Wed Oct 25 22:57:31 2017 +0200 @@ -327,49 +327,49 @@ } if head['deleted_file_mode']: - op = 'D' + op = 'removed' stats['binary'] = True stats['ops'][DEL_FILENODE] = 'deleted file' elif head['new_file_mode']: - op = 'A' + op = 'added' stats['binary'] = True stats['ops'][NEW_FILENODE] = 'new file %s' % head['new_file_mode'] else: # modify operation, can be cp, rename, chmod # CHMOD if head['new_mode'] and head['old_mode']: - op = 'M' + op = 'modified' stats['binary'] = True stats['ops'][CHMOD_FILENODE] = ('modified file chmod %s => %s' % (head['old_mode'], head['new_mode'])) # RENAME if (head['rename_from'] and head['rename_to'] and head['rename_from'] != head['rename_to']): - op = 'R' + op = 'renamed' stats['binary'] = True stats['ops'][RENAMED_FILENODE] = ('file renamed from %s to %s' % (head['rename_from'], head['rename_to'])) # COPY if head.get('copy_from') and head.get('copy_to'): - op = 'M' + op = 'modified' stats['binary'] = True stats['ops'][COPIED_FILENODE] = ('file copied from %s to %s' % (head['copy_from'], head['copy_to'])) # FALL BACK: detect missed old style add or remove if op is None: if not head['a_file'] and head['b_file']: - op = 'A' + op = 'added' stats['binary'] = True stats['ops'][NEW_FILENODE] = 'new file' elif head['a_file'] and not head['b_file']: - op = 'D' + op = 'removed' stats['binary'] = True stats['ops'][DEL_FILENODE] = 'deleted file' # it's not ADD not DELETE if op is None: - op = 'M' + op = 'modified' stats['binary'] = True stats['ops'][MOD_FILENODE] = 'modified file' @@ -380,7 +380,7 @@ stats['added'] = added stats['deleted'] = deleted # explicit mark that it's a modified file - if op == 'M': + if op == 'modified': stats['ops'][MOD_FILENODE] = 'modified file' else: # Git binary patch (or empty diff) # Git binary patch @@ -388,7 +388,7 @@ stats['ops'][BIN_FILENODE] = 'binary diff not shown' chunks = [] - if op == 'D' and chunks: + if op == 'removed' and chunks: # a way of seeing deleted content could perhaps be nice - but # not with the current UI chunks = []
--- a/kallithea/public/css/contextbar.css Wed Oct 25 23:16:34 2017 +0200 +++ b/kallithea/public/css/contextbar.css Wed Oct 25 22:57:31 2017 +0200 @@ -11,29 +11,6 @@ /* background-color: red; /* for debugging */ } /* Note: class 'icon-empty' or 'icon-gravatar' can be used to get icon styling without an actual glyph */ -/* css classes for diff file status ... it'd be nice if css had a way to - inherit from another class but alas, we must make sure this content is the - same from the icon font file */ -.icon-diff-M:before { - font-family: 'kallithea'; - content: '\22a1'; - color: #d0b44c; -} -.icon-diff-D:before { - font-family: 'kallithea'; - content: '\229f'; - color: #bd2c00; -} -.icon-diff-A:before { - font-family: 'kallithea'; - content: '\229e'; - color: #6cc644; -} -.icon-diff-R:before { - font-family: 'kallithea'; - content: '\e81f'; - color: #677a85; -} nav.navbar #quick a, #content #context-bar, #content #context-bar a {
--- a/kallithea/public/css/style.css Wed Oct 25 23:16:34 2017 +0200 +++ b/kallithea/public/css/style.css Wed Oct 25 22:57:31 2017 +0200 @@ -1989,26 +1989,23 @@ .cs_files .changes .bin.bin5 { background-color: #6D99FF; } -.cs_files .cs_added, -.cs_files .cs_A { +.cs_files .cs_added { height: 16px; margin-top: 7px; text-align: left; } .cs_files .cs_changed, -.cs_files .cs_M { +.cs_files .cs_modified { height: 16px; margin-top: 7px; text-align: left; } -.cs_files .cs_removed, -.cs_files .cs_D { +.cs_files .cs_removed { height: 16px; margin-top: 7px; text-align: left; } -.cs_files .cs_renamed, -.cs_files .cs_R { +.cs_files .cs_renamed { height: 16px; margin-top: 7px; text-align: left; @@ -2174,6 +2171,19 @@ .add-bubble div:hover { transform: scale(1.2, 1.2); } +/* file diff icons */ +.icon-diff-modified:before { + color: #d0b44c; +} +.icon-diff-removed:before { + color: #bd2c00; +} +.icon-diff-added:before { + color: #6cc644; +} +.icon-diff-renamed:before { + color: #677a85; +} /* show some context of link targets - but only works when the link target can be extended with any visual difference */ div.comment:target:before {
--- a/kallithea/public/less/kallithea-diff.less Wed Oct 25 23:16:34 2017 +0200 +++ b/kallithea/public/less/kallithea-diff.less Wed Oct 25 22:57:31 2017 +0200 @@ -54,26 +54,23 @@ .cs_files .changes .bin.bin5 { background-color: #6D99FF; } -.cs_files .cs_added, -.cs_files .cs_A { +.cs_files .cs_added { height: 16px; margin-top: 7px; text-align: left; } .cs_files .cs_changed, -.cs_files .cs_M { +.cs_files .cs_modified { height: 16px; margin-top: 7px; text-align: left; } -.cs_files .cs_removed, -.cs_files .cs_D { +.cs_files .cs_removed { height: 16px; margin-top: 7px; text-align: left; } -.cs_files .cs_renamed, -.cs_files .cs_R { +.cs_files .cs_renamed { height: 16px; margin-top: 7px; text-align: left; @@ -239,3 +236,17 @@ .add-bubble div:hover { transform: scale(1.2, 1.2); } + +/* file diff icons */ +.icon-diff-modified:before { + color: #d0b44c; +} +.icon-diff-removed:before { + color: #bd2c00; +} +.icon-diff-added:before { + color: #6cc644; +} +.icon-diff-renamed:before { + color: #677a85; +}
--- a/kallithea/tests/functional/test_compare_local.py Wed Oct 25 23:16:34 2017 +0200 +++ b/kallithea/tests/functional/test_compare_local.py Wed Oct 25 22:57:31 2017 +0200 @@ -31,48 +31,48 @@ ## files diff response.mustcontain( '''<span class="node"> - <i class="icon-diff-A"></i> + <i class="icon-diff-added"></i> <a href="#C--1c5cf9e91c12">docs/api/utils/index.rst</a> </span>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-A"></i> + <i class="icon-diff-added"></i> <a href="#C--e3305437df55">test_and_report.sh</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--c8e92ef85cd1">.hgignore</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--6e08b694d687">.hgtags</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--2c14b00f3393">docs/api/index.rst</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--430ccbc82bdf">vcs/__init__.py</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--9c390eb52cd6">vcs/backends/hg.py</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--ebb592c595c0">vcs/utils/__init__.py</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--7abc741b5052">vcs/utils/annotate.py</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--2ef0ef106c56">vcs/utils/diffs.py</a>''') response.mustcontain( '''<span class="node"> - <i class="icon-diff-M"></i> + <i class="icon-diff-modified"></i> <a href="#C--3150cb87d4b7">vcs/utils/lazy.py</a>''') def test_compare_tag_git(self):
--- a/kallithea/tests/models/test_diff_parsers.py Wed Oct 25 23:16:34 2017 +0200 +++ b/kallithea/tests/models/test_diff_parsers.py Wed Oct 25 22:57:31 2017 +0200 @@ -8,7 +8,7 @@ DIFF_FIXTURES = { 'hg_diff_add_single_binary_file.diff': [ - ('US Warszawa.jpg', 'A', + ('US Warszawa.jpg', 'added', {'added': 0, 'deleted': 0, 'binary': True, @@ -16,7 +16,7 @@ BIN_FILENODE: 'binary diff not shown'}}), ], 'hg_diff_mod_single_binary_file.diff': [ - ('US Warszawa.jpg', 'M', + ('US Warszawa.jpg', 'modified', {'added': 0, 'deleted': 0, 'binary': True, @@ -25,7 +25,7 @@ ], 'hg_diff_mod_single_file_and_rename_and_chmod.diff': [ - ('README', 'R', + ('README', 'renamed', {'added': 3, 'deleted': 0, 'binary': False, @@ -33,14 +33,14 @@ CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), ], 'hg_diff_mod_file_and_rename.diff': [ - ('README.rst', 'R', + ('README.rst', 'renamed', {'added': 3, 'deleted': 0, 'binary': False, 'ops': {RENAMED_FILENODE: 'file renamed from README to README.rst'}}), ], 'hg_diff_del_single_binary_file.diff': [ - ('US Warszawa.jpg', 'D', + ('US Warszawa.jpg', 'removed', {'added': 0, 'deleted': 0, 'binary': True, @@ -48,7 +48,7 @@ BIN_FILENODE: 'binary diff not shown'}}), ], 'hg_diff_chmod_and_mod_single_binary_file.diff': [ - ('gravatar.png', 'M', + ('gravatar.png', 'modified', {'added': 0, 'deleted': 0, 'binary': True, @@ -56,21 +56,21 @@ BIN_FILENODE: 'binary diff not shown'}}), ], 'hg_diff_chmod.diff': [ - ('file', 'M', + ('file', 'modified', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {CHMOD_FILENODE: 'modified file chmod 100755 => 100644'}}), ], 'hg_diff_rename_file.diff': [ - ('file_renamed', 'R', + ('file_renamed', 'renamed', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {RENAMED_FILENODE: 'file renamed from file to file_renamed'}}), ], 'hg_diff_rename_and_chmod_file.diff': [ - ('README', 'R', + ('README', 'renamed', {'added': 0, 'deleted': 0, 'binary': True, @@ -78,64 +78,64 @@ RENAMED_FILENODE: 'file renamed from README.rst to README'}}), ], 'hg_diff_binary_and_normal.diff': [ - ('img/baseline-10px.png', 'A', + ('img/baseline-10px.png', 'added', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {NEW_FILENODE: 'new file 100644', BIN_FILENODE: 'binary diff not shown'}}), - ('img/baseline-20px.png', 'D', + ('img/baseline-20px.png', 'removed', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {DEL_FILENODE: 'deleted file', BIN_FILENODE: 'binary diff not shown'}}), - ('index.html', 'M', + ('index.html', 'modified', {'added': 3, 'deleted': 2, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('js/global.js', 'D', + ('js/global.js', 'removed', {'added': 0, 'deleted': 75, 'binary': False, 'ops': {DEL_FILENODE: 'deleted file'}}), - ('js/jquery/hashgrid.js', 'A', + ('js/jquery/hashgrid.js', 'added', {'added': 340, 'deleted': 0, 'binary': False, 'ops': {NEW_FILENODE: 'new file 100755'}}), - ('less/docs.less', 'M', + ('less/docs.less', 'modified', {'added': 34, 'deleted': 0, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('less/scaffolding.less', 'M', + ('less/scaffolding.less', 'modified', {'added': 1, 'deleted': 3, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('readme.markdown', 'M', + ('readme.markdown', 'modified', {'added': 1, 'deleted': 10, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), ], 'git_diff_chmod.diff': [ - ('work-horus.xls', 'M', + ('work-horus.xls', 'modified', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}) ], 'git_diff_rename_file.diff': [ - ('file.xls', 'R', + ('file.xls', 'renamed', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {RENAMED_FILENODE: 'file renamed from work-horus.xls to file.xls'}}), ('files/var/www/favicon.ico/DEFAULT', - 'R', + 'renamed', {'added': 0, 'binary': True, 'deleted': 0, @@ -143,7 +143,7 @@ 6: 'modified file chmod 100644 => 100755'}}) ], 'git_diff_mod_single_binary_file.diff': [ - ('US Warszawa.jpg', 'M', + ('US Warszawa.jpg', 'modified', {'added': 0, 'deleted': 0, 'binary': True, @@ -151,78 +151,78 @@ BIN_FILENODE: 'binary diff not shown'}}) ], 'git_diff_binary_and_normal.diff': [ - ('img/baseline-10px.png', 'A', + ('img/baseline-10px.png', 'added', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {NEW_FILENODE: 'new file 100644', BIN_FILENODE: 'binary diff not shown'}}), - ('img/baseline-20px.png', 'D', + ('img/baseline-20px.png', 'removed', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {DEL_FILENODE: 'deleted file', BIN_FILENODE: 'binary diff not shown'}}), - ('index.html', 'M', + ('index.html', 'modified', {'added': 3, 'deleted': 2, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('js/global.js', 'D', + ('js/global.js', 'removed', {'added': 0, 'deleted': 75, 'binary': False, 'ops': {DEL_FILENODE: 'deleted file'}}), - ('js/jquery/hashgrid.js', 'A', + ('js/jquery/hashgrid.js', 'added', {'added': 340, 'deleted': 0, 'binary': False, 'ops': {NEW_FILENODE: 'new file 100755'}}), - ('less/docs.less', 'M', + ('less/docs.less', 'modified', {'added': 34, 'deleted': 0, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('less/scaffolding.less', 'M', + ('less/scaffolding.less', 'modified', {'added': 1, 'deleted': 3, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('readme.markdown', 'M', + ('readme.markdown', 'modified', {'added': 1, 'deleted': 10, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), ], 'diff_with_diff_data.diff': [ - ('vcs/backends/base.py', 'M', + ('vcs/backends/base.py', 'modified', {'added': 18, 'deleted': 2, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('vcs/backends/git/repository.py', 'M', + ('vcs/backends/git/repository.py', 'modified', {'added': 46, 'deleted': 15, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('vcs/backends/hg.py', 'M', + ('vcs/backends/hg.py', 'modified', {'added': 22, 'deleted': 3, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('vcs/tests/test_git.py', 'M', + ('vcs/tests/test_git.py', 'modified', {'added': 5, 'deleted': 5, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), - ('vcs/tests/test_repository.py', 'M', + ('vcs/tests/test_repository.py', 'modified', {'added': 174, 'deleted': 2, 'binary': False, 'ops': {MOD_FILENODE: 'modified file'}}), ], 'git_diff_modify_binary_file.diff': [ - ('file.name', 'M', + ('file.name', 'modified', {'added': 0, 'deleted': 0, 'binary': True, @@ -230,14 +230,14 @@ BIN_FILENODE: 'binary diff not shown'}}) ], 'hg_diff_copy_file.diff': [ - ('file2', 'M', + ('file2', 'modified', {'added': 0, 'deleted': 0, 'binary': True, 'ops': {COPIED_FILENODE: 'file copied from file1 to file2'}}), ], 'hg_diff_copy_and_modify_file.diff': [ - ('file3', 'M', + ('file3', 'modified', {'added': 1, 'deleted': 0, 'binary': False, @@ -245,7 +245,7 @@ MOD_FILENODE: 'modified file'}}), ], 'hg_diff_copy_and_chmod_file.diff': [ - ('file4', 'M', + ('file4', 'modified', {'added': 0, 'deleted': 0, 'binary': True, @@ -253,7 +253,7 @@ CHMOD_FILENODE: 'modified file chmod 100644 => 100755'}}), ], 'hg_diff_copy_chmod_and_edit_file.diff': [ - ('file5', 'M', + ('file5', 'modified', {'added': 2, 'deleted': 1, 'binary': False, @@ -262,7 +262,7 @@ MOD_FILENODE: 'modified file'}}), ], 'hg_diff_rename_space_cr.diff': [ - ('oh yes', 'R', + ('oh yes', 'renamed', {'added': 3, 'deleted': 2, 'binary': False,