From 4273ad6293f96d46bc04d96bb2035e2e61b9431c Mon Sep 17 00:00:00 2001 From: Dennis Ahrens <dennis.ahrens@hs-hannover.de> Date: Wed, 14 Feb 2018 10:18:20 +0100 Subject: [PATCH] Make target static folder configurable through settings --- hshassets/app_settings/defaults.py | 7 +++++++ hshassets/utils.py | 8 ++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hshassets/app_settings/defaults.py b/hshassets/app_settings/defaults.py index d3e041a1..f257c2a2 100644 --- a/hshassets/app_settings/defaults.py +++ b/hshassets/app_settings/defaults.py @@ -28,3 +28,10 @@ SCSS_INCLUDE_PATHS = [ # URI to the live service.it portal SERVICE_IT_URI = 'https://service.it.hs-hannover.de/' + +# THIS IS STILL EXPERIMENTAL. +# {'hshassets': 'myprojectsapp'} +# This way you say: when you render your assets from within my project (where this setting is located) +# Put the results from the assets in app KEY (hshassets) into the static folder of VALUE (myprojectapp) +# as a result you'll find myprojectapp/static/hshassets/ full of compiled assets from hshassets. +STATIC_TARGET_APPS = {} diff --git a/hshassets/utils.py b/hshassets/utils.py index 3ef9a375..aa0d1644 100644 --- a/hshassets/utils.py +++ b/hshassets/utils.py @@ -1,7 +1,7 @@ from django.conf import settings from hshassets import logger -from hshassets.app_settings import COLOR_SCHEME, SCSS_INCLUDE_PATHS +from hshassets.app_settings import COLOR_SCHEME, SCSS_INCLUDE_PATHS, STATIC_TARGET_APPS from importlib import import_module @@ -13,7 +13,7 @@ import shutil def get_asset_directories(): - ''' get every app path that contains an "asset" folder on its root ''' + """get every app path that contains an "asset" folder on its root""" asset_apps = {} @@ -25,11 +25,15 @@ def get_asset_directories(): asset_apps.update({ app_name: { 'app_path': app_path, + 'static_base_path': app_path + '/static/', 'static_path': app_path + '/static/' + app_name, 'asset_path': app_path + '/assets' } }) + for source_app, target_app in STATIC_TARGET_APPS.items(): + asset_apps[source_app]['static_path'] = asset_apps[target_app]['static_base_path'] + source_app + return asset_apps -- GitLab