diff --git a/.gitignore b/.gitignore index 6193f74..9251fe0 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,9 @@ tests/tmp #System files .project +.pydevproject .DS_Store +.vagrant # Other document-it diff --git a/README.md b/README.md index 118b0ca..7f52ab2 100644 --- a/README.md +++ b/README.md @@ -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 ``` @@ -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. \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..4255e36 --- /dev/null +++ b/Vagrantfile @@ -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 diff --git a/application/config/config.php b/application/config/config.php index 7fc0ed3..c80f3a4 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -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'] = ''; /* @@ -393,4 +393,4 @@ $config['aw_admin_email'] = 'aw-datacollection@airwolf.edispilf.org'; /* End of file config.php */ -/* Location: ./application/config/config.php */ \ No newline at end of file +/* Location: ./application/config/config.php */ diff --git a/application/config/mongodb.php b/application/config/mongodb.php index 87c71fc..20debae 100644 --- a/application/config/mongodb.php +++ b/application/config/mongodb.php @@ -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'; diff --git a/application/controllers/fixtures.php b/application/controllers/fixtures.php index f14e6a6..ac2d870 100644 --- a/application/controllers/fixtures.php +++ b/application/controllers/fixtures.php @@ -107,22 +107,22 @@ public function index() { show_error('Not allowed. Only available during development'); } - echo '
+ View on GitHub +
+ load->view('components/confirm_box') ?> load->view('base/footer_scripts') ?>