diff --git a/.gitignore b/.gitignore index 4220ff7..c369af1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ _site node_modules .DS_Store -.idea \ No newline at end of file +.idea +results.json \ No newline at end of file diff --git a/README.md b/README.md index 855652c..5ab1229 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,10 @@ A gesture training application is available online at [http://uwdata.github.io/g The application is intended to work with both mouse and touch input. The code for the training application is included in this repository under the `trainer` folder. Simply open the `index.html` file in a browser to run locally. +You can use provided `express.js` node script to spawn a webserver that starts the trainer and give you access to a POST method which records the results into a `results.json` file at root of this repo. +This is useful if you intend to produce tablet / mobile gesture. +If you append a `GET` parameter `bg` to the url, targeting an image, it will display it under the `designer` zone to give you some help. + ## Build Process We use the [gulp](http://gulpjs.com/) build system along with [browserify](http://browserify.org/) to build gestrec.min.js. diff --git a/express.js b/express.js new file mode 100644 index 0000000..541951c --- /dev/null +++ b/express.js @@ -0,0 +1,27 @@ +var express = require('express') +var bodyParser = require('body-parser') +var morgan = require('morgan') + +console.log('---------------') +console.log('\tGestRec Trainer') +console.log('') +console.log('\tYou can browse : http://127.0.0.1:8080/') +console.log('---------------') +console.log('') + +var app = express() +app.use(morgan()) + +var urlencodedParser = bodyParser.urlencoded({ extended: false, limit: '50mb' }) +app.get('/gestrec.min.js', urlencodedParser, function (req, res) { + require('fs').createReadStream('gestrec.min.js').pipe(res) +}) + +app.post('/data', urlencodedParser, function (req, res) { + require('fs').writeFileSync('results.json', JSON.stringify(JSON.parse(req.body.train), null, 2)) + res.send(200) +}) + +app.use(express.static('trainer')); + +app.listen(8080); diff --git a/package.json b/package.json index 2677354..48f7550 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,10 @@ "gulp-rename": "^1.2.2", "gulp-uglify": "^1.2.0", "vinyl-buffer": "^1.0.0", - "vinyl-source-stream": "^1.1.0" + "vinyl-source-stream": "^1.1.0", + "body-parser": "^1.13.2", + "express": "^4.13.1", + "morgan": "^1.6.1" }, "main": "src/index.js" } diff --git a/trainer/index.html b/trainer/index.html index 0660155..e8aa870 100644 --- a/trainer/index.html +++ b/trainer/index.html @@ -4,6 +4,7 @@ Gesture Designer +