Unbundle Patternfly css/js/fonts and use xstatic packaged version
Change-Id: I01cb73ef04a7808e25979d33158256aeeef4f14c
This commit is contained in:
parent
7b1c5bf0c7
commit
a70ea1c67f
@ -19,7 +19,7 @@ import sys
|
||||
|
||||
from ara import models
|
||||
from cliff.command import Command
|
||||
from flask_frozen import Freezer
|
||||
from flask_frozen import Freezer, walk_directory
|
||||
from flask_frozen import MissingURLGeneratorWarning
|
||||
from junit_xml import TestCase
|
||||
from junit_xml import TestSuite
|
||||
@ -57,6 +57,19 @@ class GenerateHtml(Command):
|
||||
if self.app.ara.config['ARA_IGNORE_EMPTY_GENERATION']:
|
||||
filterwarnings('ignore', '.*', MissingURLGeneratorWarning)
|
||||
freezer = Freezer(self.app.ara)
|
||||
|
||||
# Patternfly fonts are called from inside the CSS and are therefore
|
||||
# not automatically found by flask-frozen. We need to generate URLs
|
||||
# for the fonts.
|
||||
patternfly = self.app.ara.config['XSTATIC']['patternfly']
|
||||
|
||||
@freezer.register_generator
|
||||
def serve_static_packaged():
|
||||
for font in walk_directory(os.path.join(patternfly, 'fonts')):
|
||||
yield dict(
|
||||
module='patternfly',
|
||||
file='fonts/%s' % font
|
||||
)
|
||||
freezer.freeze()
|
||||
|
||||
print('Done.')
|
||||
|
@ -16,6 +16,7 @@ import os
|
||||
import xstatic.main
|
||||
import xstatic.pkg.jquery
|
||||
import xstatic.pkg.bootstrap_scss
|
||||
import xstatic.pkg.patternfly
|
||||
|
||||
from ansible import __version__ as ansible_version
|
||||
from ansible.constants import get_config
|
||||
@ -130,5 +131,6 @@ DB_MIGRATIONS = os.path.join(INSTALL_PATH, 'db')
|
||||
# Xstatic configuration
|
||||
XSTATIC = dict(
|
||||
jquery=xstatic.main.XStatic(xstatic.pkg.jquery).base_dir,
|
||||
bootstrap=xstatic.main.XStatic(xstatic.pkg.bootstrap_scss).base_dir
|
||||
bootstrap=xstatic.main.XStatic(xstatic.pkg.bootstrap_scss).base_dir,
|
||||
patternfly=xstatic.main.XStatic(xstatic.pkg.patternfly).base_dir
|
||||
)
|
||||
|
5
ara/static/css/patternfly-additions.min.css
vendored
5
ara/static/css/patternfly-additions.min.css
vendored
File diff suppressed because one or more lines are too long
8
ara/static/css/patternfly.min.css
vendored
8
ara/static/css/patternfly.min.css
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2
ara/static/js/patternfly.min.js
vendored
2
ara/static/js/patternfly.min.js
vendored
File diff suppressed because one or more lines are too long
@ -10,16 +10,16 @@
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='images/favicon.ico') }}">
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static.serve', module='jquery', file='jquery.min.js') }}"></script>
|
||||
<script src="{{ url_for('serve_static_packaged', module='jquery', file='jquery.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js') }}"></script>
|
||||
<script src="{{ url_for('static.serve', module='bootstrap', file='js/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ url_for('serve_static_packaged', module='bootstrap', file='js/bootstrap.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/ara.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/patternfly.min.js') }}"></script>
|
||||
<script src="{{ url_for('serve_static_packaged', module='patternfly', file='js/patternfly.min.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
<link href="{{ url_for('static', filename='css/patternfly.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/patternfly-additions.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('serve_static_packaged', module='patternfly', file='css/patternfly.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('serve_static_packaged', module='patternfly', file='css/patternfly-additions.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/pygments.css') }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static', filename='css/ara.css') }}" rel="stylesheet">
|
||||
{% endblock %}
|
||||
|
@ -5,6 +5,5 @@ from .host import host
|
||||
from .playbook import playbook
|
||||
from .reports import reports
|
||||
from .result import result
|
||||
from .static import static
|
||||
|
||||
# flake8: noqa
|
||||
|
@ -1,33 +0,0 @@
|
||||
# Copyright 2017 Red Hat, Inc. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from flask import abort
|
||||
from flask import Blueprint
|
||||
from flask import current_app
|
||||
from flask import send_from_directory
|
||||
|
||||
static = Blueprint('static', __name__)
|
||||
|
||||
|
||||
@static.route('/packaged/<module>/<path:file>')
|
||||
def serve(module, file):
|
||||
# Note (dmsimard)
|
||||
# /static/ is provided from in-tree bundled files and libraries.
|
||||
# /static/packaged/ is routed to serve packaged (i.e, XStatic) libraries.
|
||||
xstatic = current_app.config['XSTATIC']
|
||||
|
||||
if module in xstatic:
|
||||
return send_from_directory(xstatic[module], file)
|
||||
else:
|
||||
abort(404)
|
@ -24,15 +24,17 @@ from ara.context_processors import configure_context_processors
|
||||
from ara.errorhandlers import configure_errorhandlers
|
||||
from ara.filters import configure_template_filters
|
||||
from ara.models import db
|
||||
from flask import Flask, current_app
|
||||
from flask import abort
|
||||
from flask import current_app
|
||||
from flask import Flask
|
||||
from flask import logging as flask_logging
|
||||
from flask import send_from_directory
|
||||
from sqlalchemy.engine.reflection import Inspector
|
||||
|
||||
|
||||
DEFAULT_APP_NAME = 'ara'
|
||||
|
||||
views = (
|
||||
(ara.views.static, '/static'),
|
||||
(ara.views.file, '/file'),
|
||||
(ara.views.home, ''),
|
||||
(ara.views.host, '/host'),
|
||||
@ -58,6 +60,7 @@ def create_app(config=None, app_name=None):
|
||||
configure_template_filters(app)
|
||||
configure_context_processors(app)
|
||||
configure_blueprints(app)
|
||||
configure_static_route(app)
|
||||
configure_db(app)
|
||||
|
||||
return app
|
||||
@ -143,3 +146,27 @@ def configure_logging(app):
|
||||
alembic_logger.setLevel(logging.WARNING)
|
||||
del alembic_logger.handlers[:]
|
||||
alembic_logger.addHandler(handler)
|
||||
|
||||
|
||||
def configure_static_route(app):
|
||||
# Note (dmsimard)
|
||||
# /static/ is provided from in-tree bundled files and libraries.
|
||||
# /static/packaged/ is routed to serve packaged (i.e, XStatic) libraries.
|
||||
#
|
||||
# The reason why this isn't defined as a proper view by itself is due to
|
||||
# a limitation in flask-frozen. Blueprint'd views methods are like so:
|
||||
# "<view>.<method>. The URL generator of flask-frozen is a method decorator
|
||||
# that expects the method name as the function and, obviously, you can't
|
||||
# really have dots in functions.
|
||||
# By having the route configured at the root of the application, there's no
|
||||
# dots and we can decorate "serve_static_packaged" instead of, say,
|
||||
# "static.serve_packaged".
|
||||
|
||||
@app.route('/static/packaged/<module>/<path:file>')
|
||||
def serve_static_packaged(module, file):
|
||||
xstatic = current_app.config['XSTATIC']
|
||||
|
||||
if module in xstatic:
|
||||
return send_from_directory(xstatic[module], file)
|
||||
else:
|
||||
abort(404)
|
||||
|
@ -16,3 +16,4 @@ junit-xml>=1.7
|
||||
XStatic>=1.0.0 # MIT License
|
||||
XStatic-Bootstrap-SCSS>=3.3.7.1 # Apache 2.0 License
|
||||
XStatic-jQuery>=1.8.2.1 # MIT License
|
||||
XStatic-Patternfly>=3.21.0 # Apache 2.0 License
|
Loading…
Reference in New Issue
Block a user