Skip to content

Commit

Permalink
Merge pull request #132 from flipside-org/feature/public_release
Browse files Browse the repository at this point in the history
Feature/public release
  • Loading branch information
olafveerman committed Jun 19, 2014
2 parents e7d4871 + ab00d99 commit fa80a4c
Show file tree
Hide file tree
Showing 19 changed files with 442 additions and 2,159 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ tests/tmp

#System files
.project
.pydevproject
.DS_Store
.vagrant

# Other
document-it
Expand Down
112 changes: 58 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,62 +7,95 @@ Built using [Codeigniter](http://ellislab.com/codeigniter)

## Team
Daniel da Silva - [Github](https://github.com/danielfdsilva)
Ricardo Mestre - [Github](https://github.com/ricardomestre)
Olaf Veerman - [Github](https://github.com/olafveerman)
Ricardo Mestre - [Github](https://github.com/ricardomestre)
Olaf Veerman - [Github](https://github.com/olafveerman)
Nuno Veloso - [Github](https://github.com/nunoveloso)

___

## Development environment
To ease development, everything was bundled in a vagrant box. To set it up, simply run ```vagrant up``` from the root of the project. For more details about the Vagrant box and useful commands, check out the [instructions in the wiki](https://github.com/flipside-org/aw-datacollection/wiki/Vagrant-box).

If you want to develop locally without using the vagrant box, check the [local development section](https://github.com/flipside-org/aw-datacollection/wiki/Local-development) for the needed dependencies.


### Requirements
These dependencies are needed to build the app no matter whether you use the Vagrant box or manually set up the environment:

- Node & Npm
- Grunt ( $ npm install -g grunt-cli )
- Bower ($ npm install -g bower)
- Sass
- Compass (>= *1.0.0.alpha.19* ```$ sudo gem install compass -v 1.0.0.alpha.19 --pre```)

### Setup
**This is to be done in the local machine, not on vagrant**

After cloning the repository, setup the public files directory and its subfolders at the root of the app:
Initialize and update git submodules:
```
$ mkdir -p files/surveys
$ chmod -R 777 files
$ git submodule update --init --recursive
```
Subsequent updates of git submodules must be done without the ```--init``` flag

Update git submodules (**This should be also done after pulling changes**):
Install airwolf dependencies:
```
$ git submodule update --recursive
$ npm install
```
The enketo library needs to be built. Change into its directory:
```
$ cd assets/libs/enketo-core
$ npm install
$ grunt
$ bower install
```

### Task automation
After these basic requirements are met, run the following commands in the website's folder:
The enketo library needs to be built:
```
$ cd assets/libs/enketo-core
$ npm install
$ grunt --force
```
Patch pyxform library, from the app root folder:
```
$ bower install
$ git apply --directory=application/third_party/pyxform/ pyxform_validate_and_constants.patch
```

Build the CSS and Javascript, from the root folder of the

```
$ grunt build
```
Bower will create a ```bower_components``` directory in the src with all the sass and js needed for foundation. Nothing needs to be done there.
___

You might have to run these as sudo.
## First run
To setup the application go to ```http://your-domain.com/fixtures``` or ```http://192.168.99.10/airwolf/fixtures``` if you're using the vagrant box.

This will give you 2 options to setup the application:
- **Live**
- All the data present in the application will be removed and a user will be added.
- Default credentials: **admin** | admin
- **Development**
- All the data present in the application will be replaced with dummy data.
- This data includes surveys in various statuses and several users.
- Administrator: **admin** | admin
- Moderator: **moderator** | moderator
- Agent: **agent** | agent
- User with all roles: **all_roles** | all_roles

After this setup, change the environment to *production* on ```index.php```
___

## Build automation
Grunt is used for the build automation.

#### Getting started
```
$ grunt
```
Compiles the compass files, javascripts and generates the website.
Compiles the compass files, javascript and generates the website.
The system will watch files and execute tasks whenever one of them changes.

#### Other commands
### Other commands
Clean the compiled sass and javascript:
```
$ grunt clean
```

Compile the compass files, javascripts and generate the website. Use this instead of ```grunt``` if you just want to render it once:
Compile the compass files, javascript and generate the website. Use this instead of ```grunt``` if you just want to render it once:
```
$ grunt build
```
Expand All @@ -71,37 +104,8 @@ Compile the compass files and javascripts prepared for production (minified, ugl
```
$ grunt prod
```

### Running
**Temporary**  
The aw-datacollection app requires mongo.  
Ssh into the vagrant machine and start mongo.
```
$ vagrant ssh
$ mongod
```

## Vagrant machine

### Requirements
- No requirements (Everything needed is installed during bootstrap)

___

## Testing
Testing should be done from within the vagrant machine.

### Code testing

Server side testing is being done with phpunit.
Check the documentation for more.

### Behaviour testing

This is implemented with [CasperJS](http://casperjs.org/) and currently living under `tests/casperjs`.

```
@todo
- integration with grunt
- document usage
```

Testing is done using phpunit. To run the tests you just need to run ```phpunit``` in the app's root folder.
If you're using the Vagrant box environment be sure to do this inside the vagrant machine.
121 changes: 121 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.

# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"

# Base Box url
config.vm.box_url = "http://files.vagrantup.com/precise32.box"

# Hostname.
config.vm.hostname = "legoBrick"

# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
# config.vm.box_url = "http://domain.com/path/to/above.box"

# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network :forwarded_port, guest: 80, host: 8081

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network :private_network, ip: "192.168.99.10"

# Provisioning.
config.vm.provision :shell, :path => "bootstrap.sh"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network :public_network

# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder ".", "/vagrant", owner: "vagrant", group: "www-data",
:mount_options => ['dmode=775', 'fmode=664']

# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
# config.vm.provider :virtualbox do |vb|
# # Don't boot with headless mode
# vb.gui = true
#
# # Use VBoxManage to customize the VM. For example to change memory:
# vb.customize ["modifyvm", :id, "--memory", "1024"]
# end
#
# View the documentation for the provider you're using for more
# information on available options.

# Enable provisioning with Puppet stand alone. Puppet manifests
# are contained in a directory path relative to this Vagrantfile.
# You will need to create the manifests directory and a manifest in
# the file precise32.pp in the manifests_path directory.
#
# An example Puppet manifest to provision the message of the day:
#
# # group { "puppet":
# # ensure => "present",
# # }
# #
# # File { owner => 0, group => 0, mode => 0644 }
# #
# # file { '/etc/motd':
# # content => "Welcome to your Vagrant-built virtual machine!
# # Managed by Puppet.\n"
# # }
#
# config.vm.provision :puppet do |puppet|
# puppet.manifests_path = "manifests"
# puppet.manifest_file = "init.pp"
# end

# Enable provisioning with chef solo, specifying a cookbooks path, roles
# path, and data_bags path (all relative to this Vagrantfile), and adding
# some recipes and/or roles.
#
# config.vm.provision :chef_solo do |chef|
# chef.cookbooks_path = "../my-recipes/cookbooks"
# chef.roles_path = "../my-recipes/roles"
# chef.data_bags_path = "../my-recipes/data_bags"
# chef.add_recipe "mysql"
# chef.add_role "web"
#
# # You may also specify custom JSON attributes:
# chef.json = { :mysql_password => "foo" }
# end

# Enable provisioning with chef server, specifying the chef server URL,
# and the path to the validation key (relative to this Vagrantfile).
#
# The Opscode Platform uses HTTPS. Substitute your organization for
# ORGNAME in the URL and validation key.
#
# If you have your own Chef Server, use the appropriate URL, which may be
# HTTP instead of HTTPS depending on your configuration. Also change the
# validation key to validation.pem.
#
# config.vm.provision :chef_client do |chef|
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
# chef.validation_key_path = "ORGNAME-validator.pem"
# end
#
# If you're using the Opscode platform, your validator client is
# ORGNAME-validator, replacing ORGNAME with your organization name.
#
# If you have your own Chef Server, the default validation client name is
# chef-validator, unless you changed the configuration.
#
# chef.validation_client_name = "ORGNAME-validator"
end
4 changes: 2 additions & 2 deletions application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
| path to your installation.
|
*/
$config['base_url'] = 'http://192.168.99.10/work/aw-datacollection/';
$config['base_url'] = 'http://192.168.99.10/airwolf/';
//$config['base_url'] = '';

/*
Expand Down Expand Up @@ -393,4 +393,4 @@
$config['aw_admin_email'] = '[email protected]';

/* End of file config.php */
/* Location: ./application/config/config.php */
/* Location: ./application/config/config.php */
2 changes: 1 addition & 1 deletion application/config/mongodb.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
$config['default']['persist'] = TRUE;
$config['default']['persist_key'] = 'ci_persist';
$config['default']['replica_set'] = FALSE;
$config['default']['query_safety'] = 'safe';
$config['default']['query_safety'] = 'w';
19 changes: 12 additions & 7 deletions application/controllers/fixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,22 @@ public function index() {
show_error('Not allowed. Only available during development');
}

echo '<h1>Fixtures:<h1>';
echo anchor('fixtures/all', 'Setup fixtures') . '<br/><br/>';
echo anchor('fixtures/live_setup', 'Live (Only admin user is created)');
echo '<h1>Setup:<h1>';
echo anchor('fixtures/all', 'Development') . '<br/><br/>';
echo anchor('fixtures/live_setup', 'Live');
}

/**
* Populate db.
*/
public function all($key = NULL) {
public function all() {
if (ENVIRONMENT != 'development' && ENVIRONMENT != 'demo'){
show_error('Not allowed. Only available during development');
}
else if (ENVIRONMENT == 'demo') {
$demo_key = @file_get_contents('reset.demo.key');
$demo_key = trim(@file_get_contents('reset.demo.key'));

if (!$demo_key || $demo_key != $key) {
if (!$demo_key || $demo_key != $_GET['reset_key']) {
show_error('Wrong or missing key.');
}
}
Expand Down Expand Up @@ -150,7 +150,12 @@ public function all($key = NULL) {
// Indexes.
$this->mongo_db->addIndex('call_tasks', array('ctid' => 'asc'));

redirect('/');
if (ENVIRONMENT == 'development') {
redirect('/');
}
else {
print "Done";
}
}
}

Expand Down
7 changes: 6 additions & 1 deletion application/views/base/html_end.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
</div>
<?php if (ENVIRONMENT == 'demo') : ?>
<p class="ribbon">
<a title="Airwolf on Github" href="https://github.com/flipside-org/">View on GitHub</a>
</p>
<?php endif; ?>
<?php $this->load->view('components/confirm_box') ?>
<?php $this->load->view('base/footer_scripts') ?>
</body>
</html>
</html>
Loading

0 comments on commit fa80a4c

Please sign in to comment.