From 967e77e2b5c72c78a8bf4e2ccd736eb22ccb9e10 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 06 2018 13:25:12 +0000 Subject: [PATCH 1/7] Drop the use of pygments Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/_repo_renderdiff.html b/pagure/templates/_repo_renderdiff.html index a3997a6..f3d898d 100644 --- a/pagure/templates/_repo_renderdiff.html +++ b/pagure/templates/_repo_renderdiff.html @@ -260,7 +260,7 @@ {% else %}
{% autoescape false %} - {{ patch | patch_to_diff | html_diff(linenos=None) | format_loc( + {{ patch | patch_to_diff | format_loc( filename=patch_new_file_path, commit=patch_new_id, prequest=pull_request, diff --git a/pagure/templates/patchfile.html b/pagure/templates/patchfile.html index fd1079a..f3a724e 100644 --- a/pagure/templates/patchfile.html +++ b/pagure/templates/patchfile.html @@ -16,7 +16,7 @@
{% autoescape false %} - {{ diff|html_diff }} + {{ diff }} {% endautoescape %}

diff --git a/pagure/ui/diff_style.py b/pagure/ui/diff_style.py deleted file mode 100644 index 44cfda4..0000000 --- a/pagure/ui/diff_style.py +++ /dev/null @@ -1,111 +0,0 @@ -# -*- coding: utf-8 -*- - -""" - (c) 2016-2017 - Copyright Red Hat Inc - - Authors: - Mark Reynolds - -""" - -from __future__ import unicode_literals - -from pygments.style import Style -from pygments.token import Keyword, Name, Comment, String, Error, \ - Number, Operator, Generic, Whitespace, Punctuation, Other, Literal - - -class DiffStyle(Style): # flake8: noqa - Ignore this entire file - """This style is based off of "tango", and has been updated to show the - background color of changed lines so that trailing white spaces can be - identified.""" - - background_color = "#f8f8f8" - default_style = "" - - styles = { - # No corresponding class for the following: - #Text: "", # class: '' - Whitespace: "underline #f8f8f8", # class: 'w' - Error: "#a40000 border:#ef2929", # class: 'err' - Other: "#000000", # class 'x' - - Comment: "italic #8f5902", # class: 'c' - Comment.Multiline: "italic #8f5902", # class: 'cm' - Comment.Preproc: "italic #8f5902", # class: 'cp' - Comment.Single: "italic #8f5902", # class: 'c1' - Comment.Special: "italic #8f5902", # class: 'cs' - - Keyword: "bold #204a87", # class: 'k' - Keyword.Constant: "bold #204a87", # class: 'kc' - Keyword.Declaration: "bold #204a87", # class: 'kd' - Keyword.Namespace: "bold #204a87", # class: 'kn' - Keyword.Pseudo: "bold #204a87", # class: 'kp' - Keyword.Reserved: "bold #204a87", # class: 'kr' - Keyword.Type: "bold #204a87", # class: 'kt' - - Operator: "bold #ce5c00", # class: 'o' - Operator.Word: "bold #204a87", # class: 'ow' - like keywords - - Punctuation: "bold #000000", # class: 'p' - - # Because special names such as Name.Class, Name.Function, etc. - # are not recognized as such later in the parsing, we choose them - # to look the same as ordinary variables. - Name: "#000000", # class: 'n' - Name.Attribute: "#c4a000", # class: 'na' - to be revised - Name.Builtin: "#204a87", # class: 'nb' - Name.Builtin.Pseudo: "#3465a4", # class: 'bp' - Name.Class: "#000000", # class: 'nc' - to be revised - Name.Constant: "#000000", # class: 'no' - to be revised - Name.Decorator: "bold #5c35cc", # class: 'nd' - to be revised - Name.Entity: "#ce5c00", # class: 'ni' - Name.Exception: "bold #cc0000", # class: 'ne' - Name.Function: "#000000", # class: 'nf' - Name.Property: "#000000", # class: 'py' - Name.Label: "#f57900", # class: 'nl' - Name.Namespace: "#000000", # class: 'nn' - to be revised - Name.Other: "#000000", # class: 'nx' - Name.Tag: "bold #204a87", # class: 'nt' - like a keyword - Name.Variable: "#000000", # class: 'nv' - to be revised - Name.Variable.Class: "#000000", # class: 'vc' - to be revised - Name.Variable.Global: "#000000", # class: 'vg' - to be revised - Name.Variable.Instance: "#000000", # class: 'vi' - to be revised - - # since the tango light blue does not show up well in text, we choose - # a pure blue instead. - Number: "bold #0000cf", # class: 'm' - Number.Float: "bold #0000cf", # class: 'mf' - Number.Hex: "bold #0000cf", # class: 'mh' - Number.Integer: "bold #0000cf", # class: 'mi' - Number.Integer.Long: "bold #0000cf", # class: 'il' - Number.Oct: "bold #0000cf", # class: 'mo' - - Literal: "#000000", # class: 'l' - Literal.Date: "#000000", # class: 'ld' - - String: "#4e9a06", # class: 's' - String.Backtick: "#4e9a06", # class: 'sb' - String.Char: "#4e9a06", # class: 'sc' - String.Doc: "italic #8f5902", # class: 'sd' - like a comment - String.Double: "#4e9a06", # class: 's2' - String.Escape: "#4e9a06", # class: 'se' - String.Heredoc: "#4e9a06", # class: 'sh' - String.Interpol: "#4e9a06", # class: 'si' - String.Other: "#4e9a06", # class: 'sx' - String.Regex: "#4e9a06", # class: 'sr' - String.Single: "#4e9a06", # class: 's1' - String.Symbol: "#4e9a06", # class: 'ss' - - Generic: "#000000", # class: 'g' - Generic.Deleted: 'bg:#ffdddd #a40000', # trac bg color - Generic.Inserted: 'bg:#ddffdd #00A000', # trac bg color - Generic.Emph: "italic #000000", # class: 'ge' - Generic.Error: "#ef2929", # class: 'gr' - Generic.Heading: "bold #000080", # class: 'gh' - Generic.Output: "italic #000000", # class: 'go' - Generic.Prompt: "#8f5902", # class: 'gp' - Generic.Strong: "bold #000000", # class: 'gs' - Generic.Subheading: "bold #800080", # class: 'gu' - Generic.Traceback: "bold #a40000", # class: 'gt' - } diff --git a/pagure/ui/filters.py b/pagure/ui/filters.py index b9840ac..01df37f 100644 --- a/pagure/ui/filters.py +++ b/pagure/ui/filters.py @@ -22,10 +22,6 @@ import flask import six from six.moves.urllib.parse import urlparse, parse_qsl -from pygments import highlight -from pygments.lexers.text import DiffLexer -from pygments.formatters import HtmlFormatter -from pygments.filters import VisibleWhitespaceFilter from jinja2 import escape import pagure.exceptions @@ -94,7 +90,7 @@ def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, comments = {} if prequest and not isinstance(prequest, flask.wrappers.Request): for com in prequest.comments: - if commit and com.commit_id == commit \ + if commit and com.commit_id == commit.hex \ and com.filename == filename: if com.line in comments: comments[com.line].append(com) @@ -109,8 +105,6 @@ def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, cnt = 1 for line in loc.split('\n'): - if line == '': - break if filename and commit: if isinstance(filename, str) and six.PY2: filename = filename.decode('UTF-8') @@ -152,14 +146,12 @@ def format_loc(loc, commit=None, filename=None, tree_id=None, prequest=None, if not line: output.append(line) continue - if line.startswith('')[1] + if line.startswith('@@'): if prequest and prequest.project_from: - rangeline = line.partition('font-weight: bold">@@ ')[2] \ - if line.partition('font-weight: bold">@@ ')[1] == \ - 'font-weight: bold">@@ ' else None + rangeline = line.partition('@@ ')[2] \ + if line.partition('@@ ')[1] == '@@ ' else None if rangeline: - rangeline = rangeline.split(' @@')[0] + rangeline = rangeline.split(' @@')[0] linenumber = rangeline.split('+')[1].split(',')[0] line = line + ' ' + \ - '' - output.append('

%s
' % line) + output.append( + '
%s
' % line) output.append('') tpl_edit = '
%s
' % line) + output.append( + '
%s
' % line) output.append('') output.append('') @@ -414,29 +408,6 @@ def markdown_filter(text): return pagure.lib.text2markdown(text) -@UI_NS.app_template_filter('html_diff') -def html_diff(diff, linenos='inline'): - """Display diff as HTML""" - if diff is None: - return - difflexer = DiffLexer() - # Do not give whitespaces the special Whitespace token type as this - # prevents the html formatter from picking up on trailing whitespaces in - # the diff. - difflexer.add_filter(VisibleWhitespaceFilter(wstokentype=False, tabs=True)) - - style = 'diffstyle' - - return highlight( - diff, - difflexer, - HtmlFormatter( - linenos=linenos, - noclasses=True, - style=style) - ) - - @UI_NS.app_template_filter('patch_to_diff') def patch_to_diff(patch): """Render a hunk as a diff""" diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 4def7b5..7ca7ee2 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -33,12 +33,6 @@ import werkzeug from six import BytesIO from PIL import Image -from pygments import highlight -from pygments.formatters import HtmlFormatter -from pygments.lexers import guess_lexer_for_filename -from pygments.lexers.special import TextLexer -from pygments.util import ClassNotFound -from pygments.filters import VisibleWhitespaceFilter from sqlalchemy.exc import SQLAlchemyError from binaryornot.helpers import is_binary_string @@ -564,28 +558,8 @@ def view_file(repo, identifier, filename, username=None, namespace=None): # it. output_type = 'binary' if file_content is not None: - try: - lexer = guess_lexer_for_filename( - filename, - file_content - ) - except (ClassNotFound, TypeError): - lexer = TextLexer() - - style = "tango" - - if ext in ('.diff', '.patch'): - lexer.add_filter(VisibleWhitespaceFilter( - wstokentype=False, tabs=True)) - style = "diffstyle" - content = highlight( - file_content, - lexer, - HtmlFormatter( - noclasses=True, - style=style,) - ) output_type = 'file' + content = content.data.decode('utf-8') else: output_type = 'binary' elif not isbinary: @@ -752,12 +726,6 @@ def view_blame_file(repo, filename, username=None, namespace=None): _log.exception('File could not be decoded') flask.abort(500, 'File could not be decoded') - lexer = TextLexer() - content = highlight( - content, - lexer, - HtmlFormatter(noclasses=True, style="tango") - ) blame = repo_obj.blame(filename, newest_commit=commit.oid.hex) return flask.render_template( diff --git a/setup.py b/setup.py index 2e971c6..38cdaf1 100644 --- a/setup.py +++ b/setup.py @@ -53,9 +53,6 @@ setup( include_package_data=True, install_requires=get_requirements(), entry_points=""" - [pygments.styles] - diffstyle = pagure.ui.diff_style:DiffStyle - [console_scripts] pagure-admin=pagure.cli.admin:main diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index 3447244..4dcc503 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -284,7 +284,7 @@ class PagureFlaskForktests(tests.Modeltests): # Test if the `open changed file icon` is displayed. self.assertIn( 'class="open_changed_file_icon_wrap">' '
', output_text) @@ -2058,7 +2058,7 @@ index 0000000..2a552bb # Test if the `open changed file icon` is displayed. self.assertIn( 'class="open_changed_file_icon_wrap">' '', output_text) diff --git a/tests/test_pagure_flask_ui_no_master_branch.py b/tests/test_pagure_flask_ui_no_master_branch.py index 45a49c5..38270a9 100644 --- a/tests/test_pagure_flask_ui_no_master_branch.py +++ b/tests/test_pagure_flask_ui_no_master_branch.py @@ -225,13 +225,9 @@ class PagureFlaskNoMasterBranchtests(tests.SimplePagureTest):   sources ''', output_text) - self.assertTrue( - # new version of pygments - '
foo
' in output_text - or - # old version of pygments - '
foo
' in output_text - ) + self.assertIn( + '
foo
', output_text + ) @patch('pagure.lib.notify.send_email') def test_view_raw_file(self, send_email): diff --git a/tests/test_pagure_flask_ui_repo.py b/tests/test_pagure_flask_ui_repo.py index 2a23947..80d8b5d 100644 --- a/tests/test_pagure_flask_ui_repo.py +++ b/tests/test_pagure_flask_ui_repo.py @@ -2055,9 +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) @@ -2073,9 +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 @@ -2089,13 +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) @@ -2120,11 +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) @@ -2218,7 +2207,7 @@ class PagureFlaskRepotests(tests.Modeltests): '', output_text) self.assertIn( - '
 bar
', output_text) + '
 bar
', output_text) # Empty files should also be displayed tests.add_content_to_git( @@ -2317,11 +2306,9 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertIn( '', output_text) - self.assertTrue( - '
Row 0
' - in output_text - or - '
Row 0
' in output_text + self.assertIn( + '
Row 0
', + output_text ) # Add a fork of a fork @@ -2364,7 +2351,8 @@ class PagureFlaskRepotests(tests.Modeltests): '', output_text) self.assertIn( - '
 barRow 0
', output_text) + '
 barRow 0
', + output_text) @patch( 'pagure.lib.encoding_utils.decode', @@ -2562,7 +2550,7 @@ class PagureFlaskRepotests(tests.Modeltests): '', output_text) self.assertIn( - '
 bar
', output_text) + '
 bar
', output_text) data = regex.findall(output_text) self.assertEqual(len(data), 2) @@ -2580,7 +2568,7 @@ class PagureFlaskRepotests(tests.Modeltests): '', output_text) self.assertIn( - '
 bar
', output_text) + '
 bar
', output_text) data = regex.findall(output_text) self.assertEqual(len(data), 2) @@ -2593,7 +2581,7 @@ class PagureFlaskRepotests(tests.Modeltests): '', output_text) self.assertIn( - '
 bar
', output_text) + '
 bar
', output_text) data2 = regex.findall(output_text) self.assertEqual(len(data2), 2) self.assertNotEqual(data, data2) @@ -2639,12 +2627,9 @@ class PagureFlaskRepotests(tests.Modeltests): self.assertIn( '', output_text) - self.assertTrue( - '
Row 0
' - in output_text - or - '
Row 0
' - in output_text + self.assertIn( + '
Row 0
', + output_text ) # Add a fork of a fork @@ -2678,7 +2663,8 @@ class PagureFlaskRepotests(tests.Modeltests): '', output_text) self.assertIn( - '
 barRow 0
', output_text) + '
 barRow 0
', + output_text) def test_view_blame_file_on_tag(self): """ Test the view_blame_file endpoint. """ @@ -2710,7 +2696,7 @@ class PagureFlaskRepotests(tests.Modeltests): '', output_text) self.assertIn( - '
 bar
', output_text) + '
 bar
', output_text) data = regex.findall(output_text) self.assertEqual(len(data), 2) diff --git a/tests/test_pagure_flask_ui_repo_view_file.py b/tests/test_pagure_flask_ui_repo_view_file.py index a79b7cc..cd551b3 100644 --- a/tests/test_pagure_flask_ui_repo_view_file.py +++ b/tests/test_pagure_flask_ui_repo_view_file.py @@ -104,8 +104,9 @@ class PagureFlaskRepoViewFiletests(LocalBasetests): '' in output_text) - self.assertTrue( - '
 bar
' in output_text) + self.assertIn( + '
 bar
', + output_text) def test_view_file_empty_file(self): """ Test the view_file with an empty file. """ @@ -220,11 +221,9 @@ class PagureFlaskRepoViewFiletests(LocalBasetests): self.assertIn( '', output_text) - self.assertTrue( - '
Row 0
' - in output_text - or - '
Row 0
' in output_text + self.assertIn( + '
Row 0
', + output_text ) def test_view_file_fork_and_edit_logged_out(self): @@ -328,7 +327,8 @@ class PagureFlaskRepoViewFileForktests(LocalBasetests): 'data-line-number="1">', output_text) self.assertIn( - '
 barRow 0
', output_text) + '
 barRow 0
', + output_text) def test_view_file_fork_and_edit_on_fork_logged_out(self): """ Test the view_file on a text file on a fork when logged out. """ diff --git a/tests/test_pagure_flask_ui_slash_branch_name.py b/tests/test_pagure_flask_ui_slash_branch_name.py index e98547a..7c09903 100644 --- a/tests/test_pagure_flask_ui_slash_branch_name.py +++ b/tests/test_pagure_flask_ui_slash_branch_name.py @@ -227,12 +227,8 @@ class PagureFlaskSlashInBranchtests(tests.SimplePagureTest):
  .gitignore ''', output_text) - self.assertTrue( - # new version of pygments - '
*~
' in output_text - or - # old version of pygments - '
*~
' in output_text) + self.assertIn( + '
*~
', output_text) @patch('pagure.lib.notify.send_email') def test_view_raw_file(self, send_email): From 32dba7a0b56629e1ca2284be97b0adfc716c5119 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 06 2018 13:27:02 +0000 Subject: [PATCH 2/7] Drop the dependency on pygments everywhere it's listed Signed-off-by: Pierre-Yves Chibon --- diff --git a/dev/ansible/roles/pagure-dev/tasks/main.yml b/dev/ansible/roles/pagure-dev/tasks/main.yml index fabed1e..236d7c5 100644 --- a/dev/ansible/roles/pagure-dev/tasks/main.yml +++ b/dev/ansible/roles/pagure-dev/tasks/main.yml @@ -47,7 +47,6 @@ - python-pip - python-psutil - python-pygit2 - - python-pygments - python-redis - python-sqlalchemy - python-straight-plugin diff --git a/dev/docker/ev b/dev/docker/ev index 856992b..9bb1eba 100644 --- a/dev/docker/ev +++ b/dev/docker/ev @@ -8,7 +8,7 @@ RUN dnf install -y python2-devel python-setuptools python-nose py-bcrypt python- python-arrow python-binaryornot python-bleach python-blinker \ python-chardet python-cryptography python-docutils python-flask \ python-flask-wtf python-flask-multistatic python-markdown python-psutil \ - python-pygit2 python-pygments python-fedora python-openid python-openid-cla \ + python-pygit2 python-fedora python-openid python-openid-cla \ python-openid-teams python-straight-plugin python-wtforms python-munch \ python-enum34 python-redis python-sqlalchemy systemd gitolite3 python-filelock \ python-fedora-flask python2-pillow python2-psycopg2 python-trololio \ diff --git a/dev/docker/logcom b/dev/docker/logcom index 51d5e13..957bc5f 100644 --- a/dev/docker/logcom +++ b/dev/docker/logcom @@ -8,7 +8,7 @@ RUN dnf install -y python2-devel python-setuptools python-nose python2-bcrypt py python-arrow python-binaryornot python-bleach python-blinker \ python-chardet python-cryptography python-docutils python-flask \ python-flask-wtf python-flask-multistatic python-markdown python-psutil \ - python-pygit2 python-pygments python-fedora python-openid python-openid-cla \ + python-pygit2 python-fedora python-openid python-openid-cla \ python-openid-teams python-straight-plugin python-wtforms python-munch \ python-enum34 python-redis python-sqlalchemy systemd gitolite3 python-filelock \ python-fedora-flask python2-pillow python2-psycopg2 diff --git a/dev/docker/web b/dev/docker/web index 13fe223..89e9277 100644 --- a/dev/docker/web +++ b/dev/docker/web @@ -8,7 +8,7 @@ RUN dnf install -y python2-devel python-setuptools python-nose python2-bcrypt py python-arrow python-binaryornot python-bleach python-blinker \ python-chardet python-cryptography python-docutils python-flask \ python-flask-wtf python-flask-multistatic python-markdown python-psutil \ - python-pygit2 python-pygments python-fedora python-openid python-openid-cla \ + python-pygit2 python-fedora python-openid python-openid-cla \ python-openid-teams python-straight-plugin python-wtforms python-munch \ python-enum34 python-redis python-sqlalchemy systemd gitolite3 python-filelock \ python-fedora-flask python2-pillow python2-psycopg2 python2-celery \ diff --git a/dev/docker/worker b/dev/docker/worker index 2f39659..0fec307 100644 --- a/dev/docker/worker +++ b/dev/docker/worker @@ -8,7 +8,7 @@ RUN dnf install -y python2-devel python-setuptools python-nose python2-bcrypt py python-arrow python-binaryornot python-bleach python-blinker \ python-chardet python-cryptography python-docutils python-flask \ python-flask-wtf python-flask-multistatic python-markdown python-psutil \ - python-pygit2 python-pygments python-fedora python-openid python-openid-cla \ + python-pygit2 python-fedora python-openid python-openid-cla \ python-openid-teams python-straight-plugin python-wtforms python-munch \ python-enum34 python-redis python-sqlalchemy systemd gitolite3 python-filelock \ python-fedora-flask python2-pillow python2-psycopg2 diff --git a/dev/run-tests-docker.py b/dev/run-tests-docker.py index c328dda..2a71c95 100755 --- a/dev/run-tests-docker.py +++ b/dev/run-tests-docker.py @@ -11,7 +11,7 @@ PKG_LIST = 'python-alembic python-arrow python-binaryornot \ \n'\ 'python-docutils python-enum34 python-flask python2-fedora-flask \ \n'\ 'python-flask-wtf python-flask-multistatic python2-bcrypt python-jinja2 \ \n'\ 'python-markdown python-munch python-openid-cla python-openid-teams \ \n'\ - 'python-psutil python-pygit2 python-pygments python2-pillow \ \n'\ + 'python-psutil python-pygit2 python2-pillow \ \n'\ 'python-sqlalchemy python-straight-plugin python-wtforms python-nose \ \n'\ 'python-coverage python-mock python-mock python-eventlet python2-flask-oidc \ \n'\ 'python-flake8 python-celery python-redis python-trololio python-beautifulsoup4 redis vim git' diff --git a/files/pagure.spec b/files/pagure.spec index 8d0e93e..a763729 100644 --- a/files/pagure.spec +++ b/files/pagure.spec @@ -53,7 +53,6 @@ Requires: python%{python_pkgversion}-munch Requires: python%{python_pkgversion}-pillow Requires: python%{python_pkgversion}-psutil Requires: python%{python_pkgversion}-pygit2 >= 0.24.0 -Requires: python%{python_pkgversion}-pygments Requires: python%{python_pkgversion}-openid Requires: python%{python_pkgversion}-openid-cla Requires: python%{python_pkgversion}-openid-teams diff --git a/requirements-fedora.txt b/requirements-fedora.txt index 10da2c2..dbf7e4e 100644 --- a/requirements-fedora.txt +++ b/requirements-fedora.txt @@ -19,7 +19,6 @@ python-openid-cla python-openid-teams python-psutil python-pygit2 -python-pygments python-redis python-sqlalchemy python-straight-plugin diff --git a/requirements.txt b/requirements.txt index 87fc751..3a6bce0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -20,7 +20,6 @@ munch Pillow psutil pygit2 >= 0.24.0 -pygments python-openid python-openid-cla python-openid-teams diff --git a/run_ci_tests.sh b/run_ci_tests.sh index 87dbf2a..c55759e 100755 --- a/run_ci_tests.sh +++ b/run_ci_tests.sh @@ -36,7 +36,7 @@ fi # and only in py3 we're having a version that is too old (2.1) pip3 install --upgrade "idna<2.8" pip install --upgrade tox trollius -pip install --upgrade --force-reinstall pygments chardet +pip install --upgrade --force-reinstall chardet pip3 install "pygit2 <= `rpm -q libgit2 --queryformat='%{version}'`" parallel -v ::: \ "tox --sitepackages -e 'py27-flask011-ci' -- -v --with-xcoverage --cover-erase --cover-package=pagure" \ From 5d875801de1f0c91d383cf33184f4f33abd18c2e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 06 2018 13:27:02 +0000 Subject: [PATCH 3/7] Move the blame and file templates to use highlight.js Fixes https://pagure.io/pagure/issue/2707 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/static/pagure.css b/pagure/static/pagure.css index 51951b2..1020cc4 100644 --- a/pagure/static/pagure.css +++ b/pagure/static/pagure.css @@ -94,8 +94,12 @@ html box-shadow:0 0 10px 2px rgba(0,0,0,0.1) } +pre { + background-color: transparent; +} + .code_table { - background: #FDF6E3; + background: #fff; min-width: 100%; display:block; overflow-x: auto; @@ -115,7 +119,7 @@ html .code_table tr .cell1{ width: 20px; - background: #eee8d5; + background: #fff; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; @@ -436,7 +440,8 @@ color: #bbb; .highlighted-line, .highlighted-line td, -.highlighted-line td pre { +.highlighted-line td pre, +.highlighted-line td pre code { background-color: #FFFABA; } @@ -886,3 +891,8 @@ a.nav-link.btn{ background: transparent!important; color: rebeccapurple; } + +.hljs { + padding: 0!important; + background: #fff; +} diff --git a/pagure/templates/blame.html b/pagure/templates/blame.html index d1f913e..b3476b4 100644 --- a/pagure/templates/blame.html +++ b/pagure/templates/blame.html @@ -4,6 +4,15 @@ repo.namespace + '/' if repo.namespace }}{{ repo.name }}{% endblock %} {% set tag = "home" %} +{% block header %} + + +{% endblock %} {% block repo %}
@@ -175,6 +184,13 @@ No content found in this repository {% block jscripts %} {{ super() }} + + + + + + + + + + src="{{ url_for('static', filename='vendor/diff2html/diff2html.min.js') }}"> + src="{{ url_for('static', filename='vendor/highlight.js/highlight.pack.js') }}"> + src="{{ url_for('static', filename='vendor/highlight.js/spec.js') }}"> + src="{{ url_for('static', filename='vendor/diff2html/diff2html-ui.min.js') }}">