From 8d7c694b0e142913221e02a170192cac61f1220d Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Tue, 31 Oct 2017 18:16:03 -0700 Subject: [PATCH 1/4] Setting up dev environment to run bottery on local machine watching any change in files and live-reloading --- .gitignore | 1 + gruntfile.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 28 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 gruntfile.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 32ffc9a..965353a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.DS_STORE +node_modules/* diff --git a/gruntfile.js b/gruntfile.js new file mode 100644 index 0000000..58f2fae --- /dev/null +++ b/gruntfile.js @@ -0,0 +1,45 @@ +'use strict'; + +module.exports = function(grunt){ + var protocol = grunt.option('https')?'https' : 'http'; + var liveReloadPort = grunt.option('liveReloadPort') || 35730; + var serverPort = grunt.option('port') || 9000; + var HOST_IP = 'localhost'; + grunt.initConfig({ + connect: { + options: { + port: serverPort, + hostname: HOST_IP, + base: './src', + protocol : protocol + }, + livereload: { + options: { + middleware: function(connect) { + return [ + require('connect-livereload')({ port: liveReloadPort }), + require('serve-static')('./') + ]; + } + } + } + }, + watch: { + options: { + livereload: liveReloadPort + }, + files: [ + '/js/**/*.js', + '/bots/**/*.js', + '/css/**/*.css', + '!/js/vendor/*', + ] + } + }); + grunt.loadNpmTasks('grunt-contrib-connect'); + grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.registerTask('serve', [ + 'connect:livereload', + 'watch' + ]); +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..de2defc --- /dev/null +++ b/package.json @@ -0,0 +1,28 @@ +{ + "name": "bottery", + "version": "1.0.0", + "description": "## A conversational agent prototyping platform by [Kate Compton](https://github.com/galaxykate).", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/smishr4/bottery.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/smishr4/bottery/issues" + }, + "homepage": "https://github.com/smishr4/bottery#readme", + "devDependencies": { + "grunt": "^1.0.1", + "grunt-cli": "^1.2.0" + }, + "dependencies": { + "connect-livereload": "^0.6.0", + "grunt-contrib-connect": "^1.0.2", + "grunt-contrib-watch": "^1.0.0" + } +} From 0e0f7815255393ebbabec2f450ab7acdea49471e Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Tue, 31 Oct 2017 18:55:34 -0700 Subject: [PATCH 2/4] AutoStart the app through grunt-open task, update README.md --- .gitignore | 1 + README.md | 18 ++++++++++++++---- gruntfile.js | 7 +++++++ package.json | 3 ++- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 965353a..a930e37 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *~ *.DS_STORE node_modules/* +npm-debug.log diff --git a/README.md b/README.md index 093aa98..40cb30d 100755 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ The list of actions is in **action syntax** (see below). Conditions fall under the following categories: * Inputs: User input matching a string. E.g., `"one"` or `"two"`. The presence of quotes indicates a string that must be matched by the last user input. An asterisk `*` matches *any* user input. -* Expressions: Mathematical syntax representing equality, inequality, and so on. Most basic math expressions are valid e.g. `count>4`. Expressions can use variables that exist in the blackboard, using the blackboard variable syntax (see above). +* Expressions: Mathematical syntax representing equality, inequality, and so on. Most basic math expressions are valid e.g. `count>4`. Expressions can use variables that exist in the blackboard, using the blackboard variable syntax (see above). * Values: There is only one type of these at present, `wait:[time in seconds to wait]`. This evaluates to true after that much time has elapsed after entering the current state. ### Actions @@ -183,7 +183,7 @@ Interacting with this bot, you can see that the **viz** view displays the state ### Suggestion chips -User interactions can be expedited though the use of suggestion chips. These are prompts that are shown to the user when interacting through text. +User interactions can be expedited though the use of suggestion chips. These are prompts that are shown to the user when interacting through text. ```javascript bot = { @@ -277,7 +277,7 @@ bot = { } ``` -This example adds a global exit. No matter where the Pointer is at on the graph, the user can always pet the kitten. This introduces a problem, though, because the user could potentially pet the kitten before it was named, so an initial value for the name is configured in the blackboard. When the origin is entered, the variable `desired_pets` is set to a random value between 1 and 5. When the user pets the kitten too much, the `angry_pet` node is entered. +This example adds a global exit. No matter where the Pointer is at on the graph, the user can always pet the kitten. This introduces a problem, though, because the user could potentially pet the kitten before it was named, so an initial value for the name is configured in the blackboard. When the origin is entered, the variable `desired_pets` is set to a random value between 1 and 5. When the user pets the kitten too much, the `angry_pet` node is entered. ![](doc_images/kittens3.png?raw=true) @@ -344,7 +344,7 @@ bot = { } ``` -This final example adds state transitions that form a cycle of activity. If no interaction occurs, the kitten will naturally cycle between the states of `hungry`, `sleeping`, and `angry`. The `wait:10` condition on the exit will delay for a particular amount of time before automatically advancing into that state. +This final example adds state transitions that form a cycle of activity. If no interaction occurs, the kitten will naturally cycle between the states of `hungry`, `sleeping`, and `angry`. The `wait:10` condition on the exit will delay for a particular amount of time before automatically advancing into that state. ![](doc_images/kittens4.png?raw=true) @@ -355,3 +355,13 @@ This concludes the tutorial. For more examples of types of bots, check out: * `quiz.js` A basic quiz game where the user answers questions and these are used to determine a Hip Hop DJ name. * `tesla.js` A bot based on the tracery [twitter bot](https://twitter.com/losttesla) of the same name. +### Install and Run Bottery + +To run Bottery in your local machine you need to have node/npm installed on your system, if you haven't then visit https://nodejs.org/en/ and follow the installation guide. Once its done then browse into the project directory and run: + +``` +$npm install +$npm install -g grunt-cli +$grunt serve +``` +The default port to host the app is set to 9000 and for livereload module is 35730, you can change it by passing parameters with `$grunt serve -port -liveReloadPort ` diff --git a/gruntfile.js b/gruntfile.js index 58f2fae..58cce88 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -34,12 +34,19 @@ module.exports = function(grunt){ '/css/**/*.css', '!/js/vendor/*', ] + }, + open: { + dev: { + path: '<%= connect.options.protocol %>://<%= connect.options.hostname %>:<%= connect.options.port %>/' + } } }); grunt.loadNpmTasks('grunt-contrib-connect'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-open'); grunt.registerTask('serve', [ 'connect:livereload', + 'open:dev', 'watch' ]); } diff --git a/package.json b/package.json index de2defc..56423f9 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "dependencies": { "connect-livereload": "^0.6.0", "grunt-contrib-connect": "^1.0.2", - "grunt-contrib-watch": "^1.0.0" + "grunt-contrib-watch": "^1.0.0", + "grunt-open": "^0.2.3" } } From f8eeffefe83db09aff2eb3d3e12a8f5135cbcdb4 Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Wed, 1 Nov 2017 17:55:03 -0700 Subject: [PATCH 3/4] Fixing watch task's paths and updating README.md to be more accurate. --- README.md | 5 +++++ gruntfile.js | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e9695ba..20cdf61 100755 --- a/README.md +++ b/README.md @@ -362,6 +362,11 @@ To run Bottery in your local machine you need to have node/npm installed on your ``` $npm install $npm install -g grunt-cli + +``` + +When installation is done, run: +``` $grunt serve ``` The default port to host the app is set to 9000 and for livereload module is 35730, you can change it by passing parameters with `$grunt serve -port -liveReloadPort ` diff --git a/gruntfile.js b/gruntfile.js index 58cce88..5b50f51 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -29,10 +29,10 @@ module.exports = function(grunt){ livereload: liveReloadPort }, files: [ - '/js/**/*.js', - '/bots/**/*.js', - '/css/**/*.css', - '!/js/vendor/*', + './js/**/*.js', + './bots/**/*.js', + './css/**/*.css', + '!./js/vendor/*', ] }, open: { From 23eafa6860029f4268f8a1cf8184166754cc0208 Mon Sep 17 00:00:00 2001 From: Shubham Mishra Date: Sat, 4 Nov 2017 05:23:14 -0700 Subject: [PATCH 4/4] fixing git username in package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 56423f9..7a7815a 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,14 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/smishr4/bottery.git" + "url": "git+https://github.com/google/bottery.git" }, "author": "", "license": "ISC", "bugs": { - "url": "https://github.com/smishr4/bottery/issues" + "url": "https://github.com/google/bottery/issues" }, - "homepage": "https://github.com/smishr4/bottery#readme", + "homepage": "https://github.com/google/bottery#readme", "devDependencies": { "grunt": "^1.0.1", "grunt-cli": "^1.2.0"