# QED This document describes how to develop this code base and the source code organisation. ## Development, Install and Deploy Source files are located in `src`. Build and deployment is managed with _Grunt_, a node based task runner. First make sure _node_, _npm_ and _couchdb_ are installed. Then install all dependencies by running `npm install`. To run _grunt_, you'll have to install the commandline client with `npm install -g grunt-cli`. From source to a deployable version goes in few steps. 1. Develop in `src`. 1. Create a development version with `grunt build`. This will put a complete uncompressed version in `build/development`. 1. Run the development version with `node server/standalone.js` or `foreman start`. For the last option, you have to have the Heroku chain installed. 1. When editing more files, you can skip copying the fixed dependencies and only process our own source files by running `grunt compile`. If dependencies change (e.g. you installed node modules) or you have the feeling something is weird, just do a clean build by running `grunt build` again. Don't forget to restart the server. 1. When you feel your changes are production ready, create a production version by running `grunt deploy`. This will do a _Dojo_ build on the client, creating compressed CSS and Javascript. 1. You can test this version with the same commands as the development version, but now from the `build/production` directory. You can distribute the content is this directory as a release. 1. If you want to deploy to Heroku, do the following: ```sh $ git clone git@heroku.com:quod-erat.git build/quod-erat $ cd build/quod-erat $ rm -rf * cp -r ../production/* . git add . git commit -a -m "Something informative goes here..." git push ``` File organisation ----------------- * _/_ Project root * _build/_ Builds go here * _development/_ Uncompressed build * _production/_ Minified build * _docs/_ Project documentation, design documents etc * _src/_ Source code * _client/_ Dojo web client * _server/_ Node/Express server * _Procfile_ Heroku process description ``` client/ The web application for QED. routes.js Contains the mapping from URLs to pages. run.js The script for starting the web application (the researchers part). stddeps.js Contains many dependencies that are used declarativly in the templates. Maybe it can be deprecated with Dojo 1.8+'s auto require if the build scans templates as well. store.js Module that returns a fully configured store for the rest of the application to use for database access. Handles caching and exposes some common serialization functions. view.js Script that starts the survey part (the respondent part). data/ Apache proxy configuration for transparant access to CouchDB. dijit/ Dijit library (UI components) dojo/ Dojo library (Dojo JS framework) dojox/ DojoX library (contrib library for Dojo and Dijit) qed/ Sourcecode of the QED application app/ Small app framework for handling pages, content, notifications and URL history. Our application is build on this. css/ Contains all CSS of the application. Should be distributed better with the widgets. The styling is based on LESS, although a copy of the CSS is still there. model/ Contains all code dependent on our model, that is, the concrete representation of our database documents. classes/ Smart classes on top of the database documents, to help with creating and validating objects. widgets/ All widgets that are specific for objects of our model. pages/ The pages in the application. Are wired up to URLs in the routes.js file. store/ Dojo Store implementations for Couch and Elastic. ui/ Deprecated. Used to contain all widgets, but these are now split between general and model specific widgets. Contains a few widgets that were not yet refactored. widgets/ Contains general widgets that are used in our application but do not depend on our model. util/ Dojo utils (e.g. build infrastructure) ```