Commit c7713b62 by cahrens

Merge branch 'master' into feature/christina/fields

parents 46100fd2 3650316f
......@@ -206,6 +206,8 @@ PIPELINE_CSS = {
},
}
# test_order: Determines the position of this chunk of javascript on
# the jasmine test page
PIPELINE_JS = {
'main': {
'source_filenames': sorted(
......@@ -213,6 +215,7 @@ PIPELINE_JS = {
rooted_glob(PROJECT_ROOT / 'static/', 'coffee/src/**/*.js')
) + ['js/hesitate.js', 'js/base.js'],
'output_filename': 'js/cms-application.js',
'test_order': 0
},
'module-js': {
'source_filenames': (
......@@ -220,11 +223,8 @@ PIPELINE_JS = {
rooted_glob(COMMON_ROOT / 'static/', 'xmodule/modules/js/*.js')
),
'output_filename': 'js/cms-modules.js',
'test_order': 1
},
'spec': {
'source_filenames': sorted(rooted_glob(PROJECT_ROOT / 'static/', 'coffee/spec/**/*.js')),
'output_filename': 'js/cms-spec.js'
}
}
PIPELINE_CSS_COMPRESSOR = None
......
......@@ -20,7 +20,7 @@ PIPELINE_JS['js-test-source'] = {
'source_filenames': sum([
pipeline_group['source_filenames']
for group_name, pipeline_group
in PIPELINE_JS.items()
in sorted(PIPELINE_JS.items(), key=lambda item: item[1].get('test_order', 1e100))
if group_name != 'spec'
], []),
'output_filename': 'js/cms-test-source.js'
......
......@@ -7,6 +7,7 @@
"js/vendor/jquery.cookie.js",
"js/vendor/json2.js",
"js/vendor/underscore-min.js",
"js/vendor/backbone-min.js"
"js/vendor/backbone-min.js",
"js/vendor/jquery.leanModal.min.js"
]
}
......@@ -30,7 +30,7 @@
<body class="<%block name='bodyclass'></%block> hide-wip">
<%include file="courseware_vendor_js.html"/>
<script type="text/javascript" src="jsi18n/"></script>
<script type="text/javascript" src="/jsi18n/"></script>
<script type="text/javascript" src="${static.url('js/vendor/json2.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/underscore-min.js')}"></script>
<script type="text/javascript" src="${static.url('js/vendor/backbone-min.js')}"></script>
......
......@@ -26,12 +26,15 @@ EOL
printf '\E[0m'
}
error() {
printf '\E[31m'; echo "$@"; printf '\E[0m'
}
output() {
printf '\E[36m'; echo "$@"; printf '\E[0m'
}
usage() {
cat<<EO
......@@ -47,11 +50,10 @@ EO
}
info() {
cat<<EO
MITx base dir : $BASE
Python dir : $PYTHON_DIR
Ruby dir : $RUBY_DIR
Python virtualenv dir : $PYTHON_DIR
Ruby RVM dir : $RUBY_DIR
Ruby ver : $RUBY_VER
EO
......@@ -85,28 +87,46 @@ clone_repos() {
if [[ -d "$BASE/data/$REPO" ]]; then
mv "$BASE/data/$REPO" "${BASE}/data/$REPO.bak.$$"
fi
cd "$BASE/data"
cd "$BASE/data"
git clone git@github.com:MITx/$REPO
fi
}
### START
PROG=${0##*/}
BASE="$HOME/mitx_all"
PYTHON_DIR="$BASE/python"
RUBY_DIR="$BASE/ruby"
RUBY_VER="1.9.3"
LOG="/var/tmp/install-$(date +%Y%m%d-%H%M%S).log"
# Adjust this to wherever you'd like to place the codebase
BASE="${PROJECT_HOME:-$HOME}/mitx_all"
# Read arguments
# Use a sensible default (~/.virtualenvs) for your Python virtualenvs
# unless you've already got one set up with virtualenvwrapper.
PYTHON_DIR=${WORKON_HOME:-"$HOME/.virtualenvs"}
# RVM defaults its install to ~/.rvm, but use the overridden rvm_path
# if that's what's preferred.
RUBY_DIR=${rvm_path:-"$HOME/.rvm"}
LOG="/var/tmp/install-$(date +%Y%m%d-%H%M%S).log"
# Make sure the user's not about to do anything dumb
if [[ $EUID -eq 0 ]]; then
error "This script should not be run using sudo or as the root user"
usage
exit 1
fi
# If in an existing virtualenv, bail
if [[ "x$VIRTUAL_ENV" != "x" ]]; then
envname=`basename $VIRTUAL_ENV`
error "Looks like you're already in the \"$envname\" virtual env."
error "Run \`deactivate\` and then re-run this script."
usage
exit 1
fi
# Read arguments
ARGS=$(getopt "cvhs" "$*")
if [[ $? != 0 ]]; then
usage
......@@ -236,31 +256,69 @@ clone_repos
bash $BASE/mitx/install-system-req.sh
output "Installing RVM, Ruby, and required gems"
# If we're not installing RVM in the default location, then we'll do some
# funky stuff to make sure that we load in the RVM stuff properly on login.
if [ "$HOME/.rvm" != $RUBY_DIR ]; then
if ! grep -q "export rvm_path=$RUBY_DIR" ~/.rvmrc; then
if [[ -f $HOME/.rvmrc ]]; then
output "Copying existing .rvmrc to .rvmrc.bak"
cp $HOME/.rvmrc $HOME/.rvmrc.bak
fi
output "Creating $HOME/.rvmrc so rvm uses $RUBY_DIR"
echo "export rvm_path=$RUBY_DIR" > $HOME/.rvmrc
fi
fi
# Install Ruby RVM
curl -sL get.rvm.io | bash -s -- --version 1.15.7
output "Installing rvm and ruby"
# Ensure we have RVM available as a shell function so that it can mess
# with the environment and set everything up properly. The RVM install
# process adds this line to login scripts, so this shouldn't be necessary
# for the user to do each time.
if [[ `type -t rvm` != "function" ]]; then
source $RUBY_DIR/scripts/rvm
fi
if ! grep -q "export rvm_path=$RUBY_DIR" ~/.rvmrc; then
if [[ -f $HOME/.rvmrc ]]; then
output "Copying existing .rvmrc to .rvmrc.bak"
cp $HOME/.rvmrc $HOME/.rvmrc.bak
fi
output "Creating $HOME/.rvmrc so rvm uses $RUBY_DIR"
echo "export rvm_path=$RUBY_DIR" > $HOME/.rvmrc
# Ruby doesn't like to build with clang, which is the default on OS X, so
# use gcc instead. This may not work, since if your gcc was installed with
# XCode 4.2 or greater, you have an LLVM-based gcc, which also doesn't
# always play nicely with Ruby, though it seems to be better than clang.
# You may have to install apple-gcc42 using Homebrew if this doesn't work.
# See `rvm requirements` for more information.
case `uname -s` in
Darwin)
export CC=gcc
;;
esac
# Let the repo override the version of Ruby to install
if [[ -r $BASE/mitx/.ruby-version ]]; then
RUBY_VER=`cat $BASE/mitx/.ruby-version`
fi
curl -sL get.rvm.io | bash -s -- --version 1.15.7
source $RUBY_DIR/scripts/rvm
# Current stable version of RVM (1.19.0) requires the following to build Ruby:
#
# autoconf automake libtool pkg-config libyaml libxml2 libxslt libksba openssl
#
# If we decide to upgrade from the current version (1.15.7), can run
#
# LESS="-E" rvm install $RUBY_VER --autolibs=3 --with-readline
#
# to have RVM look for a package manager like Homebrew and install any missing
# libs automatically. RVM's --autolibs flag defaults to 2, which will fail if
# any required libs are missing.
LESS="-E" rvm install $RUBY_VER --with-readline
# Create the "mitx" gemset
rvm use "$RUBY_VER@mitx" --create
output "Installing gem bundler"
gem install bundler
output "Installing ruby packages"
# hack :(
cd $BASE/mitx || true
bundle install
bundle install --gemfile $BASE/mitx/Gemfile
# Install Python virtualenv
......@@ -274,16 +332,31 @@ case `uname -s` in
;;
esac
# virtualenvwrapper uses the $WORKON_HOME env var to determine where to place
# virtualenv directories. Make sure it matches the selected $PYTHON_DIR.
export WORKON_HOME=$PYTHON_DIR
# Load in the mkvirtualenv function if needed
if [[ `type -t mkvirtualenv` != "function" ]]; then
source `which virtualenvwrapper.sh`
fi
# Create MITx virtualenv and link it to repo
# virtualenvwrapper automatically sources the activation script
if [[ $systempkgs ]]; then
virtualenv --system-site-packages "$PYTHON_DIR"
mkvirtualenv -a "$BASE/mitx" --system-site-packages mitx || {
error "mkvirtualenv exited with a non-zero error"
return 1
}
else
# default behavior for virtualenv>1.7 is
# --no-site-packages
virtualenv "$PYTHON_DIR"
mkvirtualenv -a "$BASE/mitx" mitx || {
error "mkvirtualenv exited with a non-zero error"
return 1
}
fi
# activate mitx python virtualenv
source $PYTHON_DIR/bin/activate
# compile numpy and scipy if requested
......@@ -315,6 +388,8 @@ case `uname -s` in
# need latest pytz before compiling numpy and scipy
pip install -U pytz
pip install numpy
# scipy needs cython
pip install cython
# fixes problem with scipy on 10.8
pip install -e git+https://github.com/scipy/scipy#egg=scipy-dev
;;
......@@ -344,14 +419,18 @@ cat<<END
Success!!
To start using Django you will need to activate the local Python
and Ruby environment (at this time rvm only supports bash) :
and Ruby environments. Ensure the following lines are added to your
login script, and source your login script if needed:
source `which virtualenvwrapper.sh`
source $RUBY_DIR/scripts/rvm
Then, every time you're ready to work on the project, just run
$ source $RUBY_DIR/scripts/rvm
$ source $PYTHON_DIR/bin/activate
$ workon mitx
To initialize Django
$ cd $BASE/mitx
$ rake django-admin[syncdb]
$ rake django-admin[migrate]
......
......@@ -440,6 +440,9 @@ PIPELINE_CSS = {
},
}
# test_order: Determines the position of this chunk of javascript on
# the jasmine test page
PIPELINE_JS = {
'application': {
......@@ -455,31 +458,39 @@ PIPELINE_JS = {
'js/sticky_filter.js',
'js/query-params.js',
],
'output_filename': 'js/lms-application.js'
'output_filename': 'js/lms-application.js',
'test_order': 1,
},
'courseware': {
'source_filenames': courseware_js,
'output_filename': 'js/lms-courseware.js'
'output_filename': 'js/lms-courseware.js',
'test_order': 2,
},
'main_vendor': {
'source_filenames': main_vendor_js,
'output_filename': 'js/lms-main_vendor.js',
'test_order': 0,
},
'module-js': {
'source_filenames': rooted_glob(COMMON_ROOT / 'static', 'xmodule/modules/js/*.js'),
'output_filename': 'js/lms-modules.js',
'test_order': 3,
},
'discussion': {
'source_filenames': discussion_js,
'output_filename': 'js/discussion.js'
'output_filename': 'js/discussion.js',
'test_order': 4,
},
'staff_grading': {
'source_filenames': staff_grading_js,
'output_filename': 'js/staff_grading.js'
'output_filename': 'js/staff_grading.js',
'test_order': 5,
},
'open_ended': {
'source_filenames': open_ended_js,
'output_filename': 'js/open_ended.js'
'output_filename': 'js/open_ended.js',
'test_order': 6,
}
}
......
......@@ -20,14 +20,14 @@ PIPELINE_JS['js-test-source'] = {
'source_filenames': sum([
pipeline_group['source_filenames']
for group_name, pipeline_group
in PIPELINE_JS.items()
in sorted(PIPELINE_JS.items(), key=lambda item: item[1].get('test_order', 1e100))
if group_name != 'spec'
], []),
'output_filename': 'js/lms-test-source.js'
}
PIPELINE_JS['spec'] = {
'source_filenames': sorted(rooted_glob(PROJECT_ROOT / 'static/', 'coffee/spec/**/*.coffee')),
'source_filenames': sorted(rooted_glob(PROJECT_ROOT / 'static/', 'coffee/spec/**/*.js')),
'output_filename': 'js/lms-spec.js'
}
......
{
"js_files": [
"/static/js/vendor/RequireJS.js",
"/static/js/vendor/jquery.min.js",
"/static/js/vendor/jquery-ui.min.js",
"/static/js/vendor/jquery.leanModal.min.js",
"/static/js/vendor/flot/jquery.flot.js"
]
......
......@@ -306,6 +306,7 @@ end
desc "Open jasmine tests for #{system} in your default browser"
task "browse_jasmine_#{system}" do
compile_assets()
django_for_jasmine(system, true) do |jasmine_url|
Launchy.open(jasmine_url)
puts "Press ENTER to terminate".red
......@@ -315,6 +316,7 @@ end
desc "Use phantomjs to run jasmine tests for #{system} from the console"
task "phantomjs_jasmine_#{system}" do
compile_assets()
phantomjs = ENV['PHANTOMJS_PATH'] || 'phantomjs'
django_for_jasmine(system, false) do |jasmine_url|
sh("#{phantomjs} common/test/phantom-jasmine/lib/run_jasmine_test.coffee #{jasmine_url}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment