Skip to content

Instantly share code, notes, and snippets.

@yarko
Created February 13, 2014 22:47
Show Gist options
  • Save yarko/8985537 to your computer and use it in GitHub Desktop.
Save yarko/8985537 to your computer and use it in GitHub Desktop.
patch for #2520, pavelib/assets.py
diff --git a/pavelib/assets.py b/pavelib/assets.py
index 3f1064e..a2022f2 100644
--- a/pavelib/assets.py
+++ b/pavelib/assets.py
@@ -7,33 +7,35 @@ from .utils.envs import Env
from .utils.cmd import cmd, django_cmd
-COFFEE_DIRS = ['lms', 'cms', 'common']
+COFFEE_DIRS = ['lms', 'cms', 'common'] # baseline paths;
SASS_LOAD_PATHS = ['./common/static/sass']
SASS_UPDATE_DIRS = ['*/static']
SASS_CACHE_PATH = '/tmp/sass-cache'
+edxapp_env = Env()
-def theme_sass_paths():
- """
- Return the a list of paths to the theme's sass assets,
- or an empty list if no theme is configured.
- """
- edxapp_env = Env()
+USE_CUSTOM_THEME = edxapp_env.feature_flags.get('USE_CUSTOM_THEME', False)
+if USE_CUSTOM_THEME:
+ THEME_NAME = edxapp_env.env_tokens.get('THEME_NAME', '')
+ THEME_ROOT = path(edxapp_env.REPO_ROOT).dirname() / "themes" / THEME_NAME
- if edxapp_env.feature_flags.get('USE_CUSTOM_THEME', False):
- theme_name = edxapp_env.env_tokens.get('THEME_NAME', '')
- theme_root = path(edxapp_env.REPO_ROOT).dirname() / "themes" / theme_name
- return [theme_root / "static" / "sass"]
-
- else:
- return []
+"""
+Return the a list of paths to the theme's sass assets,
+or an empty list if no theme is configured.
+"""
+theme_sass_paths = lambda : [THEME_ROOT / "static" / "sass"] if USE_CUSTOM_THEME else []
def compile_coffeescript():
"""
Compile CoffeeScript to JavaScript.
"""
+ # prepend custom theme path
+ if USE_CUSTOM_THEME:
+ COFFEE_DIRS.insert(0, THEME_ROOT)
+
dirs = " ".join([Env.REPO_ROOT / coffee_dir for coffee_dir in COFFEE_DIRS])
+
sh(cmd(
"node_modules/.bin/coffee", "--compile",
" `find {dirs} -type f -name \"*.coffee\"`".format(dirs=dirs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment