Merge "Move static files configuration to reduce settings.py churn"

This commit is contained in:
Jenkins 2015-07-24 05:22:32 +00:00 committed by Gerrit Code Review
commit bbeb7c6e4f
2 changed files with 32 additions and 25 deletions

View File

@ -25,6 +25,7 @@ import django
from django.utils.translation import ugettext_lazy as _
from openstack_dashboard import exceptions
from openstack_dashboard.static_settings import find_static_files # noqa
from openstack_dashboard.static_settings import get_staticfiles_dirs # noqa
@ -305,31 +306,7 @@ STATICFILES_DIRS.append(
# populate HORIZON_CONFIG with auto-discovered JavaScript sources, mock files,
# specs files and external templates.
from horizon.utils import file_discovery as fd
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
fd.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, '..', 'horizon', 'static/')
)
# filter out non-angular javascript code and lib
HORIZON_CONFIG['js_files'] = ([f for f in HORIZON_CONFIG['js_files']
if not f.startswith('horizon/')])
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
fd.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='openstack-service-api/'
)
fd.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='app/core/'
)
find_static_files(ROOT_PATH, HORIZON_CONFIG)
# Load the pluggable dashboard settings
import openstack_dashboard.enabled

View File

@ -17,6 +17,8 @@ distributions can edit or replace this file, in order to change the paths
to match their distribution's standards.
"""
import os
import xstatic.main
import xstatic.pkg.angular
import xstatic.pkg.angular_bootstrap
@ -41,6 +43,8 @@ import xstatic.pkg.rickshaw
import xstatic.pkg.spin
import xstatic.pkg.termjs
from horizon.utils import file_discovery
def get_staticfiles_dirs(webroot='/'):
STATICFILES_DIRS = [
@ -125,3 +129,29 @@ def get_staticfiles_dirs(webroot='/'):
root_url=webroot).base_dir))
return STATICFILES_DIRS
def find_static_files(ROOT_PATH, HORIZON_CONFIG):
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
file_discovery.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, '..', 'horizon', 'static/')
)
# filter out non-angular javascript code and lib
HORIZON_CONFIG['js_files'] = ([f for f in HORIZON_CONFIG['js_files']
if not f.startswith('horizon/')])
# note the path must end in a '/' or the resultant file paths will have a
# leading "/"
file_discovery.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='openstack-service-api/'
)
file_discovery.populate_horizon_config(
HORIZON_CONFIG,
os.path.join(ROOT_PATH, 'static/'),
sub_path='app/core/'
)