Commit 51132bc1 by Pablo Molina

Merge branch 'issue/363' into 'master'

Issue/363
parents c02ecc5e 6be3ab4e
Showing with 280 additions and 519 deletions
deny from all
Este proyecto contiene el código de Pictogram, que se divide en tres:
* sails: API REST del servidor (sails.js)
* angular: Aplicación web con el dashboard para supervisores (Angular.js)
* android: aplicación para tablet para estudiantes
\ No newline at end of file
- [Servidor](sails): API REST del servidor
- [Cliente web](sails/src/assets/app): aplicación web con el dashboard para supervisores
- [Cliente android](android/Pictogram): aplicación android para tablet para estudiantes
info: Starting app...
warn: Cannot read package.json in the current directory (/home/dofer/pictogram)
warn: Are you sure this is a Sails app?
warn: 
warn: The package.json in the current directory does not list Sails as a dependency...
warn: Are you sure `/home/dofer/pictogram` is a Sails app?
warn: 
info: 
info:  .-..-.
info: 
info:  Sails <| .-..-.
info:  v0.11.3 |\
info:  /|.\
info:  / || \
info:  ,' |' \
info:  .-'.-==|/_--'
info:  `--'-------'
info:  __---___--___---___--___---___--___
info:  ____---___--___---___--___---___--___-__
info: 
info: Server lifted in `/home/dofer/pictogram`
info: To see your app, visit http://localhost:1337
info: To shut down Sails, press <CTRL> + C at any time.

debug: --------------------------------------------------------
debug: :: Tue Dec 22 2015 21:34:51 GMT+0100 (CET)

debug: Environment : development
debug: Port : 1337
debug: --------------------------------------------------------
error: 
------------------------------------------------------------------------
grunt-cli: The grunt command line interface. (v0.1.13)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:
http://gruntjs.com/getting-started
------------------------------------------------------------------------

error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.

error: Troubleshooting tips:
error: 
error:  *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error: 
error:  *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error: 
error:  *-> Or maybe you don't have permissions to access the `.tmp` directory?
error:  e.g., `/home/dofer/pictogram/.tmp` ?
error: 
error:  If you think this might be the case, try running:
error:  sudo chown -R 1001 /home/dofer/pictogram/.tmp

# INSTALL
---
## Instalación previa
Instalar nodejs
```
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
```
(Sólo en Debian) Crear link simbólico por conflicto de nombre con el paquete para utilizar nodejs en lugar de node
```
sudo ln -s /usr/bin/nodejs /usr/bin/node
```
Instalar sails
```
sudo npm -g install sails
```
Fuente: http://sailsjs.org/#/getStarted
## Descarga y configuración del proyecto
Descarga del proyecto
```
git clone http://scm.ujaen.es/softuno/pictogram.git
```
Acceder a la carpeta `src` del proyecto e instalar las dependencias definidas en `package.json`
```
npm install
```
Descomprimir el archivo de pictogramas /pictogram/sails/conf/symbolstx.rar en /pictogram/sails
```
rar x symbolstx.rar
```
En carpeta `src` del proyecto levantar sails (comprobar en localhost:1337)
```
sails lift
```
O bien en modo consola para hacer pruebas (engloba a sails lift)
```
sails console
```
De las opciones que aparecen a continuación, seleccionar en producción `1. safe` o en desarrollo `2. alter`. Esta última reconstruye la BDD según los modelos definidos en sails sin eliminar la información que tuviera previamente.
```
1. safe - never auto-migrate my database(s). I will do it myself (by hand)
2. alter - auto-migrate, but attempt to keep my existing data (experimental)
3. drop - wipe/drop ALL my data and rebuild models every time I lift Sails
```
# Servidor de Pictogram e instalación del cliente web
En este directorio se encuentra el servidor web ([src](./src)) y la aplicación
web ([src/assets/app](./src/assets/app)). Los distintos ficheros de configuración
utilizados para la inicialización y el testeo de la aplicación se encuentran
en el directorio [conf](./conf).
## Dependencias
- Ubuntu >= 14.04
- Nodejs >= 0.10.37
- Npm >= 3.8.5
- Bower >= 1.4.1
## Instalación del servidor y el cliente web
- Ejecutar el script [install.sh](./install.sh) para instalar todas las
dependencias del servidor y el cliente web.
- Acceder al directorio [conf](./conf) para la instalación de la base de datos.
> **Importante**: el script utilizado creará un entorno para el servidor desde
> cero, por lo que **pueden perderse los datos** almacenados por usuarios.
## Desarrollo y pruebas
Para ejecutar el servidor como desarrollo se debe acceder al directorio
[conf](./conf) e instalar los datos de la base de datos necesarios.
## Ejecución
Para lanzar el servidor hay que acceder al directorio [src](./src) y ejecutar
uno de esos comandos:
- `sails lift`: para un servidor corriente
- `sails console`: para un servidor con un intérprete de nodejs con las
variables de sails expuestas
> El servidor se ejecutará en [localhost:1337/app](http://localhost:1337/app)
# Order of imports
# Configuración de la base de datos
* `pictodb.sql` contains the SQL statements to create the schema of the database
* `pictodb-data.sql` contains first data load with basic information for the application to work
* `pictodb-test.sql` contains test data to be loaded in order to test the application in development
## Scripts
A script called `installdb.sh` will empty existing database and generate the new one and import the data, leaving you with a fresh database for development.
- [installdb.sh](./installdb.sh) elimina la base de datos existente y realiza
una instalación limpia para producción.
- [installdb-tests.sh](./installdb-test.sh) realiza el mismo proceso
que [installdb.sh](./installdb.sh) pero añadiendo los datos de tests.
- [installdb-autismojaen.sh](./installdb-autismojaen.sh) realiza el mismo
proceso que [installdb.sh](./installdb.sh), pero añadiendo los datos de
autismojaen.
# Notes
> **Importante**: para no añadir la biblioteca de symbolstix de nuevo
> y conservarla en el caso de que ya esté en la base de datos se puede
> añadir la opción `--ignore-symbolstix` a todos los scripts (por ejemplo
> `installdb.sh --ignore-symbolstix` no importará estos datos).
## Importing data
To import `pictodb-data.sql` into MySQL without foreign key constraints, ensure that the imported file starts with `SET foreign_key_checks=0;` and then you turn on it again with `SET foreign_key_checks=1;`
## Orden de la importación
### Datos necesarios
- [init.sql](./pictodb-init.sql) inicializa el usuario y permisos de la base de
datos.
- _[init-ignoresymbolstix.sql](./sql/init-ignoresymbolstix.sql) realiza el mismo
proceso que [init.sql](./sql/init.sql), pero ignorando a symbolstix._
- [pictodb-schema.sql](./sql/pictodb-schema.sql) contiene el esquema de la base de
datos.
- _[symbolstix-categories.sql](./sql/symbolstix-categories.sql) añade las
categorías de symbolstix._
- _[symbolstix-metadata.sql](./sql/symbolstix-metadata.sql) añade los
metadatos de symbolstix._
- [pictodb-data.sql](./sql/pictodb-data.sql) contiene la información básica que
la aplicación necesita para funcionar.
- [triggers-enrolments-integrity-constraints.sql](./pictodb-triggers-enrolments-integrity-constraints.sql)
añade disparadores para el control de integridad de inscripciones.
- [triggers-sessions-integrity-constraints.sql](./pictodb-triggers-enrolments-integrity-constraints.sql)
añade disparadores para el control de integridad de sesiones.
### Añadido de datos de desarrollo y pruebas
- [test.sql](./sql/test-autismojaen.sql) contiene datos para el desarrollo y
pruebas de la aplicación.
- [test-autismojaen.sql](./sql/test-autismojaen.sql) añade los datos de
autismojaen.
## Notes
### Importación de datos
To import `pictodb-data.sql` into MySQL without foreign key constraints, ensure
that the imported file starts with `SET foreign_key_checks=0;` and then you turn
on it again with `SET foreign_key_checks=1;`
### Eliminando la base de datos completa
## Droping all tables
```sql
SET foreign_key_checks=0;
DROP TABLE `action`, `device`, `enrolment`, `instruction`, `license`, `license_activation`, `meta_picto`, `meta_stu`, `method`, `office`, `official_dev`, `picto`, `picto_acl`, `picto_core`, `picto_core_cat`, `picto_exp`, `picto_tag`, `picto_tag_sup`, `source`, `student`, `stu_picto`, `stu_sup`, `stu_sup_dev`, `supervisor`, `try`, `working_session`;
DROP TABLE `action`, `device`, `enrolment`, `instruction`, `license`,
`license_activation`, `meta_picto`, `meta_stu`, `method`, `office`,
`official_dev`, `picto`, `picto_acl`, `picto_core`, `picto_core_cat`,
`picto_exp`, `picto_tag`, `picto_tag_sup`, `source`, `student`, `stu_picto`,
`stu_sup`, `stu_sup_dev`, `supervisor`, `try`, `working_session`;
SET foreign_key_checks=1;
```
\ No newline at end of file
```
#!/bin/bash
echo "SET foreign_key_checks=0;
TRUNCATE TABLE action;
TRUNCATE TABLE device;
TRUNCATE TABLE instruction;
TRUNCATE TABLE method;
TRUNCATE TABLE office;
TRUNCATE TABLE official_dev;
TRUNCATE TABLE picto_acl;
TRUNCATE TABLE picto_tag_sup;
TRUNCATE TABLE student;
TRUNCATE TABLE stu_dev;
TRUNCATE TABLE stu_picto;
TRUNCATE TABLE stu_sup;
TRUNCATE TABLE supervisor;
TRUNCATE TABLE try;
TRUNCATE TABLE working_session;
TRUNCATE TABLE meta_method;
TRUNCATE TABLE meta_picto;
TRUNCATE TABLE meta_stu;
TRUNCATE TABLE meta_instruction;
TRUNCATE TABLE source;
TRUNCATE picto_core_cat;
SET foreign_key_checks=1;" | mysql -u pictodbuser -pp1KT015 pictodb
#!/bin/bash
ROOT_PASSWD=passwd
IGNORE_SYMBOLSTIX=false
USAGE="Usage: ${0##*/} <mysql root pwd> [--ignore-symbolstix]"
DBUSER=pictodbuser
DBNAME=pictodb
function do_exit {
echo $USAGE
exit 1
}
function execute_db {
echo $1
mysql -u $DBUSER -pp1KT015 $DBNAME < $1
}
function main {
if [ $# -eq 0 ]; then do_exit; fi
if [ $# -gt 2 ]; then do_exit; fi
if [ $# -eq 1 ]; then ROOT_PASSWD=$1; fi
if [ $# -eq 2 ]; then
if [ $2 != '--ignore-symbolstix' ]; then do_exit; fi
ROOT_PASSWD=$1
IGNORE_SYMBOLSTIX=true
fi
if [ $IGNORE_SYMBOLSTIX == true ]; then
echo Init ignoring symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init-ignoresymbolstix.sql
else
echo Init with symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init.sql
fi
execute_db ./sql/pictodb-schema.sql
if [ $IGNORE_SYMBOLSTIX == false ]; then
execute_db ./sql/symbolstix-categories.sql
execute_db ./sql/symbolstix-metadata.sql
fi
execute_db ./sql/pictodb-data.sql
execute_db ./sql/test-autismojaen.sql
execute_db ./sql/triggers-enrolments-integrity-constraints.sql
execute_db ./sql/triggers-sessions-integrity-constraints.sql
}
main "$@"
#!/bin/bash
ROOT_PASSWD=passwdd
IGNORE_SYMBOLSTIX=false
USAGE="Usage: ${0##*/} <mysql root pwd> [--ignore-symbolstix]"
DBUSER=pictodbuser
DBNAME=pictodb
function do_exit {
echo $USAGE
exit 1
}
function execute_db {
echo $1
mysql -u $DBUSER -pp1KT015 $DBNAME < $1
}
function main {
if [ $# -eq 0 ]; then do_exit; fi
if [ $# -gt 2 ]; then do_exit; fi
if [ $# -eq 1 ]; then ROOT_PASSWD=$1; fi
if [ $# -eq 2 ]; then
if [ $2 != '--ignore-symbolstix' ]; then do_exit; fi
ROOT_PASSWD=$1
IGNORE_SYMBOLSTIX=true
fi
if [ $IGNORE_SYMBOLSTIX == true ]; then
echo Init ignoring symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init-ignoresymbolstix.sql
else
echo Init with symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init.sql
fi
execute_db ./sql/pictodb-schema.sql
if [ $IGNORE_SYMBOLSTIX == false ]; then
execute_db ./sql/symbolstix-categories.sql
execute_db ./sql/symbolstix-metadata.sql
fi
execute_db ./sql/pictodb-data.sql
execute_db ./sql/test.sql
execute_db ./sql/triggers-enrolments-integrity-constraints.sql
execute_db ./sql/triggers-sessions-integrity-constraints.sql
}
main "$@"
#!/bin/bash
echo "SET foreign_key_checks=0;
DROP TABLE action, catexp, device, instruction, meta_instruction, meta_method,
meta_picto, meta_stu, method, office, official_dev, picto, pictocat, picto_acl, picto_core,
picto_core_cat, picto_exp, picto_tag, picto_tag_sup, source, student, stu_dev, stu_picto,
stu_sup, supervisor, try, working_session;
SET foreign_key_checks=1;" | mysql -u pictodbuser -pp1KT015 pictodb
mysql -u pictodbuser -pp1KT015 pictodb < pictodb.sql
mysql -u pictodbuser -pp1KT015 pictodb < pictodb-data.sql
mysql -u pictodbuser -pp1KT015 pictodb < pictodb-test.sql
mysql -u pictodbuser -pp1KT015 pictodb < pictodb-autismojaen.sql
# picto, picto_exp and picto_tag
mysql -u pictodbuser -pp1KT015 pictodb < symbolmetadata.sql
# pictocat and catexp
mysql -u pictodbuser -pp1KT015 pictodb < symbolcat.sql
# Triggers for enrolments (office licenses)
mysql -u pictodbuser -pp1KT015 pictodb < pictodb_enrolments_integrity_constraints.sql
# Triggers and procedures for sessions
mysql -u pictodbuser -pp1KT015 pictodb < pictodb_sessions_integrity_constraints.sql
\ No newline at end of file
ROOT_PASSWD=passwd
IGNORE_SYMBOLSTIX=false
USAGE="Usage: ${0##*/} <mysql root pwd> [--ignore-symbolstix]"
DBUSER=pictodbuser
DBNAME=pictodb
function do_exit {
echo $USAGE
exit 1
}
function execute_db {
echo $1
mysql -u $DBUSER -pp1KT015 $DBNAME < $1
}
function main {
if [ $# -eq 0 ]; then do_exit; fi
if [ $# -gt 2 ]; then do_exit; fi
if [ $# -eq 1 ]; then ROOT_PASSWD=$1; fi
if [ $# -eq 2 ]; then
if [ $2 != '--ignore-symbolstix' ]; then do_exit; fi
ROOT_PASSWD=$1
IGNORE_SYMBOLSTIX=true
fi
if [ $IGNORE_SYMBOLSTIX == true ]; then
echo Init ignoring symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init-ignoresymbolstix.sql
else
echo Init with symbolstix
mysql -u root -p$ROOT_PASSWD < ./sql/init.sql
fi
execute_db ./sql/pictodb-schema.sql
if [ $IGNORE_SYMBOLSTIX == false ]; then
execute_db ./sql/symbolstix-categories.sql
execute_db ./sql/symbolstix-metadata.sql
fi
execute_db ./sql/pictodb-data.sql
execute_db ./sql/triggers-enrolments-integrity-constraints.sql
execute_db ./sql/triggers-sessions-integrity-constraints.sql
}
main "$@"
set MYSQL=C:\wamp\bin\mysql\mysql5.6.17\bin\mysql.exe
echo Drop previous database
%MYSQL% -u root < pictodb_init.sql
echo Create schema
%MYSQL% -u pictodbuser -pp1KT015 pictodb < pictodb.sql
echo Insert data
%MYSQL% -u pictodbuser -pp1KT015 pictodb < pictodb-data.sql
%MYSQL% -u pictodbuser -pp1KT015 pictodb < pictodb-test-caja.sql
echo Insert symbols
%MYSQL% -u pictodbuser -pp1KT015 pictodb < symbolmetadata.sql
echo Insert cats
%MYSQL% -u pictodbuser -pp1KT015 pictodb < symbolcat.sql
echo Create constraints
%MYSQL% -u pictodbuser -pp1KT015 pictodb < pictodb_enrolments_integrity_constraints.sql
%MYSQL% -u pictodbuser -pp1KT015 pictodb < pictodb_sessions_integrity_constraints.sql
echo End
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage: ${0##*/} <mysql root pwd>"
exit 1
fi
echo Drop previous database
mysql -u root -p$1 < pictodb_init.sql
echo Create schema
mysql -u pictodbuser -pp1KT015 pictodb < pictodb.sql
# picto, picto_exp and picto_tag
echo Insert symbols
mysql -u pictodbuser -pp1KT015 pictodb < symbolmetadata.sql
# pictocat and catexp
echo Insert cats
mysql -u pictodbuser -pp1KT015 pictodb < symbolcat.sql
echo Insert data
mysql -u pictodbuser -pp1KT015 pictodb < pictodb-data.sql
mysql -u pictodbuser -pp1KT015 pictodb < pictodb-test-caja.sql
echo Create constraints
# Triggers for enrolments (office licenses)
mysql -u pictodbuser -pp1KT015 pictodb < pictodb_enrolments_integrity_constraints.sql
# Triggers and procedures for sessions
mysql -u pictodbuser -pp1KT015 pictodb < pictodb_sessions_integrity_constraints.sql
echo End
#!/bin/bash
if [ $# -eq 0 ]
then
echo "Usage: ${0##*/} <mysql root pwd>"
exit 1
fi
echo Drop previous database
mysql -u root -p$1 < pictodb_init_keepsymbolstix.sql
echo Create schema
mysql -u pictodbuser -pp1KT015 pictodb < pictodb.sql
echo Insert data
mysql -u pictodbuser -pp1KT015 pictodb < pictodb-data.sql
mysql -u pictodbuser -pp1KT015 pictodb < pictodb-test-caja.sql
echo Create constraints
# Triggers for enrolments (office licenses)
mysql -u pictodbuser -pp1KT015 pictodb < pictodb_enrolments_integrity_constraints.sql
# Triggers and procedures for sessions
mysql -u pictodbuser -pp1KT015 pictodb < pictodb_sessions_integrity_constraints.sql
echo End
DROP TABLE stu_opentry;
DROP PROCEDURE newTry;
DROP TRIGGER TRG_TRY_EVALUATED;
DROP TRIGGER TRG_NEW_EVENT;
DROP TRIGGER TRG_SESSION_NEW;
DELIMITER ;;
CREATE TABLE stu_opentry (
id int NOT NULL AUTO_INCREMENT,
id_stu int NOT NULL,
id_sup int NOT NULL,
id_ws int NOT NULL,
id_opentry int ,
total_tries int DEFAULT 0,
begin timestamp NULL,
end timestamp NULL,
PRIMARY KEY(id),
UNIQUE(id_stu),
UNIQUE(id_sup),
UNIQUE(id_ws),
FOREIGN KEY (id_stu) REFERENCES student,
FOREIGN KEY (id_opentry) REFERENCES try,
INDEX USING HASH (id_stu),
INDEX USING HASH (id_ws)
) ENGINE=MEMORY;;
CREATE PROCEDURE newTry(idstu INT, idsup INT, idws INT)
MODIFIES SQL DATA
BEGIN
DECLARE idopentry int;
INSERT INTO try(`id_ws`)
VALUES (idws);
SET idopentry=LAST_INSERT_ID();
INSERT INTO stu_opentry(id_stu,id_sup,id_ws,id_opentry, total_tries,begin)
VALUES (
idstu,
idsup,
idws,
idopentry,
0,
NOW()
)
ON DUPLICATE KEY UPDATE id_stu=idstu, id_sup=idsup, id_ws=idws, id_opentry=idopentry;
END;;
CREATE TRIGGER TRG_TRY_EVALUATED
AFTER UPDATE ON try
FOR EACH ROW
BEGIN
DECLARE idopentry INT;
DECLARE idws INT;
DECLARE ws_end DATE;
IF ( (old.result IS NULL) and (new.result IS NOT NULL) and (new.end>ws_end)) THEN
SELECT id_ws, id_opentry,end INTO idws, idopentry, ws_end
FROM
stu_opentry
WHERE
id_ws = NEW.id_ws;
UPDATE stu_opentry
SET end=new.end, total_tries=total_tries+1
WHERE id_ws=idws;
END IF;
END;;
CREATE TRIGGER TRG_NEW_EVENT
AFTER INSERT ON action
FOR EACH ROW
BEGIN
DECLARE idopentry INT;
DECLARE idsup_ws INT;
DECLARE idws INT;
CASE NEW.type
WHEN 'Show' THEN
SELECT id_ws, id_sup, id_opentry INTO idws, idsup_ws, idopentry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
IF (idopentry IS NOT NULL and NEW.id_sup IS NULL) THEN
UPDATE `try`
SET end=NOW()
WHERE id=idopentry;
call newTry(new.id_stu, idsup_ws, idws);
END IF;
WHEN 'Pause' THEN
SELECT id_ws, id_opentry INTO idws, idopentry
FROM
stu_opentry
WHERE
id_stu = NEW.id_stu;
IF (idopentry IS NULL) THEN
call newTry(new.id_stu, new.id_sup,idws);
ELSE
call deleteOpenTry(idws);
END IF;
ELSE BEGIN END;
END CASE;
END;;
CREATE TRIGGER TRG_SESSION_NEW
AFTER INSERT ON working_session
FOR EACH ROW
BEGIN
DECLARE idstu INT;
SELECT DISTINCT M.id_stu INTO idstu
FROM
instruction I,
method M
WHERE
I.id=new.id_ins AND
I.id_met=M.id;
UPDATE instruction
SET status='started'
WHERE id=new.id_ins;
CALL newTry(idstu, new.id_sup, new.id);
END;;
DELIMITER ;

87.8 KB | W: | H:

87.8 KB | W: | H:

sails/conf/EC.png
sails/doc/EC.png
sails/conf/EC.png
sails/doc/EC.png
  • 2-up
  • Swipe
  • Onion skin
# Nodejs install
sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install -y nodejs
sudo npm install -g npm
# Sails install
sudo npm install -g sails
# Sails log file
mkdir -p ./src/logs
touch ./src/logs/my_log_file.log
# Server dependencies installation
cd ./src && npm install
# Copy sails.io.js
cd /tmp && \
rm -rf sailstempapp && \
sails new sailstempapp &&
cp /tmp/sailstempapp/assets/js/dependecies/sails.io.js ./src/assets/app/js/lib/sails.io.js
rm -rf /tmp/sailstempapp
# Link configuration file
ln ./conf/js/config.js ./src/assets/app/js/config.js
ln ./conf/js/local.js ./src/assets/app/js/local.js
# Client dependencies installation
sudo npm install -g bower
cd ./src/assets/app && bower install
/**
* Gruntfile
*
* This Node script is executed when you run `grunt` or `sails lift`.
* It's purpose is to load the Grunt tasks in your project's `tasks`
* folder, and allow you to add and remove tasks as you see fit.
* For more information on how this works, check out the `README.md`
* file that was generated in your `tasks` folder.
*
* WARNING:
* Unless you know what you're doing, you shouldn't change this file.
* Check out the `tasks` directory instead.
*/
module.exports = function(grunt) {
// Load the include-all library in order to require all of our grunt
// configurations and task registrations dynamically.
var includeAll;
try {
includeAll = require('include-all');
} catch (e0) {
try {
includeAll = require('sails/node_modules/include-all');
}
catch(e1) {
console.error('Could not find `include-all` module.');
console.error('Skipping grunt tasks...');
console.error('To fix this, please run:');
console.error('npm install include-all --save`');
console.error();
grunt.registerTask('default', []);
return;
}
}
/**
* Loads Grunt configuration modules from the specified
* relative path. These modules should export a function
* that, when run, should either load/configure or register
* a Grunt task.
*/
function loadTasks(relPath) {
return includeAll({
dirname: require('path').resolve(__dirname, relPath),
filter: /(.+)\.js$/
}) || {};
}
/**
* Invokes the function from a Grunt configuration module with
* a single argument - the `grunt` object.
*/
function invokeConfigFn(tasks) {
for (var taskName in tasks) {
if (tasks.hasOwnProperty(taskName)) {
tasks[taskName](grunt);
}
}
}
// Load task functions
var taskConfigurations = loadTasks('./tasks/config'),
registerDefinitions = loadTasks('./tasks/register');
// (ensure that a default task exists)
if (!registerDefinitions.default) {
registerDefinitions.default = function (grunt) { grunt.registerTask('default', []); };
}
// Run task functions to configure Grunt.
invokeConfigFn(taskConfigurations);
invokeConfigFn(registerDefinitions);
};
......@@ -33,5 +33,8 @@
"url": "http://scm.ujaen.es/softuno/pictogram.git"
},
"author": "emblanco, amontejo",
"license": ""
"license": "",
"devDependencies": {
"node-inspector": "^0.12.8"
}
}
{
"name": "sails_demo",
"private": true,
"version": "0.0.0",
"description": "a Sails application",
"keywords": [],
"dependencies": {
"sails": "~0.10.5",
"sails-disk": "~0.10.0",
"rc": "~0.5.0",
"include-all": "~0.1.3",
"ejs": "~0.8.4",
"grunt": "0.4.2",
"grunt-sync": "~0.0.4",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-sails-linker": "~0.9.5",
"grunt-contrib-jst": "~0.6.0",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-uglify": "~0.4.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-less": "0.11.1",
"grunt-contrib-coffee": "~0.10.1",
"jsonwebtoken": "~0.4.0",
"bcrypt": "~0.7.8"
},
"scripts": {
"start": "node app.js",
"debug": "node debug app.js"
},
"main": "app.js",
"repository": {
"type": "git",
"url": "git://github.com/emblanco/sails_demo.git"
},
"author": "emblanco",
"license": ""
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment