Merge "Replace django-pyscss with libsass"
This commit is contained in:
commit
b50784edfb
@ -50,7 +50,6 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.humanize',
|
'django.contrib.humanize',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
'django_pyscss',
|
|
||||||
'compressor',
|
'compressor',
|
||||||
'horizon',
|
'horizon',
|
||||||
'horizon.test',
|
'horizon.test',
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
# (c) Copyright 2015 Hewlett-Packard Development Company, L.P.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
@ -12,33 +10,61 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from django.conf import settings
|
import os.path
|
||||||
|
|
||||||
from django_pyscss.compressor import DjangoScssFilter
|
from compressor.filters.base import FilterBase
|
||||||
from django_pyscss import DjangoScssCompiler
|
from django.contrib.staticfiles.finders import get_finders
|
||||||
|
|
||||||
from scss.namespace import Namespace
|
import sass
|
||||||
from scss.types import String
|
|
||||||
|
|
||||||
|
|
||||||
class HorizonScssFilter(DjangoScssFilter):
|
def importer(path, prev):
|
||||||
def __init__(self, *args, **kwargs):
|
if path.startswith('/'):
|
||||||
super().__init__(*args, **kwargs)
|
# An absolute path was used, don't try relative paths.
|
||||||
|
candidates = [path[1:]]
|
||||||
|
elif prev == 'stdin':
|
||||||
|
# The parent is STDIN, so only try absolute paths.
|
||||||
|
candidates = [path]
|
||||||
|
else:
|
||||||
|
# Try both relative and absolute paths, prefer relative.
|
||||||
|
candidates = [
|
||||||
|
os.path.normpath(os.path.join(os.path.dirname(prev), path)),
|
||||||
|
path,
|
||||||
|
]
|
||||||
|
# Try adding _ in front of the file for partials.
|
||||||
|
for candidate in candidates[:]:
|
||||||
|
if '/' in candidate:
|
||||||
|
candidates.insert(0, '/_'.join(candidate.rsplit('/', 1)))
|
||||||
|
else:
|
||||||
|
candidates.insert(0, '_' + candidate)
|
||||||
|
# Try adding extensions.
|
||||||
|
for candidate in candidates[:]:
|
||||||
|
for ext in ['.scss', '.sass', '.css']:
|
||||||
|
candidates.append(candidate + ext)
|
||||||
|
for finder in get_finders():
|
||||||
|
# We can't use finder.find() because we need the prefixes.
|
||||||
|
for storage_filename, storage in finder.list([]):
|
||||||
|
prefix = getattr(storage, "prefix", "")
|
||||||
|
filename = os.path.join(prefix, storage_filename)
|
||||||
|
if filename in candidates:
|
||||||
|
with storage.open(storage_filename) as f:
|
||||||
|
data = f.read()
|
||||||
|
return [(filename, data)]
|
||||||
|
|
||||||
self.namespace = Namespace()
|
|
||||||
|
|
||||||
# Add variables to the SCSS Global Namespace Here
|
class ScssFilter(FilterBase):
|
||||||
self.namespace.set_variable(
|
def __init__(self, content, attrs=None, filter_type=None, charset=None,
|
||||||
'$static_url',
|
filename=None):
|
||||||
String(settings.STATIC_URL)
|
super().__init__(
|
||||||
)
|
content=content, filter_type=filter_type, filename=filename)
|
||||||
|
|
||||||
# Create a compiler with the right namespace
|
def input(self, **kwargs):
|
||||||
@property
|
args = {
|
||||||
def compiler(self):
|
'importers': [(0, importer)],
|
||||||
return DjangoScssCompiler(
|
'output_style': 'compressed',
|
||||||
# output_style is 'nested' by default, which is crazy. See:
|
}
|
||||||
# https://github.com/Kronuz/pyScss/issues/243
|
if self.filename:
|
||||||
output_style='compact', # or 'compressed'
|
args['filename'] = self.filename
|
||||||
namespace=self.namespace
|
else:
|
||||||
)
|
args['string'] = self.content
|
||||||
|
return sass.compile(**args)
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
# 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.
|
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
|
|
||||||
from django.conf import settings
|
|
||||||
from scss.grammar.expression import SassExpressionScanner
|
|
||||||
|
|
||||||
|
|
||||||
scss_asset_root = os.path.join(settings.STATIC_ROOT, 'scss', 'assets')
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
"""
|
|
||||||
This is a workaround for https://bugs.launchpad.net/horizon/+bug/1367590
|
|
||||||
It works by creating a path that django_scss will attempt to create
|
|
||||||
later if it doesn't exist. The django_pyscss code fails
|
|
||||||
intermittently because of concurrency issues. This code ignores the
|
|
||||||
exception and if it was anything other than the concurrency issue
|
|
||||||
django_pyscss will discover the problem later.
|
|
||||||
|
|
||||||
TODO (doug-fish): remove this workaround once fix for
|
|
||||||
https://github.com/fusionbox/django-pyscss/issues/23 is picked up.
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
if not os.path.exists(scss_asset_root):
|
|
||||||
os.makedirs(scss_asset_root)
|
|
||||||
except Exception as e:
|
|
||||||
LOG.info("Error precreating path %(root)s, %(exc)s",
|
|
||||||
{'root': scss_asset_root, 'exc': e})
|
|
||||||
|
|
||||||
# Fix a syntax error in regular expression, where a flag is not at the
|
|
||||||
# beginning of the expression.
|
|
||||||
# This is fixed upstream at
|
|
||||||
# https://github.com/Kronuz/pyScss/commit
|
|
||||||
# /73559d047706ccd4593cf6aa092de71f35164723
|
|
||||||
# We should remove it once we use that version.
|
|
||||||
|
|
||||||
for index, (name, value) in enumerate(SassExpressionScanner._patterns):
|
|
||||||
if name == 'OPACITY':
|
|
||||||
SassExpressionScanner._patterns[index] = ('OPACITY', '(?i)(opacity)')
|
|
@ -132,9 +132,10 @@ STATICFILES_FINDERS = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
COMPRESS_PRECOMPILERS = (
|
COMPRESS_PRECOMPILERS = (
|
||||||
('text/scss', 'horizon.utils.scss_filter.HorizonScssFilter'),
|
('text/scss', 'horizon.utils.scss_filter.ScssFilter'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
COMPRESS_FILTERS = {
|
COMPRESS_FILTERS = {
|
||||||
'css': (
|
'css': (
|
||||||
'compressor.filters.css_default.CssAbsoluteFilter',
|
'compressor.filters.css_default.CssAbsoluteFilter',
|
||||||
@ -157,8 +158,6 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'django.contrib.humanize',
|
'django.contrib.humanize',
|
||||||
'openstack_dashboard.django_pyscss_fix',
|
|
||||||
'django_pyscss',
|
|
||||||
'debreach',
|
'debreach',
|
||||||
'compressor',
|
'compressor',
|
||||||
'horizon',
|
'horizon',
|
||||||
@ -378,7 +377,6 @@ HORIZON_COMPRESS_OFFLINE_CONTEXT_BASE = {
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
# Here comes the Django settings deprecation section. Being at the very end
|
# Here comes the Django settings deprecation section. Being at the very end
|
||||||
# of settings.py allows it to catch the settings defined in local_settings.py
|
# of settings.py allows it to catch the settings defined in local_settings.py
|
||||||
# or inside one of local_settings.d/ snippets.
|
# or inside one of local_settings.d/ snippets.
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
|
@import "themes/default/variables";
|
||||||
@import "bootstrap/variables";
|
@import "bootstrap/variables";
|
||||||
@import "horizon/variables";
|
@import "horizon/variables";
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
@import "/dashboard/scss/_variables.scss";
|
||||||
|
|
||||||
// Override the web font path ... we want to set this ourselves
|
// Override the web font path ... we want to set this ourselves
|
||||||
$web-font-path: $static_url + "horizon/lib/roboto_fontface/css/roboto/roboto-fontface.css";
|
$web-font-path: $static_url + "horizon/lib/roboto_fontface/css/roboto/roboto-fontface.css";
|
||||||
$roboto-font-path: $static_url + "horizon/lib/roboto_fontface/fonts";
|
$roboto-font-path: $static_url + "horizon/lib/roboto_fontface/fonts";
|
||||||
|
@ -23,7 +23,6 @@ $icon-swap: (
|
|||||||
calendar: 'calendar',
|
calendar: 'calendar',
|
||||||
caret-up: 'menu-up',
|
caret-up: 'menu-up',
|
||||||
caret-down: 'menu-down',
|
caret-down: 'menu-down',
|
||||||
caret-up: 'menu-up',
|
|
||||||
check: 'check',
|
check: 'check',
|
||||||
chevron-down: 'chevron-down',
|
chevron-down: 'chevron-down',
|
||||||
chevron-left: 'chevron-left',
|
chevron-left: 'chevron-left',
|
||||||
|
@ -1,12 +1,3 @@
|
|||||||
// NOTE(e0ne): it's temporary workaround to until specified function will
|
|
||||||
// be supported by pyScss. We need to define this function before any MDI
|
|
||||||
// usage.
|
|
||||||
@if not function-exists("selector-append") {
|
|
||||||
@function selector-append($selector, $to-append) {
|
|
||||||
@return append-selector($selector, $to-append);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@import "animations";
|
@import "animations";
|
||||||
@import "icons";
|
@import "icons";
|
||||||
@import "components/checkboxes";
|
@import "components/checkboxes";
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
stroke-dashoffset: 0;
|
stroke-dashoffset: 0;
|
||||||
stroke-linecap: round;
|
stroke-linecap: round;
|
||||||
stroke: #db652d;
|
stroke: #db652d;
|
||||||
@include animation(material-loader-dash 1.5s ease-in-out infinite, material-loader-color 6s ease-in-out infinite);
|
@include animation("material-loader-dash 1.5s ease-in-out infinite, material-loader-color 6s ease-in-out infinite");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ Babel>=2.6.0 # BSD
|
|||||||
Django>=4.2,<4.3 # BSD
|
Django>=4.2,<4.3 # BSD
|
||||||
django-compressor>=4.4 # MIT
|
django-compressor>=4.4 # MIT
|
||||||
django-debreach>=1.4.2 # BSD License (2 clause)
|
django-debreach>=1.4.2 # BSD License (2 clause)
|
||||||
django-pyscss>=2.0.3 # BSD License (2 clause)
|
|
||||||
futurist>=1.2.0 # Apache-2.0
|
futurist>=1.2.0 # Apache-2.0
|
||||||
iso8601>=0.1.11 # MIT
|
iso8601>=0.1.11 # MIT
|
||||||
keystoneauth1>=4.3.1 # Apache-2.0
|
keystoneauth1>=4.3.1 # Apache-2.0
|
||||||
@ -21,7 +20,7 @@ oslo.serialization>=4.3.0 # Apache-2.0
|
|||||||
oslo.upgradecheck>=1.5.0 # Apache-2.0
|
oslo.upgradecheck>=1.5.0 # Apache-2.0
|
||||||
oslo.utils>=7.0.0 # Apache-2.0
|
oslo.utils>=7.0.0 # Apache-2.0
|
||||||
osprofiler>=3.4.2 # Apache-2.0
|
osprofiler>=3.4.2 # Apache-2.0
|
||||||
pyScss>=1.4.0 # MIT License
|
libsass>=0.23.0 # MIT
|
||||||
python-cinderclient>=8.0.0 # Apache-2.0
|
python-cinderclient>=8.0.0 # Apache-2.0
|
||||||
python-glanceclient>=2.8.0 # Apache-2.0
|
python-glanceclient>=2.8.0 # Apache-2.0
|
||||||
python-keystoneclient>=3.22.0 # Apache-2.0
|
python-keystoneclient>=3.22.0 # Apache-2.0
|
||||||
|
Loading…
Reference in New Issue
Block a user