backend and frontend
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


| Canvas |

This is the entire Canvas repo, including application code and configuration, without being cleaned up and prepped for renewed use. It's definitely doable to get this back into a running state, but please treat the configuration management parts as documentation more than pieces of reusable automation.

As for the bits of DrawQuest in this repo: for a while we ran both sites out of the same repo (the DrawQuest backend requirements were happily similar to what we'd already built with Canvas); once that became a burden, we stopped forking in code and forked in git instead.

## The instructions below are also untouched. They won't help as-is but may be a helpful guide to piece things back together.

If you have any questions feel free to reach out to

Note: Use of the registered "CANVAS" trademark is not conferred by the LICENSE. You may not use "Canvas" in the name of any derivative works without prior written permission.


1. Prerequisites:

# MANUALLY: Install XCode via thumb drive or App Store
xcode-select --install
java # type this, press enter, will prompt you to install Java
ruby -e "$(curl -fsSLk"
brew install git ack redis nginx pil solr wget memcached # requires installed XCode
sudo ln -s /usr/local/lib/python2.7/site-packages/PIL* /Library/Python/2.7/site-packages/

# Port 80/443 support
cd /tmp
tar -xzf ./canvas_forward_http.tgz
sudo ./
# MANUAL STEP (Window may pop up behind other windows if you're using spaces): Press "Inject" button

# PhantomJS
cd /tmp
# You can just install the DMG manually or run the following command.
hdiutil attach qt-mac-opensource-4.7.4.dmg && cd /Volumes/Qt\ 4.7.4/ && sudo installer -pkg Qt.mpkg -target / && cd -
mkdir -p ~/Packages && cd ~/Packages

# DO THIS IN ~/Packages
wget && unzip

# PySide
cd /tmp
open pyside-1.1.0-qt47-py27apple.pkg
# Follow the installation wizard.

# ENSURE you have an encrypted location to place your Canvas files (use FileVault for OSX, encrypted home/private in Ubuntu)
git config --global "Your Name"
git config --global
# Ensure your new ssh public key (`ssh-keygen`) is uploaded to your GitHub account at this point.
git clone
sudo ln -s "`pwd`/canvas" /var/canvas

# Add canvas bash commands
echo ". /var/canvas/.bashrc" >> ~/.bash_profile && source ~/.bash_profile
# Install python dependencies with pip
sudo easy_install pip
sudo /var/canvas/requirements/

2. Setting up local data:
cd /var/canvas/website
python syncdb
redis-server redis.conf # migration needs redis
python migrate canvas
python migrate
python solr_import group && python solr_import comment
open # and manually upload /var/canvas/website/static/img/600-600.png (allows upload from drawing)

3. Running Sass:
Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. ItÕs translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.

A subset of the stylesheets used on the site are generated by Sass. The rule is that if a CSS file looks minified or all its content is in one
line then it is controlled by sass. Hence, look for it under /static/scss and change it there. There is a conversion step that needs to run after
making changes. But you can run the Sass Daemon and it will watch the files for changes and convert them as needed.

To install Sass, you'll need to have Ruby, then run the sass alias:
sudo gem install --version 3.1.15 sass

4. Running the site:


In development mode, Django logs are written to /run/django_gunicorn.log.
You can use logs like this:
import logging
logging.debug("debug message").

You can also run a tail on the log file to see the log messages:
tail -f run/django_gunicorn.log

Reset local data:
cd /var/canvas/website
rm db.sqlite
python syncdb
python migrate
redis-cli FLUSHALL
rm -rf /var/canvas/deploy/etcpuppet/modules/solr/files/solr/*/data

Data Migrations:
You need to migrate the database schema whenever you make changes to models that will affect the corresponding database tables.
We use a tool called South to make this easy. Here is how to use it:
1. First run the schema migration locally:
python schemamigration canvas --auto

This creates a South migration file in canvas/migrations/. It is a Python file. Open it and look through it to verify the changes make sense.

2. You should comment out code that uses the new changes until you've migrated the schema on production. To run the migrations in production, you'll have
to SSH into the Gateway[1]. The Gateway and other machines in production need to have your public key. Mike can do this for you.

a. SSH into the Gateway: There is a command for that! (defined in /var/canvas/.bashrc):

If your username on your local machine is different from your username, then use this:
gw -l < username>

b. Once on the Gateway, you can SSH into Cron:
ssh `ip -rg cron`
(Note the backticks. It executed the enclosed command and it becomes the operand)

Now you're on Cron.

c. Execute the schema migration script on Cron:
python schemamigration canvas --auto

d. You can now push any code that uses the new schema.

[1] Gateway: It is a machine through which you can access other machines in the cluster. It is the only machine in the cluster that you can externally
SSH into.

The Canvas JavaScript API
The JavaScript api wrapper in statis/js/canvas_api.js is auto generated from Whenever you add a new api or change the signature of an api
method, you must regenerate the JS wrapper:
python generate_js_api

sudo pip install RunSnakeRun
mkdir -p ~/.config
runsnake foo.pstats