Skip to content

naeka/vosae-web

Repository files navigation

Vosae web client

This is the Vosae webapp.
It requires the Vosae app backend, available on Github repo naeka/vosae-app.


Branch Travis-CI build status
master (ready for production) Build Status
develop Build Status

The Vosae Web client is powered by the amazing javascript framework Ember.js and its data persistence library Ember-data.

You need Python 2.7. It should be on your system if you have a modern operating system.

Install the application

First, clone the repository:

$ git clone git@github.com:Naeka/vosae-web.git
$ cd vosae-web/

Build the virtualenv

Using virtualenvwrapper - recommanded:

$ mkvirtualenv vosae-web

Or simply with the virtualenv tool:

$ virtualenv --python=python2.7 --distribute ./
$ source bin/activate

Install Python requirements in the virtualenv:

(vosae-web)$ pip install -r requirements.txt

Manage static files

The Vosae Web client handles static files with Grunt.

You need both Node.js and Node Package Manager (npm) installed on your system.
If Node isn't on your system, install it now!

First, install grunt dependencies on your system:

$ gem install sass --version 3.2.14
$ gem install compass --minimal-deps
$ gem install sass-rails
$ gem install bootstrap-sass --version 3.1.0.1
$ gem install --pre sass-css-importer

$ npm install -g grunt-cli
$ npm install

Now you can generate static files

Build files for dev and watch directories for changes

$ grunt

Launch the dev server

Settings

Prior to launch the server, an app endpoint (auth, api) settings must be defined. The VOSAE_APP_ENDPOINT environment variable is used for this purpose.

For development, it can be more convenient to set this in a local settings file (not tracked by Git).
In this case, create a local.py file in the settings module and fill with:

Warning: Do not add a trailing shash to the endpoint

# -*- coding:Utf-8 -*-

APP_ENDPOINT = 'http://localhost:8000'

The development SQLite database must also be common to both vosae-app and vosae-web.
This one is by default located (but not tracked) in the vosae-app/www directory.
By default, vosae-web assume that it is at the same level of vosae-app on your filesystem and should work out of the box.
If not, you can set the path to your SQLite file in the VOSAE_SQLITE_DATABASE environment variable.

Ensure that the virtualenv is activated:

vosae-web should be in your command prompt, $PS1 is updated by virtualenv

Otherwise, activate it using virtualenvwrapper:

$ workon vosae-web

Or classic virtualenv:

$ cd vosae-web
$ source bin/activate

Run the dev server:

(vosae-web)$ cd vosae-web/www/    
(vosae-web)$ ./manage.py runserver 8001  # Web is run on port 8001 for development
You can now open http://localhost:8001

Notes about translation files

Internationalization is handled by django and gettext for both internationalized strings in templates (django domain) or javascripts (djangojs domain).
For the javascript part, the makemessages management command only parses .js files so that it is necessary to compile .coffee files first with grunt (either grunt or grunt build-dev if watching is not necessary).

Because of performance issues, the javascript_catalog view is not used, in profit of the django-statici18n app.
Thus, language files can be bundled with static files. Unfortunaletly, these generated static files are conflictual and should be ignored by makemessages.
This is achieved with this command from the webapp app:

(vosae-web)$ python ../manage.py makemessages -a -d djangojs -i "*djangojs.js" -i "*locale-*.js"

How to Run Unit Tests

All the tests are written with Qunit.

Setup

Build all tests with grunt build-spec

In your browser

Launch the dev server and open the url http://localhost:8001/spec/

From the CLI

Run all tests with grunt run-spec

Feature branches naming

Feature branches are branches used when developing a specific feature. It is used thanks to gitflow.

To install gitflow, follow gitflow instructions.

Code conventions

Django

  • Use of SPACES for indentation - 4-spaces equivalency
  • Class definitions and top methods separated by 2 blank lines, methods inside a class separated by 1 blank line
  • No maximum line length but try to be clear and align on multiple lines
  • Avoid parentheses use when possible for conditional and loop statements

Templates

  • Use of SPACES for indentation - 2-spaces equivalency

CoffeeScript

  • Use of SPACES for indentation - 2-spaces equivalency
  • Use simple quotes for strings, array keys, ...
  • No spaces before parentheses and brackets, carrier return for statements
  • No maximum line length but try to be clear and align on multiple lines
  • Functions must be camelCased