Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
code.vt.edu will be down for maintenance from 0530-0630 EDT Wednesday, March 26th
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
68198845
Commit
68198845
authored
9 years ago
by
Omar Al-Ithawi
Browse files
Options
Downloads
Patches
Plain Diff
Watch and process JS and CSS xmodule assets
parent
3949242c
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pavelib/assets.py
+36
-0
36 additions, 0 deletions
pavelib/assets.py
with
36 additions
and
0 deletions
pavelib/assets.py
+
36
−
0
View file @
68198845
...
...
@@ -109,6 +109,30 @@ class XModuleSassWatcher(SassWatcher):
traceback
.
print_exc
()
class
XModuleAssetsWatcher
(
PatternMatchingEventHandler
):
"""
Watches for css and js file changes
"""
ignore_directories
=
True
patterns
=
[
'
*.css
'
,
'
*.js
'
]
def
register
(
self
,
observer
):
"""
Register files with observer
"""
observer
.
schedule
(
self
,
'
common/lib/xmodule/
'
,
recursive
=
True
)
def
on_modified
(
self
,
event
):
print
(
'
\t
CHANGED:
'
,
event
.
src_path
)
try
:
process_xmodule_assets
()
except
Exception
:
# pylint: disable=broad-except
traceback
.
print_exc
()
# To refresh the hash values of static xmodule content
restart_django_servers
()
def
coffeescript_files
():
"""
return find command for paths containing coffee files
...
...
@@ -181,6 +205,17 @@ def process_xmodule_assets():
sh
(
'
xmodule_assets common/static/xmodule
'
)
def
restart_django_servers
():
"""
Restart the django server.
`$ touch` makes the Django file watcher thinks that something has changed, therefore
it restarts the server.
"""
sh
(
cmd
(
"
touch
"
,
'
lms/urls.py
'
,
'
cms/urls.py
'
,
))
def
collect_assets
(
systems
,
settings
):
"""
Collect static assets, including Django pipeline processing.
...
...
@@ -206,6 +241,7 @@ def watch_assets(options):
CoffeeScriptWatcher
().
register
(
observer
)
SassWatcher
().
register
(
observer
)
XModuleSassWatcher
().
register
(
observer
)
XModuleAssetsWatcher
().
register
(
observer
)
print
(
"
Starting asset watcher...
"
)
observer
.
start
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment