1
0
Fork 0
forked from s3lph/matemat

feat: add support for multiple theme search paths

This commit is contained in:
s3lph 2023-03-28 20:45:09 +02:00
parent 2f79377c09
commit de110cd397
6 changed files with 27 additions and 9 deletions

View file

@ -93,7 +93,7 @@ build_debian:
- gzip -9n package/debian/matemat/usr/share/doc/matemat/changelog - gzip -9n package/debian/matemat/usr/share/doc/matemat/changelog
- cp -r static/ package/debian/matemat/usr/lib/matemat/static/ - cp -r static/ package/debian/matemat/usr/lib/matemat/static/
- cp -r templates/ package/debian/matemat/usr/lib/matemat/templates/ - cp -r templates/ package/debian/matemat/usr/lib/matemat/templates/
- mkdir -p package/debian/matemat/var/lib/matemat/ - mkdir -p package/debian/matemat/var/lib/matemat/themes/
- cp -r themes/ package/debian/matemat/usr/lib/matemat/themes/ - cp -r themes/ package/debian/matemat/usr/lib/matemat/themes/
- python3.7 setup.py egg_info install --root=package/debian/matemat/ --prefix=/usr --optimize=1 - python3.7 setup.py egg_info install --root=package/debian/matemat/ --prefix=/usr --optimize=1
- cd package/debian - cd package/debian

View file

@ -1,5 +1,18 @@
# Matemat Changelog # Matemat Changelog
<!-- BEGIN RELEASE v0.3.3 -->
## Version 0.3.3
Multiple theme search paths
### Changes
<!-- BEGIN CHANGES 0.3.3-->
- Support for multiple theme search paths
<!-- END CHANGES 0.3.3 -->
<!-- END RELEASE v0.3.3 -->
<!-- BEGIN RELEASE v0.3.2 --> <!-- BEGIN RELEASE v0.3.2 -->
## Version 0.3.2 ## Version 0.3.2

View file

@ -1,2 +1,2 @@
__version__ = '0.3.2' __version__ = '0.3.3'

View file

@ -1,6 +1,7 @@
import logging import logging
from typing import Any, Dict, Iterable, Union from typing import Any, Dict, Iterable, Union
import shlex
import sys import sys
import os.path import os.path
import bottle import bottle
@ -63,11 +64,15 @@ def _init(config: Dict[str, Any]):
@bottle.route('/static/<filename:path>') @bottle.route('/static/<filename:path>')
def serve_static_files(filename: str): def serve_static_files(filename: str):
config = get_config() config = get_config()
themeroot = os.path.abspath(os.path.join(config['themeroot'], config['theme'], 'static')) roots = []
staticroot = os.path.abspath(config['staticroot']) for themeroot in shlex.split(config['themeroot']):
resp = bottle.static_file(filename, root=themeroot) roots.append(os.path.abspath(os.path.join(themeroot, config['theme'], 'static')))
if resp.status_code == 404: roots.append(os.path.abspath(config['staticroot']))
resp = bottle.static_file(filename, root=staticroot) resp = None
for root in roots:
resp = bottle.static_file(filename, root=root)
if resp.status_code == 200:
break
return resp return resp

View file

@ -1,5 +1,5 @@
Package: matemat Package: matemat
Version: 0.3.2 Version: 0.3.3
Maintainer: s3lph <1375407-s3lph@users.noreply.gitlab.com> Maintainer: s3lph <1375407-s3lph@users.noreply.gitlab.com>
Section: web Section: web
Priority: optional Priority: optional

View file

@ -2,7 +2,7 @@
StaticPath=/usr/lib/matemat/static StaticPath=/usr/lib/matemat/static
TemplatePath=/usr/lib/matemat/templates TemplatePath=/usr/lib/matemat/templates
ThemePath=/var/lib/matemat/themes ThemePath=/var/lib/matemat/themes /usr/lib/matemat/themes
LogTarget=stdout LogTarget=stdout