misc: use scss for all css files (#62936)

This commit is contained in:
Frédéric Péters 2022-03-18 13:21:38 +01:00
parent be7d250b87
commit 7b141061e7
12 changed files with 47 additions and 5 deletions

2
.gitignore vendored
View File

@ -11,6 +11,8 @@ authentic.egg-info
local_settings.py
log.log
authentic2/locale/fr/LC_MESSAGES/django.mo
*.css
*.css.map
local_settings.*
*.egg-info
*.mo

View File

@ -7,9 +7,10 @@ recursive-exclude tests_rbac *.pyc
include tox.ini .coveragerc
# static
recursive-include src/authentic2/static *.css *.js *.ico *.gif *.png *.jpg
recursive-include src/authentic2/manager/static *.css *.js *.png
recursive-include src/authentic2_auth_fc/static/authentic2_auth_fc *.css *.js *.png *.svg
recursive-include src/authentic2/static *.css *.scss *.js *.ico *.gif *.png *.jpg
recursive-include src/authentic2/manager/static *.css *.scss *.js *.png
recursive-include src/authentic2_auth_fc/static/authentic2_auth_fc *.css *.scss *.js *.png *.svg
recursive-include src/authentic2_idp_oidc/static/authentic2_idp_oidc *.css *.scss *.js *.png *.svg
# templates
recursive-include src/authentic2/templates *.html *.txt *.xml

2
debian/control vendored
View File

@ -3,7 +3,7 @@ Section: python
Priority: optional
Maintainer: Benjamin Dauvergne <bdauvergne@entrouvert.com>
Build-Depends-Indep: python3-all-dev
Build-Depends: debhelper-compat (= 12), dh-python, python3-setuptools, python3-django
Build-Depends: debhelper-compat (= 12), dh-python, python3-setuptools, python3-django, sassc
Standards-Version: 3.9.6
Homepage: http://dev.entrouvert.org/projects/authentic/

View File

@ -10,6 +10,8 @@ import subprocess
import sys
from distutils.cmd import Command
from distutils.command.build import build as _build
from distutils.errors import CompileError
from distutils.spawn import find_executable
from setuptools import find_packages, setup
from setuptools.command.install_lib import install_lib as _install_lib
@ -47,8 +49,44 @@ class compile_translations(Command):
os.chdir(curdir)
class compile_scss(Command):
description = 'compile scss files into css files'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
sass_bin = None
for program in ('sassc', 'sass'):
sass_bin = find_executable(program)
if sass_bin:
break
if not sass_bin:
raise CompileError(
'A sass compiler is required but none was found. See sass-lang.com for choices.'
)
for path, dirnames, filenames in os.walk('src'):
for filename in filenames:
if not filename.endswith('.scss'):
continue
if filename.startswith('_'):
continue
subprocess.check_call(
[
sass_bin,
'%s/%s' % (path, filename),
'%s/%s' % (path, filename.replace('.scss', '.css')),
]
)
class build(_build):
sub_commands = [('compile_translations', None)] + _build.sub_commands
sub_commands = [('compile_translations', None), ('compile_scss', None)] + _build.sub_commands
class sdist(_sdist):
@ -166,6 +204,7 @@ setup(
cmdclass={
'build': build,
'install_lib': install_lib,
'compile_scss': compile_scss,
'compile_translations': compile_translations,
'sdist': sdist,
},