Merge "SCSS $webroot should inherit from settings.py"

This commit is contained in:
Jenkins 2015-08-28 09:15:53 +00:00 committed by Gerrit Code Review
commit a085b2e0c3
5 changed files with 57 additions and 19 deletions

View File

@ -1086,18 +1086,6 @@ the web server.
For example, if you're accessing the Dashboard via
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::
Additional settings may be required in the config files of your webserver
@ -1144,6 +1132,13 @@ webserver configuration should be updated to match.
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:
https://docs.djangoproject.com/en/1.7/ref/settings/#static-url

View 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
)

View File

@ -142,7 +142,7 @@ STATICFILES_FINDERS = (
)
COMPRESS_PRECOMPILERS = (
('text/scss', 'django_pyscss.compressor.DjangoScssFilter'),
('text/scss', 'horizon.utils.scss_filter.HorizonScssFilter'),
)
COMPRESS_CSS_FILTERS = (

View File

@ -2,10 +2,10 @@
to our variables */
@import "/custom/variables";
/* This variable can be used to change the web root of horizon
default value is already '/' */
$webroot: "" !default;
/* When used with Horizon via Django, this value is set automatically from
settings.py and is added dynamically to the namespace through
horizon/utils/scss_filter.py */
$static_url: "/static/" !default;
/* Horizon Custom Variables */
@ -59,7 +59,7 @@ $rbrowser-footer-background-color: #f1f1f1;
// .table-striped-datatable styles.
// 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 */

View File

@ -1,5 +1,5 @@
/* This variable changes the web root of horizon to /dashboard rather
than the default '/' */
$webroot: "/dashboard";
$static_url: "/dashboard/static/";
@import "../themes/default/variables";