From 1d851713a0f945d45cffe37a5055bfd4c6c86787 Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Wed, 25 Jul 2012 21:36:52 -0400 Subject: [PATCH 1/3] Compiling coffee files in course data directories on startup. --- lms/envs/common.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lms/envs/common.py b/lms/envs/common.py index b1fbbb9bab..c8bfaa35e9 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -429,6 +429,22 @@ PIPELINE_JS = { } } +if os.path.isdir(DATA_DIR): + for course_dir in os.listdir(DATA_DIR): + js_dir = DATA_DIR / course_dir / "js" + if not os.path.isdir(js_dir): + continue + for filename in os.listdir(js_dir): + if filename.endswith('coffee'): + new_filename = os.path.splitext(filename)[0] + ".js" + if os.path.exists(js_dir / new_filename): + coffee_timestamp = os.stat(js_dir / filename).st_mtime + js_timestamp = os.stat(js_dir / new_filename).st_mtime + if coffee_timestamp <= js_timestamp: + continue + os.system("coffee -c %s" % (js_dir / filename)) + print "coffee -c %s" % (js_dir / filename) + PIPELINE_COMPILERS = [ 'pipeline.compilers.sass.SASSCompiler', 'pipeline.compilers.coffee.CoffeeScriptCompiler', From 3002260de53b07b9443c8f7baee645027e958a5c Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Wed, 25 Jul 2012 21:36:52 -0400 Subject: [PATCH 2/3] Compiling coffee files in course data directories on startup. --- lms/envs/common.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lms/envs/common.py b/lms/envs/common.py index b1fbbb9bab..4c16380b9c 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -429,6 +429,21 @@ PIPELINE_JS = { } } +if os.path.isdir(DATA_DIR): + for course_dir in os.listdir(DATA_DIR): + js_dir = DATA_DIR / course_dir / "js" + if not os.path.isdir(js_dir): + continue + for filename in os.listdir(js_dir): + if filename.endswith('coffee'): + new_filename = os.path.splitext(filename)[0] + ".js" + if os.path.exists(js_dir / new_filename): + coffee_timestamp = os.stat(js_dir / filename).st_mtime + js_timestamp = os.stat(js_dir / new_filename).st_mtime + if coffee_timestamp <= js_timestamp: + continue + os.system("coffee -c %s" % (js_dir / filename)) + PIPELINE_COMPILERS = [ 'pipeline.compilers.sass.SASSCompiler', 'pipeline.compilers.coffee.CoffeeScriptCompiler', From 73261719ce7d509a16c9eff9f985fcb704b51dbf Mon Sep 17 00:00:00 2001 From: Arjun Singh Date: Thu, 26 Jul 2012 13:14:00 -0400 Subject: [PATCH 3/3] Added TODO near temporary code. --- lms/envs/common.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lms/envs/common.py b/lms/envs/common.py index 4c16380b9c..54fb94e7bd 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -429,6 +429,9 @@ PIPELINE_JS = { } } +# Compile all coffee files in course data directories if they are out of date. +# TODO: Remove this once we move data into Mongo. This is only temporary while +# course data directories are still in use. if os.path.isdir(DATA_DIR): for course_dir in os.listdir(DATA_DIR): js_dir = DATA_DIR / course_dir / "js"