1
0
mirror of https://github.com/gilbN/theme.park.git synced 2024-11-20 18:12:31 +01:00

added create_theme_options function

This commit is contained in:
GilbN 2021-11-01 22:35:58 +01:00
parent a515e4263a
commit 82a6c8ad0a

View File

@ -1,6 +1,6 @@
from os import listdir
from os.path import isdir, isfile, join
from json import dump, dumps, loads
from json import dump, dumps, loads, load
import subprocess
import shutil
@ -90,7 +90,7 @@ def create_json(app_folders: list = None, themes: list = None, community_themes:
return dumps(THEMES_DICT)
else:
ADDONS = loads(create_addons_json())
APPS = {"applications": {}}
APPS = {}
app_shas = subprocess.check_output(["git", "ls-files", "-s", "./css/base/*base.css"])
SHAS = get_shas(app_shas)
APPS.update(dict(sorted({
@ -101,6 +101,14 @@ def create_json(app_folders: list = None, themes: list = None, community_themes:
} for app in app_folders if not isfile(f'./css/base/{app}/.deprecated')
}
}.items())))
APPS.update(dict(sorted({
"deprecated": {
app: {
"base_css": f"https://{DOMAIN}/css/base/{app}/{app}-base.css?sha={SHAS.get(f'{app}-base.css')}",
"addons": ADDONS["addons"][app] if app in ADDONS["addons"] else {}
} for app in app_folders if isfile(f'./css/base/{app}/.deprecated')
}
}.items())))
THEMES = loads(create_json(themes=themes, community_themes=community_themes, no_sub_folders=True))
APPS.update(ADDONS)
APPS.update(THEMES)
@ -124,6 +132,22 @@ def temporary_copy_files():
continue
shutil.copytree(src,src_dst[src],dirs_exist_ok=True)
def create_theme_options():
def create_app(folder):
with open(f"{folder}/{app}/{theme.lower()}.css", "w") as create_app:
content = f'@import url("{applications[app]["base_css"]}");\n@import url("{themes[theme]["url"]}");'
create_app.write(content)
with open("themes.json") as themes:
data = load(themes)
themes = data["all-themes"]
applications = data["applications"]
for app in applications:
for theme in themes:
folders = ["./CSS/themes","./css/base"]
for folder in folders:
create_app(folder)
if __name__ == "__main__":
app_folders = [name for name in listdir('./css/base') if isdir(join('./css/base', name))]
themes = [name for name in listdir('./css/theme-options') if isfile(join('./css/theme-options', name))]
@ -134,3 +158,4 @@ if __name__ == "__main__":
with open("themes.json", "w") as outfile:
dump(apps, outfile, indent=2, sort_keys=True)
temporary_copy_files()
create_theme_options()