Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AIRFLOW-5618] Remove copy of pygments style #6290

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions airflow/www/app.py
Expand Up @@ -112,6 +112,7 @@ def init_views(appbuilder):
appbuilder.add_view_no_menu(views.Airflow())
appbuilder.add_view_no_menu(views.DagModelView())
appbuilder.add_view_no_menu(views.ConfigurationView())
appbuilder.add_view_no_menu(views.PygmentsView())
appbuilder.add_view_no_menu(views.VersionView())
appbuilder.add_view(views.DagRunModelView,
"DAG Runs",
Expand Down
52 changes: 0 additions & 52 deletions airflow/www/static/css/main.css
Expand Up @@ -236,55 +236,3 @@ div.square {
.btn:active, .btn.active {
box-shadow: inset 0 6px 6px rgba(0, 0, 0, 0.4);
}

.hll { background-color: #ffffcc }
.c { color: #408080; font-style: italic } /* Comment */
.err { border: 1px solid #FF0000 } /* Error */
.k { color: #008000; font-weight: bold } /* Keyword */
.o { color: #666666 } /* Operator */
.cm { color: #408080; font-style: italic } /* Comment.Multiline */
.cp { color: #BC7A00 } /* Comment.Preproc */
.c1 { color: #408080; font-style: italic } /* Comment.Single */
.cs { color: #408080; font-style: italic } /* Comment.Special */
.gd { color: #A00000 } /* Generic.Deleted */
.ge { font-style: italic } /* Generic.Emph */
.gr { color: #FF0000 } /* Generic.Error */
.gh { color: #000080; font-weight: bold } /* Generic.Heading */
.gi { color: #00A000 } /* Generic.Inserted */
.go { color: #888888 } /* Generic.Output */
.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.gs { font-weight: bold } /* Generic.Strong */
.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.gt { color: #0044DD } /* Generic.Traceback */
.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.kp { color: #008000 } /* Keyword.Pseudo */
.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.kt { color: #B00040 } /* Keyword.Type */
.m { color: #666666 } /* Literal.Number */
.s { color: #BA2121 } /* Literal.String */
.na { color: #7D9029 } /* Name.Attribute */
.nb { color: #008000 } /* Name.Builtin */
.nc { color: #0000FF; font-weight: bold } /* Name.Class */
.no { color: #880000 } /* Name.Constant */
.nd { color: #AA22FF } /* Name.Decorator */
.ni { color: #999999; font-weight: bold } /* Name.Entity */
.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
.nf { color: #0000FF } /* Name.Function */
.nl { color: #A0A000 } /* Name.Label */
.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
.nt { color: #008000; font-weight: bold } /* Name.Tag */
.nv { color: #19177C } /* Name.Variable */
.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
.w { color: #bbbbbb } /* Text.Whitespace */
.mb { color: #666666 } /* Literal.Number.Bin */
.mf { color: #666666 } /* Literal.Number.Float */
.mh { color: #666666 } /* Literal.Number.Hex */
.mi { color: #666666 } /* Literal.Number.Integer */
.mo { color: #666666 } /* Literal.Number.Oct */
.sb { color: #BA2121 } /* Literal.String.Backtick */
.sc { color: #BA2121 } /* Literal.String.Char */
.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.s2 { color: #BA2121 } /* Literal.String.Double */
.s1 { color: #BA2121 } /* Literal.String.Single */
1 change: 1 addition & 0 deletions airflow/www/templates/appbuilder/baselayout.html
Expand Up @@ -31,6 +31,7 @@
<link href="{{ url_for_asset('main.css') }}" rel="stylesheet">

<link rel="icon" type="image/png" href="{{ url_for('static', filename='pin_32.png') }}">
<link rel="stylesheet" type="text/css" href="{{ url_for("PygmentsView.style_defs") }}">
{% endblock %}


Expand Down
12 changes: 12 additions & 0 deletions airflow/www/views.py
Expand Up @@ -1944,6 +1944,18 @@ def version(self):
git_version=git_version)


class PygmentsView(AirflowBaseView):

@expose('/pygments.css')
@has_access
def style_defs(self):
formatter = HtmlFormatter(style='default')
style_defs = formatter.get_style_defs()
response = make_response(style_defs, 200)
response.headers['Content-Type'] = "text/css"
return response


class ConfigurationView(AirflowBaseView):
@expose('/configuration')
@has_access
Expand Down
9 changes: 9 additions & 0 deletions tests/www/test_views.py
Expand Up @@ -823,6 +823,15 @@ def test_version(self):
self.check_content_in_response('Version Info', resp)


class TestPygmentsView(TestBase):
def test_pygments(self):
resp = self.client.get('pygments.css', data=dict(
username='test',
password='test'
), follow_redirects=True)
self.check_content_in_response('background-color: #ffffcc', resp)


class ViewWithDateTimeAndNumRunsAndDagRunsFormTester:
DAG_ID = 'dag_for_testing_dt_nr_dr_form'
DEFAULT_DATE = datetime(2017, 9, 1)
Expand Down