Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
59106f23
Commit
59106f23
authored
Mar 27, 2014
by
yarko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set reasonable SERVICE_VARIANT based on command line; ensure theme passed to coffeescript also;
parent
cc67c07d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
19 deletions
+26
-19
pavelib/assets.py
+16
-19
pavelib/utils/envs.py
+10
-0
No files found.
pavelib/assets.py
View file @
59106f23
...
...
@@ -11,11 +11,24 @@ import traceback
from
.utils.envs
import
Env
from
.utils.cmd
import
cmd
,
django_cmd
# setup baseline paths
COFFEE_DIRS
=
[
'lms'
,
'cms'
,
'common'
]
SASS_LOAD_PATHS
=
[
'./common/static/sass'
]
SASS_UPDATE_DIRS
=
[
'*/static'
]
SASS_CACHE_PATH
=
'/tmp/sass-cache'
THEME_COFFEE_PATHS
=
[]
THEME_SASS_PATHS
=
[]
edxapp_env
=
Env
()
if
edxapp_env
.
feature_flags
.
get
(
'USE_CUSTOM_THEME'
,
False
):
theme_name
=
edxapp_env
.
env_tokens
.
get
(
'THEME_NAME'
,
''
)
parent_dir
=
path
(
edxapp_env
.
REPO_ROOT
)
.
abspath
()
.
parent
theme_root
=
parent_dir
/
"themes"
/
theme_name
THEME_COFFEE_PATHS
=
[
theme_root
]
THEME_SASS_PATHS
=
[
theme_root
/
"static"
/
"sass"
]
class
CoffeeScriptWatcher
(
PatternMatchingEventHandler
):
"""
...
...
@@ -54,7 +67,7 @@ class SassWatcher(PatternMatchingEventHandler):
"""
register files with observer
"""
for
dirname
in
SASS_LOAD_PATHS
+
SASS_UPDATE_DIRS
+
theme_sass_paths
()
:
for
dirname
in
SASS_LOAD_PATHS
+
SASS_UPDATE_DIRS
+
THEME_SASS_PATHS
:
paths
=
[]
if
'*'
in
dirname
:
paths
.
extend
(
glob
.
glob
(
dirname
))
...
...
@@ -92,27 +105,11 @@ class XModuleSassWatcher(SassWatcher):
traceback
.
print_exc
()
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
()
if
edxapp_env
.
feature_flags
.
get
(
'USE_CUSTOM_THEME'
,
False
):
theme_name
=
edxapp_env
.
env_tokens
.
get
(
'THEME_NAME'
,
''
)
parent_dir
=
path
(
edxapp_env
.
REPO_ROOT
)
.
abspath
()
.
parent
theme_root
=
parent_dir
/
"themes"
/
theme_name
return
[
theme_root
/
"static"
/
"sass"
]
else
:
return
[]
def
coffeescript_files
():
"""
return find command for paths containing coffee files
"""
dirs
=
" "
.
join
([
Env
.
REPO_ROOT
/
coffee_dir
for
coffee_dir
in
COFFEE_DIRS
])
dirs
=
" "
.
join
(
THEME_COFFEE_PATHS
+
[
Env
.
REPO_ROOT
/
coffee_dir
for
coffee_dir
in
COFFEE_DIRS
])
return
cmd
(
'find'
,
dirs
,
'-type f'
,
'-name
\"
*.coffee
\"
'
)
...
...
@@ -131,7 +128,7 @@ def compile_sass(debug=False):
"""
Compile Sass to CSS.
"""
theme_paths
=
theme_sass_paths
()
theme_paths
=
THEME_SASS_PATHS
sh
(
cmd
(
'sass'
,
''
if
debug
else
'--style compressed'
,
"--cache-location {cache}"
.
format
(
cache
=
SASS_CACHE_PATH
),
...
...
pavelib/utils/envs.py
View file @
59106f23
...
...
@@ -21,6 +21,16 @@ class Env(object):
# We use this to determine which envs.json file to load.
SERVICE_VARIANT
=
os
.
environ
.
get
(
'SERVICE_VARIANT'
,
None
)
# If service variant not configured in env, then pass the correct
# environment for lms / cms
if
not
SERVICE_VARIANT
:
# this will intentionally catch "";
args
=
sys
.
argv
[
1
:]
if
'lms'
in
args
:
SERVICE_VARIANT
=
'lms'
elif
any
(
i
in
args
for
i
in
(
'cms'
,
'studio'
)):
SERVICE_VARIANT
=
'cms'
@lazy
def
env_tokens
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment