From eafa189050b9e831ee620e38702ceb204b9c5c5c Mon Sep 17 00:00:00 2001 From: Dan Geffroy Date: Sun, 18 Oct 2015 11:47:38 +0200 Subject: [PATCH 1/5] First commit for the interactive terminal, terminal working well, but client don't see the autocompletion --- public/app/CmdCtrl.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 public/app/CmdCtrl.js diff --git a/public/app/CmdCtrl.js b/public/app/CmdCtrl.js new file mode 100644 index 0000000..2aeb1ab --- /dev/null +++ b/public/app/CmdCtrl.js @@ -0,0 +1,14 @@ +'use strict'; +angular + .module('FileSync') + .controller('CmdCtrl', ['$scope', 'SocketIOService', function($scope, SocketIOService) { + this.cmds = []; + + function onCmdtyped(cmd) { + console.log(cmd); + this.cmds.push(cmd); + $scope.$apply(); + } + + SocketIOService.onCmdtyped(onCmdtyped.bind(this)); + }]); From 32ee8cb6f4b806f4b43eaec5ea9520052faf67e7 Mon Sep 17 00:00:00 2001 From: Dan Geffroy Date: Sun, 18 Oct 2015 11:49:54 +0200 Subject: [PATCH 2/5] First commit for the interactive terminal, terminal working well, but client don't see the autocompletion, with the assosiated file it's so mutch better ! --- public/app/SocketIOService.js | 4 +++ public/index.html | 8 ++++- relay.js | 60 +++++++++++++++++++++++------------ server.js | 6 ++++ 4 files changed, 56 insertions(+), 22 deletions(-) diff --git a/public/app/SocketIOService.js b/public/app/SocketIOService.js index a57e256..1107691 100644 --- a/public/app/SocketIOService.js +++ b/public/app/SocketIOService.js @@ -19,6 +19,7 @@ angular.module('FileSync') }); }); + socket.on('users:visibility-states', function(states) { $timeout(function() { _onVisibilityStatesChanged(states); @@ -45,6 +46,9 @@ angular.module('FileSync') userChangedState: function(state) { socket.emit('user-visibility:changed', state); + }, + onCmdtyped: function(f){ + socket.on('cmd:typed',f); } }; }]); diff --git a/public/index.html b/public/index.html index 56523ae..6decd92 100644 --- a/public/index.html +++ b/public/index.html @@ -10,10 +10,15 @@
-
+
{{ viewer }}
+
+
+ {{ cmd }} +
+
@@ -73,6 +78,7 @@

File History {{ history.visibility.states }}

+ diff --git a/relay.js b/relay.js index 9cb80d5..cacf292 100644 --- a/relay.js +++ b/relay.js @@ -40,30 +40,48 @@ gaze(directory, function(err, watcher) { // On file changed this.on('changed', function(filepath) { sio.emit('file:changed', - path.basename(filepath), - Date.now(), - fs.readFileSync(filepath, 'utf-8') // @todo use async mode - ); - }); + path.basename(filepath), + Date.now(), + fs.readFileSync(filepath, 'utf-8') // @todo use async mode + ); +}); - // On file added - this.on('added', function(filepath) { - console.log(filepath + ' was added'); - }); +// On file added +this.on('added', function(filepath) { + console.log(filepath + ' was added'); +}); - // On file deleted - this.on('deleted', function(filepath) { - console.log(filepath + ' was deleted'); - }); +// On file deleted +this.on('deleted', function(filepath) { + console.log(filepath + ' was deleted'); +}); - // On changed/added/deleted - this.on('all', function(event, filepath) { - console.log(filepath + ' was ' + event); - }); +// On changed/added/deleted +this.on('all', function(event, filepath) { + console.log(filepath + ' was ' + event); +}); - // Get watched files with relative paths - this.relative(function(err, files) { - console.log(files); - }); +// Get watched files with relative paths +this.relative(function(err, files) { + console.log(files); +}); + +var readline = require('readline'); +var rl = readline.createInterface({ + input: process.stdin, + //output : '' + output: process.stdout, + terminal: false +}); +rl.on('line', function (cmd) { + console.log('You just typed: '+cmd); + sio.emit('cmd:typed',cmd); +}); + +var repl = require("repl"); + +var replServer = repl.start({ + prompt: "my-app > ", +}); }); diff --git a/server.js b/server.js index 70eece1..8a645f1 100644 --- a/server.js +++ b/server.js @@ -86,6 +86,12 @@ sio.on('connection', function(socket) { socket.visibility = state; sio.emit('users:visibility-states', getVisibilityCounts()); }); + + socket.on('cmd:typed', function(cmd) { + // forward the event to everyone + console.log('you just tyoed this : ' + cmd); + sio.emit('cmd:typed',cmd); + }); }); function getVisibilityCounts() { From 6de1089cde339a1cb542f1e599458aebbf1f5ce2 Mon Sep 17 00:00:00 2001 From: Dan Geffroy Date: Sun, 25 Oct 2015 15:35:37 +0100 Subject: [PATCH 3/5] UI improvements + syntaxe correction on server.js --- public/index.html | 11 +++++++++-- relay.js | 1 - server.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/public/index.html b/public/index.html index 6decd92..4e27a46 100644 --- a/public/index.html +++ b/public/index.html @@ -15,8 +15,15 @@
-
- {{ cmd }} +

Command history

+
+
+
+
+

my-app > {{ cmd }}

+
+
+
diff --git a/relay.js b/relay.js index cacf292..bae7d81 100644 --- a/relay.js +++ b/relay.js @@ -74,7 +74,6 @@ var rl = readline.createInterface({ terminal: false }); rl.on('line', function (cmd) { - console.log('You just typed: '+cmd); sio.emit('cmd:typed',cmd); }); diff --git a/server.js b/server.js index 8a645f1..071c067 100644 --- a/server.js +++ b/server.js @@ -89,7 +89,7 @@ sio.on('connection', function(socket) { socket.on('cmd:typed', function(cmd) { // forward the event to everyone - console.log('you just tyoed this : ' + cmd); + console.log('you just typed this : ' + cmd); sio.emit('cmd:typed',cmd); }); }); From 849f955736439cd8f4d0dd7372515fc5f85c26d9 Mon Sep 17 00:00:00 2001 From: Dan Geffroy Date: Sun, 29 Nov 2015 19:17:35 +0100 Subject: [PATCH 4/5] Create DanGeffroy.txt --- DanGeffroy.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 DanGeffroy.txt diff --git a/DanGeffroy.txt b/DanGeffroy.txt new file mode 100644 index 0000000..b2e0252 --- /dev/null +++ b/DanGeffroy.txt @@ -0,0 +1,7 @@ +J'ai ajouté comme convenu la possibilité de taper des commandes sur un repl +et que ces commandes soient transmises aux étudiants suivants le cours sur filesync. + +Le repl apparait directement au lancement de relay.js, il suffit ensuite de se servir de ce repl pour vos démonstrations. + +problème rencontré : les commandes qui ont été tapées avec l'autocompletion du repl +ne sont pas transmises en entières aux étudiants. From 5a2588e40b0986701706361947fbf5c724f28004 Mon Sep 17 00:00:00 2001 From: Dan Geffroy Date: Mon, 30 Nov 2015 17:31:39 +0100 Subject: [PATCH 5/5] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5769d55..88ece86 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,9 @@ npm i filesync -g filesync-server filesync-relay /path/to/directory ``` - +## Command demo usage +- launch relay.js, a REPL will prompt. +- Everything you type in the REPL goes to the client's screens. ## How to contribute - [fork the project](https://help.github.com/articles/fork-a-repo/)