Skip to content

Information for Developers

James Errington edited this page Jun 22, 2017 · 3 revisions

Contents

  1. Using Grunt
  2. Debugging and Testing
  3. File Formats

Grunt

grunt.js is used to build releases and to install rg2 on the routegadget.co.uk sites. It would make sense to install node.js first so that you can install things via npm. Then install Grunt.

npm install

Run npm install from a shell in the top-level directory. This should install all the necessary packages to allow you to build rg2.

Gruntfile.js

Grunt tasks are defined in Gruntfile.js in the top-level directory. If you look at the end of the file you will find the various tasks required to build rg2. The earlier part of the file defines and configures the various tasks.

grunt build (the default grunt task)

Runs csshint, jslint and jshint to find code problems. Then generates minified css and js files, plus the associated maps for debugging. The end result is rg2-x.y.z.min.js, rg2manager-x.y.z.min.js and rg2-x.y.x.min.css which are the core files loaded by index.php.

grunt bump

Used to increment the version number in package.json (or this can be done manually). Only really relevant when building a new release for the master branch. This version number is reported on the information dialog.

grunt deploy

Used to create a formal release (for Github) and to copy the relevant to temporary release directories locally for upload to the routegadget.co.uk site.

Debug

Adding a debug query (?debug) to the call to rg2 will download the uncompressed .js files rather than rg2-x-y-z.min.js. This originally made debugging easier on live sites, but the maps now sort that out. It is retained to avoid having to build everything after every change in the local test environment. Yes, I know Webpack would do that, and one day it will get closer to the top of the list of things to do.

The debug setting is also activated if you are using an rg2-override-config.php file.

example: http://www.happyherts.routegadget.co.uk/rg2?debug

Touch interface

After testing a number of possible touch interface solutions it turned out that a simple home-grown solution worked best. Therefore the touch interface does not include any libraries. This might change when jquery-ui adds support for touch, which is meant to happen somewhen.

Testing

See the RG2 Protractor test set-up