SCSS $webroot should inherit from settings.py
There is double maintenance right now when you change the STATIC_URL via settings.py, you must also use a custom theme to have access to also change $webroot within the SCSS to serve font-awesome from a custom location. This patch makes the STATIC_URL available by default in the SCSS namespace through variable $static_url. Also, it was being called $webroot in the SCSS, but it should actually be called $static_url since it should map directly to settings.py's STATIC_URL. Change-Id: I1ee40652f8110b176f45b8811f0e0197789a73da Closes-Bug: #1478794
This commit is contained in:
parent
9eb111c293
commit
24f25eddb6
@ -1067,18 +1067,6 @@ the web server.
|
|||||||
For example, if you're accessing the Dashboard via
|
For example, if you're accessing the Dashboard via
|
||||||
https://<your server>/dashboard, you would set this to ``"/dashboard/"``.
|
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_dashboard/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"``.
|
|
||||||
|
|
||||||
Make sure you run ``python manage.py collectstatic`` and
|
|
||||||
``python manage.py compress`` after you change the ``_variables.scss`` file.
|
|
||||||
|
|
||||||
For your convenience, a custom theme for only setting the web root has been
|
|
||||||
provided see: ``"/horizon/openstack_dashboard/themes/webroot"``
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Additional settings may be required in the config files of your webserver
|
Additional settings may be required in the config files of your webserver
|
||||||
@ -1125,6 +1113,13 @@ webserver configuration should be updated to match.
|
|||||||
|
|
||||||
The value for STATIC_URL must end in '/'.
|
The value for STATIC_URL must end in '/'.
|
||||||
|
|
||||||
|
This value is also available in the scss namespace with the variable name
|
||||||
|
$static_url. Make sure you run ``python manage.py collectstatic`` and
|
||||||
|
``python manage.py compress`` after any changes to this value in settings.py.
|
||||||
|
|
||||||
|
For your convenience, a custom theme for only setting the static url has been
|
||||||
|
provided see: ``"/horizon/openstack_dashboard/themes/webroot"``
|
||||||
|
|
||||||
For more information see:
|
For more information see:
|
||||||
https://docs.djangoproject.com/en/1.7/ref/settings/#static-url
|
https://docs.djangoproject.com/en/1.7/ref/settings/#static-url
|
||||||
|
|
||||||
|
43
horizon/utils/scss_filter.py
Normal file
43
horizon/utils/scss_filter.py
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
|
||||||
|
#
|
||||||
|
# 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 django.conf import settings
|
||||||
|
|
||||||
|
from django_pyscss.compressor import DjangoScssFilter
|
||||||
|
from django_pyscss import DjangoScssCompiler
|
||||||
|
|
||||||
|
from scss.namespace import Namespace
|
||||||
|
from scss.types import String
|
||||||
|
|
||||||
|
import six
|
||||||
|
|
||||||
|
|
||||||
|
class HorizonScssFilter(DjangoScssFilter):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super(HorizonScssFilter, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
self.namespace = Namespace()
|
||||||
|
|
||||||
|
# Add variables to the SCSS Global Namespace Here
|
||||||
|
self.namespace.set_variable(
|
||||||
|
'$static_url',
|
||||||
|
String(six.text_type(getattr(settings, 'STATIC_URL', '/static/')))
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create a compiler with the right namespace
|
||||||
|
@property
|
||||||
|
def compiler(self):
|
||||||
|
return DjangoScssCompiler(
|
||||||
|
namespace=self.namespace
|
||||||
|
)
|
@ -141,7 +141,7 @@ STATICFILES_FINDERS = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
COMPRESS_PRECOMPILERS = (
|
COMPRESS_PRECOMPILERS = (
|
||||||
('text/scss', 'django_pyscss.compressor.DjangoScssFilter'),
|
('text/scss', 'horizon.utils.scss_filter.HorizonScssFilter'),
|
||||||
)
|
)
|
||||||
|
|
||||||
COMPRESS_CSS_FILTERS = (
|
COMPRESS_CSS_FILTERS = (
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
to our variables */
|
to our variables */
|
||||||
@import "/custom/variables";
|
@import "/custom/variables";
|
||||||
|
|
||||||
|
/* When used with Horizon via Django, this value is set automatically from
|
||||||
/* This variable can be used to change the web root of horizon
|
settings.py and is added dynamically to the namespace through
|
||||||
default value is already '/' */
|
horizon/utils/scss_filter.py */
|
||||||
$webroot: "" !default;
|
$static_url: "/static/" !default;
|
||||||
|
|
||||||
|
|
||||||
/* Horizon Custom Variables */
|
/* Horizon Custom Variables */
|
||||||
@ -59,7 +59,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: $webroot + "/static/horizon/lib/font-awesome/fonts";
|
$fa-font-path: $static_url + "horizon/lib/font-awesome/fonts";
|
||||||
|
|
||||||
/* Charts */
|
/* Charts */
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* This variable changes the web root of horizon to /dashboard rather
|
/* This variable changes the web root of horizon to /dashboard rather
|
||||||
than the default '/' */
|
than the default '/' */
|
||||||
$webroot: "/dashboard";
|
$static_url: "/dashboard/static/";
|
||||||
|
|
||||||
@import "../themes/default/variables";
|
@import "../themes/default/variables";
|
Loading…
Reference in New Issue
Block a user