OpenLightingProject / rdm-app

Code for the rdm.openlighting.org site
http://rdm.openlighting.org
17 stars 11 forks source link
appengine bower gae google-appengine grunt javascript python rdm

rdm-app

Build Status

This is the codebase for the rdm.openlighting.org website.

If you're intested in how PID definitions work, see https://wiki.openlighting.org/index.php/RDM_PID_Definitions

Development Setup

On the production instance, the javascript is minified using UglifyJS. Before you start changing the code, or deploy to appengine you'll need to download the javascript tools that are used for this process.

The tools are managed using nodejs's package manager npm. The packages are downloaded using npm and bower. Bower is called using grunt

If all of this seems rather complex don't despair, once everything is installed it's very easy to use.

1, Install npm.

2, Install grunt-cli globally yourself by running either

npm install -g grunt-cli

or

sudo npm install -g grunt-cli

3, Use npm to install the remaining dependencies. In the root directory of the project run:

npm install
grunt bower

This will install the node.js dependencies (grunt, bower, karma) and then run the grunt task for installing the bower packages.

Important!

The bower packages should only be installed using grunt, since grunt will place them in static/libs, where both appengine & karma expect them. Calling bower directly will install them in bower_components.

Common Tasks

Tasks are managed using Grunt. To see a list of tasks run:

grunt --help

Run the Unit Tests

The newer Angular code is unit-tested using karma. The tests are in unit-test-js/tests/rdm.js and the karma configuration in unit-test-js/karma.conf.js. The test can be run with:

grunt unit-test

It does require Firefox and the dependencies to be installed to be able to run the test.

Compress / Uglify

To minifiy the Javascript code, run

grunt compress

This will run jshint which enforces style guidelines and then if jshint passes, runs uglifyjs to compress the javascript code.

If you are continuously editing the source and testing it, you can have grunt automatically perform the compression when the source files change by running

grunt compress-watch

Debugging

If you are having trouble with debugging the minified sources you can copy the files to the static dir (without compression) by using:

grunt copy-once

Again, this will run jshint and the copy the sources over to static/js/

If you want an automatic copy when the files change, use:

grunt copy-watch

Important!

When you are finished debugging, remember to run

grunt copy-cleanup

otherwise the files won't be compressed

Changing app.js

After changing app.js, you have to build the compiled Google Closure script by using:

grunt closure-compiler

Running the App Engine locally

If you want to run the server locally for debugging, download and install the Google Cloud Tools. Then you can start the server locally using:

/path/to/google-cloud-tools/dev_appserver.py /path/to/rdm-app/

On the first run, you are asked to install some additional components for Google Cloud Tools.

You can access the local server at http://localhost:8080/. Logging in at /admin only works with one of the white-listed email addresses. Those are stored in admin.py's BaseAdminPageHandler class.

If you want to add more RDM devices / nodes / etc. for testing, add them to the respective file in the data/ directory.

Deploying to App Engine

Before deploying to App Engine run:

grunt compress

You can then run appcfg.py to deploy.

TODO(someone): Automate this using Grunt.