Fixing changing WEBROOT from /
There were a few items missed with the patch enabling changing WEBROOT patch. First the XStatic files were being unpacked in the wrong directoy because root_url was not being passed in. This caused 404 errors when running with a different web root. This change allows root_url to be passed in on XStatic handling. Second, STATIC_URL and MEDIA_URL were not using WEBROOT. These now are built with WEBROOT. Third, the fa-font-path variable was hard-coded in _variables.scss to use "/" as the web root. A webroot variable has been added that can be overridden. Additionally, a new theme has also been added to change the web root. Closes-Bug: #1434276 Change-Id: Ifff1c60b3405ce2136d039b8d74da08752e7215c
This commit is contained in:
parent
4fdc42cf63
commit
18dddd97da
@ -951,9 +951,27 @@ Specifies the location where the access to the dashboard is configured in
|
|||||||
the web server.
|
the web server.
|
||||||
|
|
||||||
For example, if you're accessing the Dashboard via
|
For example, if you're accessing the Dashboard via
|
||||||
https://<your server>/horizon, you'd set this to ``"/horizon"``.
|
https://<your server>/dashboard, you would set this to ``"/dashboard/"``.
|
||||||
|
|
||||||
|
Additionally, setting the ``"$webroot"`` SCSS variable is required. You
|
||||||
|
can change this directly in
|
||||||
|
``"openstack_dasbboard/static/dashboard/scss/_variables.scss"`` or in the
|
||||||
|
``"_variables.scss"`` file in your custom theme. For more information on
|
||||||
|
custom themes, see: ``"CUSTOM_THEME_PATH"``.
|
||||||
|
|
||||||
|
For your convenience, a custom theme for only setting the web root has been
|
||||||
|
provided see: ``"/horizon/openstack_dashboard/static/themes/webroot"``
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Additional settings may be required in the config files of your webserver
|
||||||
|
of choice. For example to make ``"/dashboard/"`` the web root in apache,
|
||||||
|
the ``"sites-available/horizon.conf"`` requires a couple of additional
|
||||||
|
aliases set::
|
||||||
|
|
||||||
|
Alias /dashboard/static %HORIZON_DIR%/static
|
||||||
|
|
||||||
|
Alias /dashboard/media %HORIZON_DIR%/openstack_dashboard/static
|
||||||
|
|
||||||
|
|
||||||
Django Settings (Partial)
|
Django Settings (Partial)
|
||||||
|
@ -22,10 +22,12 @@ import sys
|
|||||||
|
|
||||||
import django
|
import django
|
||||||
from django.utils import html_parser
|
from django.utils import html_parser
|
||||||
from openstack_dashboard.static_settings import STATICFILES_DIRS # noqa
|
from openstack_dashboard.static_settings import get_staticfiles_dirs # noqa
|
||||||
|
|
||||||
from horizon.test import patches
|
from horizon.test import patches
|
||||||
|
|
||||||
|
STATICFILES_DIRS = get_staticfiles_dirs()
|
||||||
|
|
||||||
# Patch django.utils.html_parser.HTMLParser as a workaround for bug 1273943
|
# Patch django.utils.html_parser.HTMLParser as a workaround for bug 1273943
|
||||||
if django.get_version() == '1.4' and sys.version_info[:3] > (2, 7, 3):
|
if django.get_version() == '1.4' and sys.version_info[:3] > (2, 7, 3):
|
||||||
html_parser.HTMLParser.parse_starttag = patches.parse_starttag_patched
|
html_parser.HTMLParser.parse_starttag = patches.parse_starttag_patched
|
||||||
|
@ -25,7 +25,7 @@ import django
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from openstack_dashboard import exceptions
|
from openstack_dashboard import exceptions
|
||||||
from openstack_dashboard.static_settings import STATICFILES_DIRS # noqa
|
from openstack_dashboard.static_settings import get_staticfiles_dirs # noqa
|
||||||
|
|
||||||
|
|
||||||
warnings.formatwarning = lambda message, category, *args, **kwargs: \
|
warnings.formatwarning = lambda message, category, *args, **kwargs: \
|
||||||
@ -48,11 +48,6 @@ LOGOUT_URL = None
|
|||||||
LOGIN_REDIRECT_URL = None
|
LOGIN_REDIRECT_URL = None
|
||||||
|
|
||||||
|
|
||||||
MEDIA_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'media'))
|
|
||||||
MEDIA_URL = '/media/'
|
|
||||||
STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static'))
|
|
||||||
STATIC_URL = '/static/'
|
|
||||||
|
|
||||||
ROOT_URLCONF = 'openstack_dashboard.urls'
|
ROOT_URLCONF = 'openstack_dashboard.urls'
|
||||||
|
|
||||||
HORIZON_CONFIG = {
|
HORIZON_CONFIG = {
|
||||||
@ -269,11 +264,6 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
logging.warning("No local_settings file found.")
|
logging.warning("No local_settings file found.")
|
||||||
|
|
||||||
CUSTOM_THEME = os.path.join(ROOT_PATH, CUSTOM_THEME_PATH)
|
|
||||||
STATICFILES_DIRS.append(
|
|
||||||
('custom', CUSTOM_THEME),
|
|
||||||
)
|
|
||||||
|
|
||||||
if not WEBROOT.endswith('/'):
|
if not WEBROOT.endswith('/'):
|
||||||
WEBROOT += '/'
|
WEBROOT += '/'
|
||||||
if LOGIN_URL is None:
|
if LOGIN_URL is None:
|
||||||
@ -283,6 +273,16 @@ if LOGOUT_URL is None:
|
|||||||
if LOGIN_REDIRECT_URL is None:
|
if LOGIN_REDIRECT_URL is None:
|
||||||
LOGIN_REDIRECT_URL = WEBROOT
|
LOGIN_REDIRECT_URL = WEBROOT
|
||||||
|
|
||||||
|
MEDIA_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'media'))
|
||||||
|
MEDIA_URL = WEBROOT + 'media/'
|
||||||
|
STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static'))
|
||||||
|
STATIC_URL = WEBROOT + 'static/'
|
||||||
|
STATICFILES_DIRS = get_staticfiles_dirs(WEBROOT)
|
||||||
|
|
||||||
|
CUSTOM_THEME = os.path.join(ROOT_PATH, CUSTOM_THEME_PATH)
|
||||||
|
STATICFILES_DIRS.append(
|
||||||
|
('custom', CUSTOM_THEME),
|
||||||
|
)
|
||||||
|
|
||||||
# Load the pluggable dashboard settings
|
# Load the pluggable dashboard settings
|
||||||
import openstack_dashboard.enabled
|
import openstack_dashboard.enabled
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
to our variables */
|
to our variables */
|
||||||
@import "/bootstrap/scss/bootstrap/variables";
|
@import "/bootstrap/scss/bootstrap/variables";
|
||||||
|
|
||||||
|
/* This variable can be used to change the web root of horizon
|
||||||
|
default value is already '/' */
|
||||||
|
$webroot: "" !default;
|
||||||
|
|
||||||
/* Bootstrap variables overrides */
|
/* Bootstrap variables overrides */
|
||||||
|
|
||||||
@ -62,7 +65,7 @@ $rbrowser-footer-background-color: #f1f1f1;
|
|||||||
// .table-striped-datatable styles.
|
// .table-striped-datatable styles.
|
||||||
|
|
||||||
// Font-awesome path to the icon fonts
|
// Font-awesome path to the icon fonts
|
||||||
$fa-font-path: "/static/horizon/lib/font-awesome/fonts";
|
$fa-font-path: $webroot + "/static/horizon/lib/font-awesome/fonts";
|
||||||
|
|
||||||
/* Charts */
|
/* Charts */
|
||||||
|
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
/* This variable changes the web root of horizon to /dashboard rather
|
||||||
|
than the default '/' */
|
||||||
|
$webroot: "/dashboard";
|
@ -41,57 +41,83 @@ import xstatic.pkg.spin
|
|||||||
import xstatic.pkg.termjs
|
import xstatic.pkg.termjs
|
||||||
|
|
||||||
|
|
||||||
STATICFILES_DIRS = [
|
def get_staticfiles_dirs(webroot='/'):
|
||||||
('horizon/lib/angular',
|
STATICFILES_DIRS = [
|
||||||
xstatic.main.XStatic(xstatic.pkg.angular).base_dir),
|
('horizon/lib/angular',
|
||||||
('horizon/lib/angular',
|
xstatic.main.XStatic(xstatic.pkg.angular,
|
||||||
xstatic.main.XStatic(xstatic.pkg.angular_bootstrap).base_dir),
|
root_url=webroot).base_dir),
|
||||||
('horizon/lib/angular',
|
('horizon/lib/angular',
|
||||||
xstatic.main.XStatic(xstatic.pkg.angular_irdragndrop).base_dir),
|
xstatic.main.XStatic(xstatic.pkg.angular_bootstrap,
|
||||||
('horizon/lib/angular',
|
root_url=webroot).base_dir),
|
||||||
xstatic.main.XStatic(xstatic.pkg.angular_smart_table).base_dir),
|
('horizon/lib/angular',
|
||||||
('horizon/lib/bootstrap_datepicker',
|
xstatic.main.XStatic(xstatic.pkg.angular_irdragndrop,
|
||||||
xstatic.main.XStatic(xstatic.pkg.bootstrap_datepicker).base_dir),
|
root_url=webroot).base_dir),
|
||||||
('bootstrap',
|
('horizon/lib/angular',
|
||||||
xstatic.main.XStatic(xstatic.pkg.bootstrap_scss).base_dir),
|
xstatic.main.XStatic(xstatic.pkg.angular_smart_table,
|
||||||
('horizon/lib',
|
root_url=webroot).base_dir),
|
||||||
xstatic.main.XStatic(xstatic.pkg.d3).base_dir),
|
('horizon/lib/bootstrap_datepicker',
|
||||||
('horizon/lib',
|
xstatic.main.XStatic(xstatic.pkg.bootstrap_datepicker,
|
||||||
xstatic.main.XStatic(xstatic.pkg.hogan).base_dir),
|
root_url=webroot).base_dir),
|
||||||
('horizon/lib/font-awesome',
|
('bootstrap',
|
||||||
xstatic.main.XStatic(xstatic.pkg.font_awesome).base_dir),
|
xstatic.main.XStatic(xstatic.pkg.bootstrap_scss,
|
||||||
('horizon/lib/jasmine',
|
root_url=webroot).base_dir),
|
||||||
xstatic.main.XStatic(xstatic.pkg.jasmine).base_dir),
|
('horizon/lib',
|
||||||
('horizon/lib/jquery',
|
xstatic.main.XStatic(xstatic.pkg.d3,
|
||||||
xstatic.main.XStatic(xstatic.pkg.jquery).base_dir),
|
root_url=webroot).base_dir),
|
||||||
('horizon/lib/jquery',
|
('horizon/lib',
|
||||||
xstatic.main.XStatic(xstatic.pkg.jquery_migrate).base_dir),
|
xstatic.main.XStatic(xstatic.pkg.hogan,
|
||||||
('horizon/lib/jquery',
|
root_url=webroot).base_dir),
|
||||||
xstatic.main.XStatic(xstatic.pkg.jquery_quicksearch).base_dir),
|
('horizon/lib/font-awesome',
|
||||||
('horizon/lib/jquery',
|
xstatic.main.XStatic(xstatic.pkg.font_awesome,
|
||||||
xstatic.main.XStatic(xstatic.pkg.jquery_tablesorter).base_dir),
|
root_url=webroot).base_dir),
|
||||||
('horizon/lib/jsencrypt',
|
('horizon/lib/jasmine',
|
||||||
xstatic.main.XStatic(xstatic.pkg.jsencrypt).base_dir),
|
xstatic.main.XStatic(xstatic.pkg.jasmine,
|
||||||
('horizon/lib/magic_search',
|
root_url=webroot).base_dir),
|
||||||
xstatic.main.XStatic(xstatic.pkg.magic_search).base_dir),
|
('horizon/lib/jquery',
|
||||||
('horizon/lib/qunit',
|
xstatic.main.XStatic(xstatic.pkg.jquery,
|
||||||
xstatic.main.XStatic(xstatic.pkg.qunit).base_dir),
|
root_url=webroot).base_dir),
|
||||||
('horizon/lib',
|
('horizon/lib/jquery',
|
||||||
xstatic.main.XStatic(xstatic.pkg.rickshaw).base_dir),
|
xstatic.main.XStatic(xstatic.pkg.jquery_migrate,
|
||||||
('horizon/lib',
|
root_url=webroot).base_dir),
|
||||||
xstatic.main.XStatic(xstatic.pkg.spin).base_dir),
|
('horizon/lib/jquery',
|
||||||
('horizon/lib',
|
xstatic.main.XStatic(xstatic.pkg.jquery_quicksearch,
|
||||||
xstatic.main.XStatic(xstatic.pkg.termjs).base_dir),
|
root_url=webroot).base_dir),
|
||||||
]
|
('horizon/lib/jquery',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.jquery_tablesorter,
|
||||||
|
root_url=webroot).base_dir),
|
||||||
|
('horizon/lib/jsencrypt',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.jsencrypt,
|
||||||
|
root_url=webroot).base_dir),
|
||||||
|
('horizon/lib/magic_search',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.magic_search,
|
||||||
|
root_url=webroot).base_dir),
|
||||||
|
('horizon/lib/qunit',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.qunit,
|
||||||
|
root_url=webroot).base_dir),
|
||||||
|
('horizon/lib',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.rickshaw,
|
||||||
|
root_url=webroot).base_dir),
|
||||||
|
('horizon/lib',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.spin,
|
||||||
|
root_url=webroot).base_dir),
|
||||||
|
('horizon/lib',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.termjs,
|
||||||
|
root_url=webroot).base_dir),
|
||||||
|
]
|
||||||
|
|
||||||
|
if xstatic.main.XStatic(xstatic.pkg.jquery_ui,
|
||||||
|
root_url=webroot).version.startswith('1.10.'):
|
||||||
|
# The 1.10.x versions already contain the 'ui' directory.
|
||||||
|
STATICFILES_DIRS.append(
|
||||||
|
('horizon/lib/jquery-ui',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.jquery_ui,
|
||||||
|
root_url=webroot).base_dir))
|
||||||
|
else:
|
||||||
|
# Newer versions dropped the directory, add it to keep the path the
|
||||||
|
# same.
|
||||||
|
STATICFILES_DIRS.append(
|
||||||
|
('horizon/lib/jquery-ui/ui',
|
||||||
|
xstatic.main.XStatic(xstatic.pkg.jquery_ui,
|
||||||
|
root_url=webroot).base_dir))
|
||||||
|
|
||||||
if xstatic.main.XStatic(xstatic.pkg.jquery_ui).version.startswith('1.10.'):
|
return STATICFILES_DIRS
|
||||||
# The 1.10.x versions already contain the 'ui' directory.
|
|
||||||
STATICFILES_DIRS.append(
|
|
||||||
('horizon/lib/jquery-ui',
|
|
||||||
xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir))
|
|
||||||
else:
|
|
||||||
# Newer versions dropped the directory, add it to keep the path the same.
|
|
||||||
STATICFILES_DIRS.append(
|
|
||||||
('horizon/lib/jquery-ui/ui',
|
|
||||||
xstatic.main.XStatic(xstatic.pkg.jquery_ui).base_dir))
|
|
||||||
|
@ -15,7 +15,9 @@ import os
|
|||||||
from horizon.test.settings import * # noqa
|
from horizon.test.settings import * # noqa
|
||||||
from horizon.utils import secret_key
|
from horizon.utils import secret_key
|
||||||
from openstack_dashboard import exceptions
|
from openstack_dashboard import exceptions
|
||||||
|
from openstack_dashboard.static_settings import get_staticfiles_dirs # noqa
|
||||||
|
|
||||||
|
STATICFILES_DIRS = get_staticfiles_dirs()
|
||||||
|
|
||||||
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
TEST_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, ".."))
|
ROOT_PATH = os.path.abspath(os.path.join(TEST_DIR, ".."))
|
||||||
|
Loading…
Reference in New Issue
Block a user