From e2ab95ce3e9611f788ed807ff8f07975cfea56ee Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Thu, 21 Apr 2011 15:47:15 +0200 Subject: [PATCH 01/34] part one of plugin refactoring --- server/cloud9/ext/auth/index.js | 8 +-- server/cloud9/ext/debugger/index.js | 55 ++++++++++---------- server/cloud9/ext/git/index.js | 11 ++-- server/cloud9/ext/settings/index.js | 6 +-- server/cloud9/ext/shell/index.js | 23 +++++---- server/cloud9/ext/state/index.js | 14 ++--- server/cloud9/ext/watcher/index.js | 15 +++--- server/cloud9/ide.js | 79 +++-------------------------- server/cloud9/plugin.js | 39 +++++++------- server/cloud9/user.js | 7 +-- server/cloud9/util.js | 10 ++++ server/cloud9/workspace.js | 78 ++++++++++++++++++++++++++++ 12 files changed, 188 insertions(+), 157 deletions(-) create mode 100644 server/cloud9/util.js create mode 100644 server/cloud9/workspace.js diff --git a/server/cloud9/ext/auth/index.js b/server/cloud9/ext/auth/index.js index 42fa2ec045d..15f5a8ed1ea 100644 --- a/server/cloud9/ext/auth/index.js +++ b/server/cloud9/ext/auth/index.js @@ -7,8 +7,8 @@ var Plugin = require("cloud9/plugin"); var sys = require("sys"); -var AuthPlugin = module.exports = function(ide) { - this.ide = ide; +var AuthPlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "auth"; }; @@ -22,12 +22,12 @@ sys.inherits(AuthPlugin, Plugin); return false; if (message.workspaceId != this.ide.options.workspaceId) { - this.ide.error("Unable to attach web socket!", 10, message, client) + this.error("Unable to attach web socket!", 10, message, client) return true; } client.send('{"type": "attached"}'); - this.ide.execHook("connect", user, client); + this.workspace.execHook("connect", user, client); return true; }; diff --git a/server/cloud9/ext/debugger/index.js b/server/cloud9/ext/debugger/index.js index a9fe08d58d4..598982f97df 100644 --- a/server/cloud9/ext/debugger/index.js +++ b/server/cloud9/ext/debugger/index.js @@ -12,8 +12,8 @@ var Path = require("path"), sys = require("sys"), netutil = require("cloud9/netutil"); -var DebuggerPlugin = module.exports = function(ide) { - this.ide = ide; +var DebuggerPlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "debugger"; }; @@ -23,7 +23,7 @@ sys.inherits(DebuggerPlugin, Plugin); (function() { this.init = function() { var _self = this; - this.ide.getExt("state").on("statechange", function(state) { + this.workspace.getExt("state").on("statechange", function(state) { state.debugClient = !!_self.debugClient; state.processRunning = !!_self.child; }); @@ -47,7 +47,7 @@ sys.inherits(DebuggerPlugin, Plugin); message.preArgs = ["--debug=" + _self.NODE_DEBUG_PORT]; message.debug = true; _self.$run(message, client); - + setTimeout(function() { _self.$startDebug(); }, 100); @@ -56,11 +56,11 @@ sys.inherits(DebuggerPlugin, Plugin); case "rundebugbrk": netutil.findFreePort(this.NODE_DEBUG_PORT, "localhost", function(port) { _self.NODE_DEBUG_PORT = port; - + message.preArgs = ["--debug-brk=" + _self.NODE_DEBUG_PORT]; message.debug = true; _self.$run(message, client); - + setTimeout(function() { _self.$startDebug(); }, 100); @@ -68,25 +68,25 @@ sys.inherits(DebuggerPlugin, Plugin); break; case "rundebugchrome": if (this.chromeDebugProxy) { - this.ide.error("Chrome debugger already running!", 7, message); + this.error("Chrome debugger already running!", 7, message); break; } this.chromeDebugProxy = new ChromeDebugProxy(this.CHROME_DEBUG_PORT); this.chromeDebugProxy.connect(); this.chromeDebugProxy.addEventListener("connection", function() { - _self.ide.broadcast('{"type": "chrome-debug-ready"}', _self.name); + _self.send('{"type": "chrome-debug-ready"}', null, _self.name); }); break; case "debugnode": if (!this.nodeDebugProxy) - this.ide.error("No debug session running!", 6, message); + this.error("No debug session running!", 6, message); else this.nodeDebugProxy.send(message.body); break; case "debugattachnode": if (this.nodeDebugProxy) - this.ide.broadcast('{"type": "node-debug-ready"}', _self.name); + this.send('{"type": "node-debug-ready"}', null, _self.name); break; case "kill": this.$kill(); @@ -118,18 +118,18 @@ sys.inherits(DebuggerPlugin, Plugin); var _self = this; if (this.child) - return _self.ide.error("Child process already running!", 1, message); + return _self.error("Child process already running!", 1, message); var file = _self.ide.workspaceDir + "/" + message.file; - + Path.exists(file, function(exists) { if (!exists) - return _self.ide.error("File does not exist: " + message.file, 2, message); - + return _self.error("File does not exist: " + message.file, 2, message); + var cwd = _self.ide.workspaceDir + "/" + (message.cwd || ""); Path.exists(cwd, function(exists) { if (!exists) - return _self.ide.error("cwd does not exist: " + message.cwd, 3, message); + return _self.error("cwd does not exist: " + message.cwd, 3, message); // lets check what we need to run if(file.match(/\.js$/)){ var args = (message.preArgs || []).concat(file).concat(message.args || []); @@ -143,6 +143,7 @@ sys.inherits(DebuggerPlugin, Plugin); this.$runProc = function(proc, args, cwd, env, debug) { var _self = this; + var name = this.name; // mixin process env for (var key in process.env) { @@ -150,12 +151,12 @@ sys.inherits(DebuggerPlugin, Plugin); env[key] = process.env[key]; } - console.log("Executing node "+proc+" "+args.join(" ")+" "+cwd); + console.log("Executing node "+proc+" "+args.join(" ")+" "+cwd); var child = _self.child = Spawn(proc, args, {cwd: cwd, env: env}); _self.debugClient = args.join(" ").search(/(?:^|\b)\-\-debug\b/) != -1; - _self.ide.getExt("state").publishState(); - _self.ide.broadcast(JSON.stringify({"type": "node-start"}), _self.name); + _self.workspace.getExt("state").publishState(); + _self.send({"type": "node-start"}, null, name); child.stdout.on("data", sender("stdout")); child.stderr.on("data", sender("stderr")); @@ -167,12 +168,12 @@ sys.inherits(DebuggerPlugin, Plugin); "stream": stream, "data": data.toString("utf8") }; - _self.ide.broadcast(JSON.stringify(message), _self.name); + _self.send(message, null, name); }; } child.on("exit", function(code) { - _self.ide.broadcast(JSON.stringify({"type": "node-exit"}), _self.name); + _self.send({"type": "node-exit"}, null, name); _self.debugClient = false; delete _self.child; @@ -186,10 +187,10 @@ sys.inherits(DebuggerPlugin, Plugin); var _self = this; if (!this.debugClient) - return this.ide.error("No debuggable application running", 4, message); + return this.error("No debuggable application running", 4, message); if (this.nodeDebugProxy) - return this.ide.error("Debug session already running", 5, message); + return this.error("Debug session already running", 5, message); this.nodeDebugProxy = new NodeDebugProxy(this.NODE_DEBUG_PORT); this.nodeDebugProxy.on("message", function(body) { @@ -197,11 +198,11 @@ sys.inherits(DebuggerPlugin, Plugin); "type": "node-debug", "body": body }; - _self.ide.broadcast(JSON.stringify(msg), _self.name); + _self.send(msg, null, _self.name); }); this.nodeDebugProxy.on("connection", function() { - _self.ide.broadcast('{"type": "node-debug-ready"}', _self.name); + _self.send('{"type": "node-debug-ready"}', null, _self.name); }); this.nodeDebugProxy.on("end", function() { @@ -212,10 +213,10 @@ sys.inherits(DebuggerPlugin, Plugin); this.nodeDebugProxy.connect(); }; - + this.dispose = function(callback) { this.$kill(); callback(); }; - -}).call(DebuggerPlugin.prototype); \ No newline at end of file + +}).call(DebuggerPlugin.prototype); diff --git a/server/cloud9/ext/git/index.js b/server/cloud9/ext/git/index.js index ae3262639ef..fde618fdc41 100644 --- a/server/cloud9/ext/git/index.js +++ b/server/cloud9/ext/git/index.js @@ -5,10 +5,11 @@ * @license GPLv3 */ var Plugin = require("cloud9/plugin"); -var sys = require("sys"); +var sys = require("sys"); +var util = require("cloud9/util"); -var ShellGitPlugin = module.exports = function(ide) { - this.ide = ide; +var ShellGitPlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "git"; }; @@ -49,14 +50,14 @@ sys.inherits(ShellGitPlugin, Plugin); } function onfinish() { - _self.extend(commands, githelp); + util.extend(commands, githelp); callback(); } }; this.augmentCommand = function(cmd, struct) { var map = commandsMap[cmd] || commandsMap["default"]; - return this.extend(struct, map || {}); + return util.extend(struct, map || {}); }; this.command = function(user, message, client) { diff --git a/server/cloud9/ext/settings/index.js b/server/cloud9/ext/settings/index.js index f1277ed0e29..c792c747f23 100644 --- a/server/cloud9/ext/settings/index.js +++ b/server/cloud9/ext/settings/index.js @@ -9,8 +9,8 @@ var Path = require("path"); var fs = require("fs"); var sys = require("sys"); -var SettingsPlugin = module.exports = function(ide) { - this.ide = ide; +var SettingsPlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "settings"; @@ -37,7 +37,7 @@ sys.inherits(SettingsPlugin, Plugin); else if (message.action == "set") { this.storeSettings(user, message.settings, function(err) { if (err) - _self.ide.error(err, 500, message, client); + _self.error(err, 500, message, client); }); } return true; diff --git a/server/cloud9/ext/shell/index.js b/server/cloud9/ext/shell/index.js index bc1d4607b5e..aa21269000f 100644 --- a/server/cloud9/ext/shell/index.js +++ b/server/cloud9/ext/shell/index.js @@ -4,17 +4,18 @@ * @copyright 2010, Ajax.org B.V. * @license GPLv3 */ -var Plugin = require("cloud9/plugin"), - Fs = require("fs"), - Path = require("path"), - Async = require("asyncjs"), - sys = require("sys"); +var Plugin = require("cloud9/plugin"); +var Fs = require("fs"); +var Path = require("path"); +var Async = require("asyncjs"); +var sys = require("sys"); +var util = require("cloud9/util"); -var ShellPlugin = module.exports = function(ide) { - this.ide = ide; +var ShellPlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "shell"; -} +}; sys.inherits(ShellPlugin, Plugin); @@ -71,9 +72,9 @@ sys.inherits(ShellPlugin, Plugin); var commands = {}, _self = this; - Async.list(Object.keys(this.ide.exts)) + Async.list(Object.keys(this.workspace.exts)) .each(function(sName, next) { - var oExt = _self.ide.getExt(sName); + var oExt = _self.workspace.getExt(sName); if (oExt["$commandHints"]) { oExt["$commandHints"](commands, message, next); } @@ -93,7 +94,7 @@ sys.inherits(ShellPlugin, Plugin); function afterMeta() { if (oExt.metadata && oExt.metadata.commands) - _self.extend(commands, oExt.metadata.commands); + util.extend(commands, oExt.metadata.commands); next(); } } diff --git a/server/cloud9/ext/state/index.js b/server/cloud9/ext/state/index.js index 03f6775a692..a1ce17cd432 100644 --- a/server/cloud9/ext/state/index.js +++ b/server/cloud9/ext/state/index.js @@ -7,8 +7,8 @@ var Plugin = require("cloud9/plugin"); var sys = require("sys"); -var cloud9StatePlugin = module.exports = function(ide) { - this.ide = ide; +var cloud9StatePlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["connect", "command"]; this.name = "state"; }; @@ -19,14 +19,14 @@ sys.inherits(cloud9StatePlugin, Plugin); this.connect = function(user, message, client) { this.publishState(); }; - + this.command = function(user, message, client) { if (message && message.command !== "state") return false; return true; }; - + this.publishState = function() { var state = { "type": "state", @@ -35,8 +35,8 @@ sys.inherits(cloud9StatePlugin, Plugin); }; this.emit("statechange", state); - console.log("publish state" + JSON.stringify(state)) - this.ide.broadcast(JSON.stringify(state)); + console.log("publish state" + JSON.stringify(state)); + this.send(state, null, this.name); }; - + }).call(cloud9StatePlugin.prototype); diff --git a/server/cloud9/ext/watcher/index.js b/server/cloud9/ext/watcher/index.js index b9f85c7ce9e..7178deca480 100644 --- a/server/cloud9/ext/watcher/index.js +++ b/server/cloud9/ext/watcher/index.js @@ -12,9 +12,9 @@ var IGNORE_TIMEOUT = 50, ignoredPaths = {}, ignoreTimers = {}; -function cloud9WatcherPlugin(ide) { - var that = this; - +var cloud9WatcherPlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); + ide.davServer.plugins['watcher'] = function (handler) { handler.addEventListener('beforeWriteContent', function (e, uri) { var path = handler.server.tree.basePath + '/' + uri; @@ -25,7 +25,6 @@ function cloud9WatcherPlugin(ide) { }); }; - this.ide = ide; this.hooks = ["disconnect", "command"]; this.name = "watcher"; this.filenames = {}; @@ -98,12 +97,12 @@ sys.inherits(cloud9WatcherPlugin, Plugin); } }); } - that.ide.broadcast(JSON.stringify({ + that.send({ "type" : "watcher", "subtype" : subtype, "path" : path, "files" : files - })); + }); //console.log("Sent " + subtype + " notification for file " + path); }); this.filenames[path] = 0; @@ -123,6 +122,4 @@ sys.inherits(cloud9WatcherPlugin, Plugin); callback(); }; -}).call(cloud9WatcherPlugin.prototype); - -module.exports = cloud9WatcherPlugin; +}).call(cloud9WatcherPlugin.prototype); \ No newline at end of file diff --git a/server/cloud9/ide.js b/server/cloud9/ide.js index 441de060407..89ce901b80c 100644 --- a/server/cloud9/ide.js +++ b/server/cloud9/ide.js @@ -12,6 +12,7 @@ var jsDAV = require("jsdav"), lang = require("pilot/lang"), Url = require("url"), template = require("./template"), + Workspace = require("cloud9/workspace"), EventEmitter = require("events").EventEmitter; module.exports = Ide = function(options, httpServer, exts, socket) { @@ -19,6 +20,8 @@ module.exports = Ide = function(options, httpServer, exts, socket) { this.httpServer = httpServer; this.socket = socket; + + this.workspace = new Workspace(this); this.workspaceDir = Async.abspath(options.workspaceDir).replace(/\/+$/, ""); var baseUrl = (options.baseUrl || "").replace(/\/+$/, ""); @@ -58,7 +61,7 @@ module.exports = Ide = function(options, httpServer, exts, socket) { this.davServer = jsDAV.mount(this.options.mountDir, this.options.davPrefix, this.httpServer, false); this.davInited = false; - this.registerExts(exts); + this.workspace.createPlugins(exts); }; sys.inherits(Ide, EventEmitter); @@ -171,7 +174,7 @@ Ide.DEFAULT_PLUGINS = [ version: _self.options.version }; - var settingsPlugin = _self.getExt("settings"); + var settingsPlugin = _self.workspace.getExt("settings"); var user = _self.getUser(req); if (!settingsPlugin || !user) { index = template.fill(index, replacements); @@ -202,7 +205,7 @@ Ide.DEFAULT_PLUGINS = [ _self.onUserMessage(msg.user, msg.message, msg.client); }); user.on("disconnectClient", function(msg) { - _self.execHook("disconnect", msg.user, msg.client); + _self.workspace.execHook("disconnect", msg.user, msg.client); }); user.on("disconnectUser", function(user) { console.log("Running user disconnect timer..."); @@ -251,7 +254,7 @@ Ide.DEFAULT_PLUGINS = [ }; this.onUserMessage = function(user, message, client) { - this.execHook("command", user, message, client); + this.workspace.execHook("command", user, message, client); }; this.onUserCountChange = function() { @@ -272,75 +275,9 @@ Ide.DEFAULT_PLUGINS = [ this.sendToUser = function(username, msg) { this.$users[username] && this.$users[username].broadcast(msg); } - - this.registerExts = function(exts) { - this.exts = {} - - for (var ext in exts) { - this.exts[ext] = new exts[ext](this); - } - for (ext in this.exts) { - if (this.exts[ext].init) - this.exts[ext].init(); - } - } - - this.getExt = function(name) { - return this.exts[name] || null; - }; - - this.execHook = function(hook, user /* varargs */) { - var ext, hooks, - args = Array.prototype.slice.call(arguments, 1), - hook = hook.toLowerCase().replace(/^[\s]+/, "").replace(/[\s]+$/, ""); - - var server_exclude = lang.arrayToMap(user.getPermissions().server_exclude.split("|")); - - for (var name in this.exts) { - if (server_exclude[name]) { - continue; - } - - ext = this.exts[name]; - hooks = ext.getHooks(); - if (hooks.indexOf(hook) > -1 && ext[hook].apply(ext, args) === true) { - return; - } - } - // if we get here, no hook function was successfully delegated to an - // extension. - - //this.error("Error: no handler found for hook '" + hook + "'. Arguments: " - // + sys.inspect(args), 9, args[0]); - }; - - // TODO remove - this.error = function(description, code, message, client) { - //console.log("Socket error: " + description, new Error().stack); - var sid = (message || {}).sid || -1; - var error = JSON.stringify({ - "type": "error", - "sid": sid, - "code": code, - "message": description - }); - if (client) - client.send(error) - else - this.broadcast(error); - }; this.dispose = function(callback) { - var count; - for (var name in this.exts) { - count++; - var ext = this.exts[name]; - ext.dispose(function() { - count--; - if (count == 0) - callback(); - }); - } + this.workspace.dispose(callback); }; }).call(Ide.prototype); diff --git a/server/cloud9/plugin.js b/server/cloud9/plugin.js index 193dd11fe50..b27ee216923 100644 --- a/server/cloud9/plugin.js +++ b/server/cloud9/plugin.js @@ -1,28 +1,25 @@ /** - * @copyright 2010, Ajax.org Services B.V. + * @copyright 2011, Ajax.org Services B.V. * @license GPLv3 */ -var Spawn = require("child_process").spawn; -var sys = require("sys"); -function cloud9Plugin() {} +var events = require("events"); +var Spawn = require("child_process").spawn; +var sys = require("sys"); -sys.inherits(cloud9Plugin, process.EventEmitter); +var Plugin = function(ide, workspace) { + this.ide = ide; + this.workspace = workspace; +}; + +sys.inherits(Plugin, events.EventEmitter); (function() { this.getHooks = function() { return this.hooks || []; }; - this.extend = function(dest, src) { - for (var prop in src) { - dest[prop] = src[prop]; - } - return dest; - }; - this.sendResult = function(sid, type, msg) { - //console.log("sending result to client: ", type, JSON.stringify(msg)); this.ide.broadcast(JSON.stringify({ type : "result", subtype: type || "error", @@ -31,6 +28,14 @@ sys.inherits(cloud9Plugin, process.EventEmitter); }), this.name); }; + this.error = function(description, code, message, client) { + return this.workspace.error(description, code, message, client); + }; + + this.send = function(msg, replyTo, scope) { + this.workspace.send(msg, replyTo, scope); + }; + this.spawnCommand = function(cmd, args, cwd, onerror, ondata, onexit) { var child = this.activePs = Spawn(cmd, args || [], {cwd: cwd || this.server.workspaceDir}), out = "", @@ -60,11 +65,11 @@ sys.inherits(cloud9Plugin, process.EventEmitter); return child; }; - + this.dispose = function(callback) { callback(); }; - -}).call(cloud9Plugin.prototype); -module.exports = cloud9Plugin; +}).call(Plugin.prototype); + +module.exports = Plugin; diff --git a/server/cloud9/user.js b/server/cloud9/user.js index 8af15d640ba..fe067477c4d 100644 --- a/server/cloud9/user.js +++ b/server/cloud9/user.js @@ -122,14 +122,15 @@ User.VISITOR_PERMISSIONS = { this.error = function(description, code, message, client) { //console.log("Socket error: " + description, new Error().stack); var sid = (message || {}).sid || -1; - var error = JSON.stringify({ + var error = { "type": "error", "sid": sid, "code": code, "message": description - }); + }; + if (client) - client.send(error); + client.send(JSON.stringify(error)); else this.broadcast(error); }; diff --git a/server/cloud9/util.js b/server/cloud9/util.js new file mode 100644 index 00000000000..c0a664c1db4 --- /dev/null +++ b/server/cloud9/util.js @@ -0,0 +1,10 @@ +/** + * @copyright 2011, Ajax.org Services B.V. + * @license GPLv3 + */ +exports.extend = function(dest, src) { + for (var prop in src) { + dest[prop] = src[prop]; + } + return dest; +}; \ No newline at end of file diff --git a/server/cloud9/workspace.js b/server/cloud9/workspace.js new file mode 100644 index 00000000000..b561bf811ab --- /dev/null +++ b/server/cloud9/workspace.js @@ -0,0 +1,78 @@ +var lang = require("pilot/lang"); + +var Workspace = module.exports = function(ide) { + this.ide = ide; +}; + +(function() { + this.createPlugins = function (plugins) { + var exts = this.exts = {}; + + for (var name in plugins) { + exts[name] = new plugins[name](this.ide, this); + } + for (name in exts) { + if (exts[name].init) + exts[name].init(); + } + }; + + this.execHook = function(hook, user /* varargs */) { + var ext, hooks, + args = Array.prototype.slice.call(arguments, 1), + hook = hook.toLowerCase().replace(/^[\s]+/, "").replace(/[\s]+$/, ""); + + var server_exclude = lang.arrayToMap(user.getPermissions().server_exclude.split("|")); + + for (var name in this.exts) { + if (server_exclude[name]) { + continue; + } + + ext = this.exts[name]; + hooks = ext.getHooks(); + if (hooks.indexOf(hook) > -1 && ext[hook].apply(ext, args) === true) { + return; + } + } + }; + + this.getExt = function(name) { + return this.exts[name] || null; + }; + + this.send = function(msg, replyTo, scope) { + if (replyTo) + msg.sid = replyTo.sid; + this.ide.broadcast(JSON.stringify(msg), scope); + }; + + this.error = function(description, code, message, client) { + var sid = (message || {}).sid || -1; + var error = { + "type": "error", + "sid": sid, + "code": code, + "message": description + }; + + if (client) + client.send(JSON.stringify(error)); + else + this.broadcast(error); + }; + + this.dispose = function(callback) { + var count; + for (var name in this.exts) { + count++; + var ext = this.exts[name]; + ext.dispose(function() { + count--; + if (count == 0) + callback(); + }); + } + }; + +}).call(Workspace.prototype); From e04886f9a988f61bc879f46d9341d53c3183305b Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Thu, 21 Apr 2011 16:35:16 +0200 Subject: [PATCH 02/34] Renaming plugin files to their plugin names --- .gitignore | 2 ++ server/cloud9/ext/auth/{index.js => auth.js} | 2 +- .../ext/debugger/{index.js => debugger.js} | 7 ++++--- server/cloud9/ext/git/{index.js => git.js} | 0 .../ext/settings/{index.js => settings.js} | 0 .../cloud9/ext/shell/{index.js => shell.js} | 8 ++++---- .../cloud9/ext/state/{index.js => state.js} | 4 +--- .../ext/watcher/{index.js => watcher.js} | 0 server/cloud9/ide.js | 13 +++++++++---- server/cloud9/index.js | 19 ++++++++++--------- server/cloud9/workspace.js | 2 ++ 11 files changed, 33 insertions(+), 24 deletions(-) rename server/cloud9/ext/auth/{index.js => auth.js} (92%) rename server/cloud9/ext/debugger/{index.js => debugger.js} (96%) rename server/cloud9/ext/git/{index.js => git.js} (100%) rename server/cloud9/ext/settings/{index.js => settings.js} (100%) rename server/cloud9/ext/shell/{index.js => shell.js} (95%) rename server/cloud9/ext/state/{index.js => state.js} (88%) rename server/cloud9/ext/watcher/{index.js => watcher.js} (100%) diff --git a/.gitignore b/.gitignore index 1e7db6c361a..263720b1007 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +*.swp +*.un~ common/packager common/apf client/icons/Thumbs.db diff --git a/server/cloud9/ext/auth/index.js b/server/cloud9/ext/auth/auth.js similarity index 92% rename from server/cloud9/ext/auth/index.js rename to server/cloud9/ext/auth/auth.js index 15f5a8ed1ea..b39eb4ab939 100644 --- a/server/cloud9/ext/auth/index.js +++ b/server/cloud9/ext/auth/auth.js @@ -21,7 +21,7 @@ sys.inherits(AuthPlugin, Plugin); if (message.command != "attach") return false; - if (message.workspaceId != this.ide.options.workspaceId) { + if (message.workspaceId != this.workspace.workspaceId) { this.error("Unable to attach web socket!", 10, message, client) return true; } diff --git a/server/cloud9/ext/debugger/index.js b/server/cloud9/ext/debugger/debugger.js similarity index 96% rename from server/cloud9/ext/debugger/index.js rename to server/cloud9/ext/debugger/debugger.js index 598982f97df..97515aa6bd9 100644 --- a/server/cloud9/ext/debugger/index.js +++ b/server/cloud9/ext/debugger/debugger.js @@ -16,6 +16,7 @@ var DebuggerPlugin = module.exports = function(ide, workspace) { Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "debugger"; + this.nodeCmd = process.argv[0]; }; sys.inherits(DebuggerPlugin, Plugin); @@ -120,20 +121,20 @@ sys.inherits(DebuggerPlugin, Plugin); if (this.child) return _self.error("Child process already running!", 1, message); - var file = _self.ide.workspaceDir + "/" + message.file; + var file = _self.workspace.workspaceDir + "/" + message.file; Path.exists(file, function(exists) { if (!exists) return _self.error("File does not exist: " + message.file, 2, message); - var cwd = _self.ide.workspaceDir + "/" + (message.cwd || ""); + var cwd = _self.workspace.workspaceDir + "/" + (message.cwd || ""); Path.exists(cwd, function(exists) { if (!exists) return _self.error("cwd does not exist: " + message.cwd, 3, message); // lets check what we need to run if(file.match(/\.js$/)){ var args = (message.preArgs || []).concat(file).concat(message.args || []); - _self.$runProc(_self.ide.nodeCmd, args, cwd, message.env || {}, message.debug || false); + _self.$runProc(_self.nodeCmd, args, cwd, message.env || {}, message.debug || false); } else { _self.$runProc(file, message.args||[], cwd, message.env || {}, false); } diff --git a/server/cloud9/ext/git/index.js b/server/cloud9/ext/git/git.js similarity index 100% rename from server/cloud9/ext/git/index.js rename to server/cloud9/ext/git/git.js diff --git a/server/cloud9/ext/settings/index.js b/server/cloud9/ext/settings/settings.js similarity index 100% rename from server/cloud9/ext/settings/index.js rename to server/cloud9/ext/settings/settings.js diff --git a/server/cloud9/ext/shell/index.js b/server/cloud9/ext/shell/shell.js similarity index 95% rename from server/cloud9/ext/shell/index.js rename to server/cloud9/ext/shell/shell.js index aa21269000f..fe027e21cc0 100644 --- a/server/cloud9/ext/shell/index.js +++ b/server/cloud9/ext/shell/shell.js @@ -47,11 +47,11 @@ sys.inherits(ShellPlugin, Plugin); this["internal-isfile"] = function(message) { var file = message.argv.pop(), - path = message.cwd || this.ide.workspaceDir, + path = message.cwd || this.workspace.workspaceDir, _self = this; path = Path.normalize(path + "/" + file.replace(/^\//g, "")); - if (path.indexOf(this.ide.workspaceDir) === -1) { + if (path.indexOf(this.workspace.workspaceDir) === -1) { this.sendResult(); return; } @@ -119,11 +119,11 @@ sys.inherits(ShellPlugin, Plugin); this.cd = function(message) { var to = message.argv.pop(), - path = message.cwd || this.ide.workspaceDir, + path = message.cwd || this.workspace.workspaceDir, _self = this; if (to != "/") { path = Path.normalize(path + "/" + to.replace(/^\//g, "")); - if (path.indexOf(this.ide.workspaceDir) === -1) + if (path.indexOf(this.workspace.workspaceDir) === -1) return this.sendResult(); Fs.stat(path, function(err, stat) { if (err) { diff --git a/server/cloud9/ext/state/index.js b/server/cloud9/ext/state/state.js similarity index 88% rename from server/cloud9/ext/state/index.js rename to server/cloud9/ext/state/state.js index a1ce17cd432..064114317b4 100644 --- a/server/cloud9/ext/state/index.js +++ b/server/cloud9/ext/state/state.js @@ -29,9 +29,7 @@ sys.inherits(cloud9StatePlugin, Plugin); this.publishState = function() { var state = { - "type": "state", - "workspaceDir": this.ide.workspaceDir, - "davPrefix": this.ide.davPrefix + "type": "state" }; this.emit("statechange", state); diff --git a/server/cloud9/ext/watcher/index.js b/server/cloud9/ext/watcher/watcher.js similarity index 100% rename from server/cloud9/ext/watcher/index.js rename to server/cloud9/ext/watcher/watcher.js diff --git a/server/cloud9/ide.js b/server/cloud9/ide.js index 89ce901b80c..8837ae505e2 100644 --- a/server/cloud9/ide.js +++ b/server/cloud9/ide.js @@ -20,8 +20,6 @@ module.exports = Ide = function(options, httpServer, exts, socket) { this.httpServer = httpServer; this.socket = socket; - - this.workspace = new Workspace(this); this.workspaceDir = Async.abspath(options.workspaceDir).replace(/\/+$/, ""); var baseUrl = (options.baseUrl || "").replace(/\/+$/, ""); @@ -56,12 +54,19 @@ module.exports = Ide = function(options, httpServer, exts, socket) { this.$users = {}; - this.nodeCmd = process.argv[0]; - this.davServer = jsDAV.mount(this.options.mountDir, this.options.davPrefix, this.httpServer, false); this.davInited = false; + this.workspace = new Workspace(this); + this.workspace.createPlugins(exts); + var statePlugin = this.workspace.getExt("state"); + if (statePlugin) { + statePlugin.on("statechange", function(state) { + state.workspaceDir = this.workspace.workspaceDir; + state.davPrefix = this.ide.davPrefix; + }); + } }; sys.inherits(Ide, EventEmitter); diff --git a/server/cloud9/index.js b/server/cloud9/index.js index 294c27b7a56..09d30e22c0e 100644 --- a/server/cloud9/index.js +++ b/server/cloud9/index.js @@ -18,17 +18,18 @@ exports.main = function(options) { ip = options.ip, user = options.user, group = options.group; - - if (!Path.existsSync(projectDir)) + + if (!Path.existsSync(projectDir)) throw new Error("Workspace directory does not exist: " + projectDir); - + var ideProvider = function(projectDir, server) { // load plugins: var exts = {}; Fs.readdirSync(Path.normalize(__dirname + "/ext")).forEach(function(name){ - exts[name] = require("./ext/" + name); + if (name[0] !== ".") + exts[name] = require("./ext/" + name + "/" + name); }); - + // create web socket var socketOptions = { transports: ['websocket', 'htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling'] @@ -37,7 +38,7 @@ exports.main = function(options) { socketIo.on("connection", function(client) { ide.addClientConnection("owner", client, null); }); - + var name = projectDir.split("/").pop(); var serverOptions = { workspaceDir: projectDir, @@ -50,14 +51,14 @@ exports.main = function(options) { version: options.version }; var ide = new IdeServer(serverOptions, server, exts); - + return function(req, res, next) { req.session.uid = "owner"; ide.addUser("owner", User.OWNER_PERMISSIONS); ide.handle(req, res, next); }; }; - + var server = Connect.createServer(); //server.use(Connect.logger()); server.use(Connect.conditionalGet()); @@ -85,4 +86,4 @@ process.on("uncaughtException", function(e) { if (module === require.main) { exports.main({workspace: ".", port: 3000, ip: '127.0.0.1'}); -} \ No newline at end of file +} diff --git a/server/cloud9/workspace.js b/server/cloud9/workspace.js index b561bf811ab..20ee763b7e4 100644 --- a/server/cloud9/workspace.js +++ b/server/cloud9/workspace.js @@ -2,6 +2,8 @@ var lang = require("pilot/lang"); var Workspace = module.exports = function(ide) { this.ide = ide; + this.workspaceId = ide.options.workspaceId; + this.workspaceDir = ide.options.workspaceDir; }; (function() { From cb6120eb452e132a51d6e9aaecabfedb90406827 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Mon, 2 May 2011 14:36:10 +0200 Subject: [PATCH 03/34] Unified infra Workspace with Cloud9 workspace. Infra workspace now inherits from cloud9 workspace and does minimal work. --- server/cloud9/ext/debugger/debugger.js | 14 ++--- server/cloud9/ide.js | 4 +- server/cloud9/workspace.js | 77 +++++++++++++++----------- 3 files changed, 52 insertions(+), 43 deletions(-) diff --git a/server/cloud9/ext/debugger/debugger.js b/server/cloud9/ext/debugger/debugger.js index 97515aa6bd9..bcbfc32011a 100644 --- a/server/cloud9/ext/debugger/debugger.js +++ b/server/cloud9/ext/debugger/debugger.js @@ -17,19 +17,17 @@ var DebuggerPlugin = module.exports = function(ide, workspace) { this.hooks = ["command"]; this.name = "debugger"; this.nodeCmd = process.argv[0]; + + var _self = this; + this.workspace.getExt("state").on("statechange", function(state) { + state.debugClient = !!_self.debugClient; + state.processRunning = !!_self.child; + }); }; sys.inherits(DebuggerPlugin, Plugin); (function() { - this.init = function() { - var _self = this; - this.workspace.getExt("state").on("statechange", function(state) { - state.debugClient = !!_self.debugClient; - state.processRunning = !!_self.child; - }); - }; - this.NODE_DEBUG_PORT = 5858; this.CHROME_DEBUG_PORT = 9222; diff --git a/server/cloud9/ide.js b/server/cloud9/ide.js index 8837ae505e2..c39175696ef 100644 --- a/server/cloud9/ide.js +++ b/server/cloud9/ide.js @@ -57,7 +57,7 @@ module.exports = Ide = function(options, httpServer, exts, socket) { this.davServer = jsDAV.mount(this.options.mountDir, this.options.davPrefix, this.httpServer, false); this.davInited = false; - this.workspace = new Workspace(this); + this.workspace = new Workspace({ ide: this }); this.workspace.createPlugins(exts); var statePlugin = this.workspace.getExt("state"); @@ -279,7 +279,7 @@ Ide.DEFAULT_PLUGINS = [ this.sendToUser = function(username, msg) { this.$users[username] && this.$users[username].broadcast(msg); - } + }; this.dispose = function(callback) { this.workspace.dispose(callback); diff --git a/server/cloud9/workspace.js b/server/cloud9/workspace.js index 20ee763b7e4..a8181740a87 100644 --- a/server/cloud9/workspace.js +++ b/server/cloud9/workspace.js @@ -1,46 +1,53 @@ var lang = require("pilot/lang"); - -var Workspace = module.exports = function(ide) { - this.ide = ide; - this.workspaceId = ide.options.workspaceId; - this.workspaceDir = ide.options.workspaceDir; + +var Workspace = module.exports = function(config) { + if (config) + for (var prop in config) + this[prop] = config[prop]; + else + throw new Error("No parameters were passed to Workspace."); + + this.init(); }; (function() { + this.init = function() { + this.workspaceId = this.ide.options.workspaceId; + this.workspaceDir = this.ide.options.workspaceDir; + }; + this.createPlugins = function (plugins) { - var exts = this.exts = {}; + this.plugins = {}; for (var name in plugins) { - exts[name] = new plugins[name](this.ide, this); - } - for (name in exts) { - if (exts[name].init) - exts[name].init(); + this.plugins[name] = new plugins[name](this.ide, this); } }; + this.getServerExclude = function() { + return lang.arrayToMap(user.getPermissions().server_exclude.split("|")); + }; + this.execHook = function(hook, user /* varargs */) { - var ext, hooks, - args = Array.prototype.slice.call(arguments, 1), - hook = hook.toLowerCase().replace(/^[\s]+/, "").replace(/[\s]+$/, ""); + var plugin, hooks; + var args = Array.prototype.slice.call(arguments, 1); + var hook = hook.toLowerCase().trim(); - var server_exclude = lang.arrayToMap(user.getPermissions().server_exclude.split("|")); + var server_exclude = this.getServerExclude(); - for (var name in this.exts) { - if (server_exclude[name]) { - continue; - } + for (var name in this.plugins) { + if (server_exclude[name]) continue; - ext = this.exts[name]; - hooks = ext.getHooks(); - if (hooks.indexOf(hook) > -1 && ext[hook].apply(ext, args) === true) { + plugin = this.plugins[name]; + hooks = plugin.getHooks(); + if (hooks.indexOf(hook) > -1 && plugin[hook].apply(plugin, args) === true) { return; } } }; this.getExt = function(name) { - return this.exts[name] || null; + return this.plugins[name] || null; }; this.send = function(msg, replyTo, scope) { @@ -49,6 +56,13 @@ var Workspace = module.exports = function(ide) { this.ide.broadcast(JSON.stringify(msg), scope); }; + this.sendError = function(error, client) { + if (client) + client.send(JSON.stringify(error)); + else + this.broadcast(error); + }; + this.error = function(description, code, message, client) { var sid = (message || {}).sid || -1; var error = { @@ -57,20 +71,17 @@ var Workspace = module.exports = function(ide) { "code": code, "message": description }; - - if (client) - client.send(JSON.stringify(error)); - else - this.broadcast(error); + + this.sendError(error, client || null); }; this.dispose = function(callback) { var count; - for (var name in this.exts) { - count++; - var ext = this.exts[name]; - ext.dispose(function() { - count--; + for (var name in this.plugins) { + count += 1; + var plugin = this.plugins[name]; + plugin.dispose(function() { + count -= 1; if (count == 0) callback(); }); From 1fb3c9eedcd45f7e4f17f1d446b68ee6d3c1d3b0 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Mon, 2 May 2011 14:45:46 +0200 Subject: [PATCH 04/34] Fixed bug where `user` was not passed when getting excluded plugins. --- server/cloud9/workspace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/cloud9/workspace.js b/server/cloud9/workspace.js index a8181740a87..bf2ca0593c9 100644 --- a/server/cloud9/workspace.js +++ b/server/cloud9/workspace.js @@ -24,7 +24,7 @@ var Workspace = module.exports = function(config) { } }; - this.getServerExclude = function() { + this.getServerExclude = function(user) { return lang.arrayToMap(user.getPermissions().server_exclude.split("|")); }; @@ -33,7 +33,7 @@ var Workspace = module.exports = function(config) { var args = Array.prototype.slice.call(arguments, 1); var hook = hook.toLowerCase().trim(); - var server_exclude = this.getServerExclude(); + var server_exclude = this.getServerExclude(user); for (var name in this.plugins) { if (server_exclude[name]) continue; From f9dbdac26c8870cb42f7ed8c057b178505a96ffe Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Mon, 2 May 2011 17:21:12 +0200 Subject: [PATCH 05/34] Adapted `Plugin` to handle infra `sendResult` cases. Part of plugin unification. --- server/cloud9/plugin.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/server/cloud9/plugin.js b/server/cloud9/plugin.js index b27ee216923..26f36bee3a0 100644 --- a/server/cloud9/plugin.js +++ b/server/cloud9/plugin.js @@ -20,12 +20,20 @@ sys.inherits(Plugin, events.EventEmitter); }; this.sendResult = function(sid, type, msg) { - this.ide.broadcast(JSON.stringify({ + var error = { type : "result", subtype: type || "error", sid : sid || 0, body : msg || "Access denied." - }), this.name); + }; + + // We check for the ide variable in order to know if we are in a cloud9 + // plugin or in a infra plugin. Pretty nasty, but it will hopefully go + // away soon. + if (this.ide) + this.ide.broadcast(JSON.stringify(error), this.name); + else + this.send(error); }; this.error = function(description, code, message, client) { @@ -35,12 +43,16 @@ sys.inherits(Plugin, events.EventEmitter); this.send = function(msg, replyTo, scope) { this.workspace.send(msg, replyTo, scope); }; - + this.spawnCommand = function(cmd, args, cwd, onerror, ondata, onexit) { - var child = this.activePs = Spawn(cmd, args || [], {cwd: cwd || this.server.workspaceDir}), - out = "", - err = "", - _self = this; + var child = this.activePs = Spawn(cmd, args || [], { + cwd: cwd || this.server.workspaceDir + }); + + var out = ""; + var err = ""; + var _self = this; + child.stdout.on("data", sender("stdout")); child.stderr.on("data", sender("stderr")); @@ -50,8 +62,7 @@ sys.inherits(Plugin, events.EventEmitter); if (stream == "stderr") { err += s; onerror && onerror(s); - } - else { + } else { out += s; ondata && ondata(s); } From 99e06869868ce9590642f0e65650ec566dc46e9c Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Tue, 3 May 2011 10:30:33 +0200 Subject: [PATCH 06/34] The path to asyncjs was borked --- support/paths.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/support/paths.js b/support/paths.js index 9fa0bcbebfd..10e6c4bd9ac 100644 --- a/support/paths.js +++ b/support/paths.js @@ -2,12 +2,12 @@ * @copyright 2010, Ajax.org B.V. * @license GPLv3 */ - + require("./requireJS-node"); require.paths.unshift(__dirname + "/../server"); require.paths.unshift(__dirname + "/connect/lib"); -require.paths.unshift(__dirname + "/async/lib"); +require.paths.unshift(__dirname + "/asyncjs/lib"); require.paths.unshift(__dirname + "/jsdav/lib"); require.paths.unshift(__dirname + "/socket.io/lib"); require.paths.unshift(__dirname + "/ace/lib"); @@ -16,4 +16,4 @@ require.paths.unshift(__dirname + "/lib-v8debug/lib"); require.paths.unshift(__dirname); require.paths.unshift(__dirname + "/../demo/plugin"); -require.paths.unshift(__dirname + "/../demo/template"); \ No newline at end of file +require.paths.unshift(__dirname + "/../demo/template"); From 9888d00f5ea4d67892b6999f6f9e936fee51cf78 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Tue, 3 May 2011 10:35:08 +0200 Subject: [PATCH 07/34] Fixed previous commit --- support/paths.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/paths.js b/support/paths.js index 10e6c4bd9ac..888a52c5e00 100644 --- a/support/paths.js +++ b/support/paths.js @@ -7,7 +7,7 @@ require("./requireJS-node"); require.paths.unshift(__dirname + "/../server"); require.paths.unshift(__dirname + "/connect/lib"); -require.paths.unshift(__dirname + "/asyncjs/lib"); +require.paths.unshift(__dirname + "/async/lib/asyncjs"); require.paths.unshift(__dirname + "/jsdav/lib"); require.paths.unshift(__dirname + "/socket.io/lib"); require.paths.unshift(__dirname + "/ace/lib"); From 8437d974f7c021774c257524abf812bc8f9d7f41 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Tue, 3 May 2011 10:47:46 +0200 Subject: [PATCH 08/34] Renamed async folder From c731111132d9b35f9ad6467d8dd142f8f2978897 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Tue, 3 May 2011 11:01:58 +0200 Subject: [PATCH 09/34] Added asyncjs again --- .gitmodules | 3 +++ support/async | 1 + 2 files changed, 4 insertions(+) create mode 160000 support/async diff --git a/.gitmodules b/.gitmodules index aae3c2aa764..ee118ba6005 100644 --- a/.gitmodules +++ b/.gitmodules @@ -25,3 +25,6 @@ [submodule "support/gnu-builds"] path = support/gnu-builds url = git://github.com/ajaxorg/gnu-builds.git +[submodule "support/async"] + path = support/async + url = git@github.com:ajaxorg/async.js.git diff --git a/support/async b/support/async new file mode 160000 index 00000000000..d36ead408e2 --- /dev/null +++ b/support/async @@ -0,0 +1 @@ +Subproject commit d36ead408e2959b1e99572114ef3a1b6a48c1072 From bbfcddce548ee22d84a1907c8c892436a41e205a Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Tue, 3 May 2011 11:15:25 +0200 Subject: [PATCH 10/34] Deleted previous asyncjs refernce in gitmodules. Restored paths (once again). --- .gitmodules | 3 --- support/paths.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index ee118ba6005..a488e824751 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,9 +4,6 @@ [submodule "support/connect"] path = support/connect url = http://github.com/senchalabs/connect.git -[submodule "support/asyncjs"] - path = support/asyncjs - url = http://github.com/ajaxorg/async.js.git [submodule "support/jsdav"] path = support/jsdav url = http://github.com/ajaxorg/jsDAV.git diff --git a/support/paths.js b/support/paths.js index 888a52c5e00..d393371df86 100644 --- a/support/paths.js +++ b/support/paths.js @@ -7,7 +7,7 @@ require("./requireJS-node"); require.paths.unshift(__dirname + "/../server"); require.paths.unshift(__dirname + "/connect/lib"); -require.paths.unshift(__dirname + "/async/lib/asyncjs"); +require.paths.unshift(__dirname + "/async/lib/"); require.paths.unshift(__dirname + "/jsdav/lib"); require.paths.unshift(__dirname + "/socket.io/lib"); require.paths.unshift(__dirname + "/ace/lib"); From 42c4af5d69fa1d6f003fd97cc9b18239a0cd275b Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Fri, 20 May 2011 15:23:56 +0200 Subject: [PATCH 11/34] ace --- support/ace | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/ace b/support/ace index bc027e927ac..6de1e4f5f50 160000 --- a/support/ace +++ b/support/ace @@ -1 +1 @@ -Subproject commit bc027e927ac64fcb918bf6e37feab0ed80776e6b +Subproject commit 6de1e4f5f50f86654cd63a81279cf4efc279c80b From 802597fc35f9c865f7de87006926821beceea93a Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 23 May 2011 11:02:28 +0200 Subject: [PATCH 12/34] ace --- support/ace | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/ace b/support/ace index 6de1e4f5f50..e3ccca36636 160000 --- a/support/ace +++ b/support/ace @@ -1 +1 @@ -Subproject commit 6de1e4f5f50f86654cd63a81279cf4efc279c80b +Subproject commit e3ccca3663648a21074ccf100dad4e557d4e64a9 From 4f08c3212b37f7e3344b3013e15945041358b65f Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 23 May 2011 16:21:32 +0200 Subject: [PATCH 13/34] jsdav --- support/jsdav | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/jsdav b/support/jsdav index 5b4141557ec..50a847b42ab 160000 --- a/support/jsdav +++ b/support/jsdav @@ -1 +1 @@ -Subproject commit 5b4141557ec9df2e5e38d6f840a414f23fe73383 +Subproject commit 50a847b42abde8070418ac7039ae3133daaf8a2e From c80c00af52abcfd5b05a403f08c6d55e5d470308 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 23 May 2011 18:01:19 +0200 Subject: [PATCH 14/34] jsdav --- support/jsdav | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/jsdav b/support/jsdav index 50a847b42ab..76a0dcc3bdb 160000 --- a/support/jsdav +++ b/support/jsdav @@ -1 +1 @@ -Subproject commit 50a847b42abde8070418ac7039ae3133daaf8a2e +Subproject commit 76a0dcc3bdb76eed83e6d569e157c20689526a1a From 75c404f4970c0e752e4eb87c1842524019de7dc1 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 23 May 2011 18:01:53 +0200 Subject: [PATCH 15/34] add option to mount a sftp directory --- server/cloud9/ide.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server/cloud9/ide.js b/server/cloud9/ide.js index 9432b19be15..236370e3ef3 100644 --- a/server/cloud9/ide.js +++ b/server/cloud9/ide.js @@ -13,7 +13,8 @@ var jsDAV = require("jsdav"), Url = require("url"), template = require("./template"), Workspace = require("cloud9/workspace"), - EventEmitter = require("events").EventEmitter; + EventEmitter = require("events").EventEmitter, + util = require("./util"); module.exports = Ide = function(options, httpServer, exts, socket) { EventEmitter.call(this); @@ -49,12 +50,23 @@ module.exports = Ide = function(options, httpServer, exts, socket) { offlineManifest: options.offlineManifest || "", projectName: options.projectName || this.workspaceDir.split("/").pop(), version: options.version, - extra: options.extra + extra: options.extra, + remote: options.remote }; this.$users = {}; - this.davServer = jsDAV.mount(this.options.mountDir, this.options.davPrefix, this.httpServer, false); + var davOptions = { + mount: this.options.davPrefix, + server: this.httpServer, + standalone: false + }; + if (options.remote) + util.extend(davOptions, options.remote); + else + davOptions.path = this.options.mountDir; + + this.davServer = jsDAV.mount(davOptions); this.davInited = false; this.workspace = new Workspace({ ide: this }); From 4f5f882bd7fa03d901ba15ff048cec0bd83b14d6 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 23 May 2011 18:02:38 +0200 Subject: [PATCH 16/34] ace --- support/ace | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/ace b/support/ace index e3ccca36636..9e021d21d91 160000 --- a/support/ace +++ b/support/ace @@ -1 +1 @@ -Subproject commit e3ccca3663648a21074ccf100dad4e557d4e64a9 +Subproject commit 9e021d21d919b2b5ba4baaa67a2b9f01cd427f80 From 39a52c8041ddeafadb60cea2baba790f1fe6eea1 Mon Sep 17 00:00:00 2001 From: mikedeboer Date: Mon, 20 Jun 2011 15:23:00 +0200 Subject: [PATCH 17/34] updated submodules --- support/ace | 2 +- support/jsdav | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/support/ace b/support/ace index 63835b240d0..eb6bcf5fa0c 160000 --- a/support/ace +++ b/support/ace @@ -1 +1 @@ -Subproject commit 63835b240d020ff0c4db659fd72e54cfb688565f +Subproject commit eb6bcf5fa0c59b80e02535815700e20967c9b851 diff --git a/support/jsdav b/support/jsdav index a6cc73351f2..2471d0a2f83 160000 --- a/support/jsdav +++ b/support/jsdav @@ -1 +1 @@ -Subproject commit a6cc73351f2baf9dca1919d8040011e3b483871f +Subproject commit 2471d0a2f83481a2cc75fb3b555151ead974e4d4 From 601c9d7c763d574c6f02259a8ea3528a1a7c1460 Mon Sep 17 00:00:00 2001 From: Sergi Mansilla Date: Tue, 21 Jun 2011 12:44:48 +0200 Subject: [PATCH 18/34] Added jsdav revision previous to node-ftp submodule --- support/jsdav | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/jsdav b/support/jsdav index 2471d0a2f83..0a6336863ca 160000 --- a/support/jsdav +++ b/support/jsdav @@ -1 +1 @@ -Subproject commit 2471d0a2f83481a2cc75fb3b555151ead974e4d4 +Subproject commit 0a6336863caf757dc95f394400386d152698c577 From 32db963a6c789377c5763f816ad909eab0fd828a Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Tue, 21 Jun 2011 13:32:03 +0200 Subject: [PATCH 19/34] fix client side hg plugin --- server/cloud9/ext/hg/{index.js => hg.js} | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename server/cloud9/ext/hg/{index.js => hg.js} (90%) diff --git a/server/cloud9/ext/hg/index.js b/server/cloud9/ext/hg/hg.js similarity index 90% rename from server/cloud9/ext/hg/index.js rename to server/cloud9/ext/hg/hg.js index 6269d31e0b7..37aed0c86f1 100644 --- a/server/cloud9/ext/hg/index.js +++ b/server/cloud9/ext/hg/hg.js @@ -7,8 +7,8 @@ var Plugin = require("cloud9/plugin"); var sys = require("sys"); -var ShellHgPlugin = module.exports = function(ide) { - this.ide = ide; +var ShellHgPlugin = module.exports = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "hg"; this.banned = ["serve"]; @@ -17,14 +17,14 @@ var ShellHgPlugin = module.exports = function(ide) { sys.inherits(ShellHgPlugin, Plugin); (function() { - var hghelp = "", - commandsMap = { - "default": { - "commands": { - "[PATH]": {"hint": "path pointing to a folder or file. Autocomplete with [TAB]"} - } + var hghelp = ""; + var commandsMap = { + "default": { + "commands": { + "[PATH]": {"hint": "path pointing to a folder or file. Autocomplete with [TAB]"} } - }; + } + }; this.$commandHints = function(commands, message, callback) { var _self = this; From f34f203968d369eb8d88253d2fdc014b3deb9bf3 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 22 Jun 2011 13:26:03 +0200 Subject: [PATCH 20/34] minor fix --- server/cloud9/workspace.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/cloud9/workspace.js b/server/cloud9/workspace.js index bf2ca0593c9..c9949f07bbc 100644 --- a/server/cloud9/workspace.js +++ b/server/cloud9/workspace.js @@ -60,7 +60,7 @@ var Workspace = module.exports = function(config) { if (client) client.send(JSON.stringify(error)); else - this.broadcast(error); + this.ide.broadcast(error); }; this.error = function(description, code, message, client) { @@ -88,4 +88,4 @@ var Workspace = module.exports = function(config) { } }; -}).call(Workspace.prototype); +}).call(Workspace.prototype); \ No newline at end of file From 53f3a8dd4d0fd0f4f02e17524b2ccdb94a8e83e3 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 22 Jun 2011 13:26:15 +0200 Subject: [PATCH 21/34] update submodules --- support/apf | 2 +- support/jsdav | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/support/apf b/support/apf index 52f8e185f6f..0a6bcd92aaa 160000 --- a/support/apf +++ b/support/apf @@ -1 +1 @@ -Subproject commit 52f8e185f6f267e0aaeb08ef0c3bc1a4f573d494 +Subproject commit 0a6bcd92aaa10ef05b6d3b348b451d81a670d228 diff --git a/support/jsdav b/support/jsdav index 0a6336863ca..1d8a95404f3 160000 --- a/support/jsdav +++ b/support/jsdav @@ -1 +1 @@ -Subproject commit 0a6336863caf757dc95f394400386d152698c577 +Subproject commit 1d8a95404f3bb8bfd04978858d54caa2bc682f74 From 8c06cb51703093535a1db670d53cc01e5e3e5491 Mon Sep 17 00:00:00 2001 From: Luis Merino Date: Wed, 22 Jun 2011 15:06:57 +0200 Subject: [PATCH 22/34] [BACKLOG-1074] readonly for loading files; also added icon to tab --- client/ext/editors/editors.js | 6 ++++-- .../style/images/load-indicator-active-tab.gif | Bin 0 -> 1455 bytes .../style/images/load-indicator-inactive-tab.gif | Bin 0 -> 1458 bytes client/style/skins.xml | 8 ++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 client/style/images/load-indicator-active-tab.gif create mode 100644 client/style/images/load-indicator-inactive-tab.gif diff --git a/client/ext/editors/editors.js b/client/ext/editors/editors.js index 38fa47c320f..754606af1fc 100644 --- a/client/ext/editors/editors.js +++ b/client/ext/editors/editors.js @@ -225,8 +225,10 @@ return ext.register("ext/editors/editors", { page.$doc = doc; page.$editor = editor; page.setAttribute("tooltip", "[@path]"); - page.setAttribute("class", "{(parseInt([@saving]) ? (tabEditors.getPage(tabEditors.activepage) == this ? 'saving_active' : 'saving') : '')}"); - + page.setAttribute("class", + "{parseInt([@saving]) ? (tabEditors.getPage(tabEditors.activepage) == this ? 'saving_active' : 'saving') : \ + ([@loading] ? (tabEditors.getPage(tabEditors.activepage) == this ? 'loading_active' : 'loading') : '')}" + ); page.setAttribute("model", page.$model = model); page.$model.load(xmlNode); }); diff --git a/client/style/images/load-indicator-active-tab.gif b/client/style/images/load-indicator-active-tab.gif new file mode 100644 index 0000000000000000000000000000000000000000..097ae207656991d601ac11df30559fb0b15e52ef GIT binary patch literal 1455 zcmZ?wbhEHbWM$xFIKsd%Z(qm4gWcc1f8TRq-Q~My-@biwJk0`%j-f9k{aj^OsLuTXR2t`mpEx`VSvInA9_U`SRu6yLT^N zzU<#o{NlxnH*ekqPE`B+`Lp7GZa>$MU}whwS0gl#hD=EpgRdNJLD1hvA&M!(;Fx4~A zO*SwyP%typGc-0aH#gT&FfuSS&^IvBH#E{UG`BJ~vNAAGfC43;ZAB?*RzWUqP`iLU zTcwPWk^(Dz{qpj1y>er{{GxPyLrY6bkQqisxGJi(uOl}XuDZA+C>7y&tmYSoR2HP_2c;J0mlh?b0+lNxS%u#skV2>*tb7xTvQvSv z=$4pMoC=ok^|kT`IzBTmF~=o8ximL5uf)^ERtcy@FC{a@%D~XVz|hd##K7Fhz|6uB z$g?oEFgG{0Fm<(bv^2GVnSo8Oqm!wjnW3|>rJ;qZp`ojRg{6hDv!$`Ip_#dhrMZbQ zOs{8NaYryA&s6{iyj3O^``rvp%nVIT&76?@ZE56WVd&^+Vq$3E zq6F2OLQa_J10ACeN^3}I4<-am&>$u}CjmL|yqKB?jJhIVPGkK4@9&@AzkdGs{_X3R z&!0Yic>nJ0o7b;izIguZ>66Eg9zM8#@9v%3w{G6Je(ma&%a<-*IDhW!nbW6Eo;ZH& z=#j&R4j$OQZ||PnyLRr_zHRH4&6_rESif%Vn$@dTu2{Zo>5|2Z7A}}SZ|F(<6Xm4w6X>Mw4sIRN7sjjN5C@(85DK083$j{5o$m zNlr>kh>weniH?el2oDPl2@VPj@b~le@%HlcaCdWcadvWau(z|dv9_|bFgG(bF*X9` zay?xgZ7od=bv0ELWhF%gc{y1bX(>qwaWPR5VIe^Qem-6vZZ1v^b~aWPW+q^HrTCMD zMF?1I=>RbUsMKU&ReYe{<(43I;h;=Fn}x@<(hD(_6{)$`(+a0>wjREyVlqbnSr;Qv x7Yk4qf5MYq!ELe9(>y0nDV@vEj;w|iszyM8v8Tnzr1_Aj_rbzjiwhMQtN~347w7;0 literal 0 HcmV?d00001 diff --git a/client/style/images/load-indicator-inactive-tab.gif b/client/style/images/load-indicator-inactive-tab.gif new file mode 100644 index 0000000000000000000000000000000000000000..8c24a4febf80fb4122950ff4d680d9e53719c0f3 GIT binary patch literal 1458 zcmbVMX>=1+6iy`-E24-yE=;G2Ta#InS=zKsGD(xtDQyx8)RuNK8IrM`nRI5_q*ZZ2 zs}v9v6mj1W+*jOC5v_u_YrzH7y5TO13*v@vYE%28r$3x?=FGcqzVCkbzIX4f3SE!4JO3N#vO;Ma6F`TRwLS+@cmi7iO7p(9F>cmha5l;5h$L7YOjnT@g zYOOa;Qf?PTm3Yc~Ha0iT50;iy_=8o=={deYxS^X1hN~;9_?25a1EJ}K2PV`6Vo|@h zHh??Pad|eI4Q$QkYavcB1@J8`&!z>jRWhNtl$2Euyledi7?Kknc$SMt`Lth3$)Rpt zigwq;#O_v+Nx!~WMWPgrx@inpG(l4oLAwHsmvPZKAER-J0LgF+0Ah3i!vZMH(1f2M2+U1!3`G(- zZdf%;K^3K(t_*aCxZIdr)~`!~sp&CIYs(c>ZAvpWBc-Jwf7Au>f+(w&ZQVA=31rJj zy4)!xg1V+ag9p#bqv!`Q(v6WWw{Jw=4DO>bua_h-l!J%3iT`tE2nYtTYHdXA<+eaU zTg%~20>*GJN-DTI9dugWfxrLy^N-*6|F-YfUw-~+@1EVee*EG4@4o%!>#ufx`Nij- zeLC>T#~E)ODUVLHW^BbOf_L=ohKlS7j zkFR^|(MKMB=)ni>zwh3A?q0j*uGM$mard(DdFS6{Vk>6J?s zFX~-*#pOMhUAo|si!Zux{srfs*WH!Pbat4A-k#P}rLFZ`IhC9zCB(SU(mc1R@tlS^ zvuD-Mj71}LwKHn?>giSCP-QT{`F-As@-k0p3Cqx6Vvz(6y4>j~KKraQ&p3VBX{Q#! zh0xSfPCn_xDJL9%+_A?TebnS5CmnJ4#KR^WT5!ntgY)g<4g&M4aKGI?8H}xB@Y<}Y zY0EDf*yL^6$E{s%=a-q|4Rc3k;i@&s{(5D_(mr^93zqXklFjR8 mZr{pp>u;aBr@e3_C_e`puq|E?Cwul5EZQwhSuGUWO8x=0rtf+H literal 0 HcmV?d00001 diff --git a/client/style/skins.xml b/client/style/skins.xml index abe049e6234..a42d54ce172 100644 --- a/client/style/skins.xml +++ b/client/style/skins.xml @@ -5770,6 +5770,14 @@ .editor_tab .btnsesssioncontainer .saving .sessiontab_icon { background-image: url(images/save-indicator-inactive-tab.gif); } + + .editor_tab .btnsesssioncontainer .loading_active .sessiontab_icon { + background-image: url(images/load-indicator-active-tab.gif); + } + + .editor_tab .btnsesssioncontainer .loading .sessiontab_icon { + background-image: url(images/load-indicator-inactive-tab.gif); + } .editor_tab .btnsesssioncontainer .session_btn .tab_middle .sessiontab_title { overflow : hidden; From 7f2cd4d54508559ad1d155217a56ddb7a0d804f5 Mon Sep 17 00:00:00 2001 From: Luis Merino Date: Wed, 22 Jun 2011 14:25:12 +0200 Subject: [PATCH 23/34] Added loading attribute to editor to save the gap between file open and after file open --- client/ext/code/code.xml | 2 +- client/ext/filesystem/filesystem.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/client/ext/code/code.xml b/client/ext/code/code.xml index 0b97939ecfd..d29406185cd 100644 --- a/client/ext/code/code.xml +++ b/client/ext/code/code.xml @@ -25,7 +25,7 @@ contextmenu = "mnuCtxEditor" debugger = "{this.syntax == 'javascript' ? dbg : null}" - readonly = "{cloud9config.readonly or (location.host and stDebugProcessRunning.active and [@scriptid])}" + readonly = "{[@loading] or cloud9config.readonly or (location.host and stDebugProcessRunning.active and [@scriptid])}" /> diff --git a/client/ext/filesystem/filesystem.js b/client/ext/filesystem/filesystem.js index cf16106556e..ce7ddde9b93 100644 --- a/client/ext/filesystem/filesystem.js +++ b/client/ext/filesystem/filesystem.js @@ -297,6 +297,13 @@ return ext.register("ext/filesystem/filesystem", { var doc = e.doc; var node = doc.getNode(); + apf.xmldb.setAttribute(node, "loading", "true"); + console.log('node', node); + ide.addEventListener("afteropenfile", function(e) { + apf.xmldb.setAttribute(e.node, "loading", ""); + console.log('internal node', e.node); + }); + if (doc.hasValue()) { ide.dispatchEvent("afteropenfile", {doc: doc, node: node}); return; From 6f57b140c7363e43a2a41ff9d23c408f34facb4d Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 22 Jun 2011 18:06:07 +0200 Subject: [PATCH 24/34] add node-ssh to the search path --- support/paths.js | 1 + 1 file changed, 1 insertion(+) diff --git a/support/paths.js b/support/paths.js index 9769ea3e580..8455ca3ad8d 100644 --- a/support/paths.js +++ b/support/paths.js @@ -9,6 +9,7 @@ require.paths.unshift(__dirname + "/../server"); require.paths.unshift(__dirname + "/connect/lib"); require.paths.unshift(__dirname + "/asyncjs/lib"); require.paths.unshift(__dirname + "/jsdav/lib"); +require.paths.unshift(__dirname + "/jsdav/support"); require.paths.unshift(__dirname + "/jsdav/support/node-ftp"); require.paths.unshift(__dirname + "/jsdav/support/node-sftp/lib"); require.paths.unshift(__dirname + "/socket.io/lib"); From ddf90817a7c15959c8b94ad987acc23577d8c222 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 23 Jun 2011 13:42:45 +0200 Subject: [PATCH 25/34] move run state handling to the noderunner plugin --- client/core/ide.js | 13 ++++--------- client/ext/noderunner/noderunner.js | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/client/core/ide.js b/client/core/ide.js index 873aa0f7531..7b8985d4751 100644 --- a/client/core/ide.js +++ b/client/core/ide.js @@ -157,12 +157,6 @@ define(function(require, exports, module) { }); }; - //@todo see if this can be moved to noderunner - ide.addEventListener("socketMessage", function(e){ - if (e.message.type && e.message.type == "state") - stProcessRunning.setProperty("active", e.message.processRunning); - }); - // for unknown reasons io is sometimes undefined try { ide.socket = new io.Socket(null, options); @@ -175,10 +169,11 @@ define(function(require, exports, module) { } ); - var socketIoScriptEl = Array.prototype.slice.call(document.getElementsByTagName("script")) - .filter(function(script) { + var socketIoScriptEl = Array.prototype.slice.call( + document.getElementsByTagName("script")).filter(function(script) { return script.src && script.src.indexOf("socket.io.js") >= 0; - })[0]; + } + )[0]; if (socketIoScriptEl) { apf.ajax(socketIoScriptEl.src, { diff --git a/client/ext/noderunner/noderunner.js b/client/ext/noderunner/noderunner.js index 64fd2107f34..5899018f4cd 100644 --- a/client/ext/noderunner/noderunner.js +++ b/client/ext/noderunner/noderunner.js @@ -80,6 +80,7 @@ return ext.register("ext/noderunner/noderunner", { case "state": stDebugProcessRunning.setProperty("active", message.debugClient); + stProcessRunning.setProperty("active", e.message.processRunning); dbgNode.setProperty("strip", message.workspaceDir + "/"); ide.dispatchEvent("noderunnerready"); break; From 1db1c0f1bbf494543d54d0b2dce7294e18c9603c Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Thu, 23 Jun 2011 13:45:59 +0200 Subject: [PATCH 26/34] remove log messages --- client/ext/filesystem/filesystem.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/ext/filesystem/filesystem.js b/client/ext/filesystem/filesystem.js index ce7ddde9b93..6f1347c5694 100644 --- a/client/ext/filesystem/filesystem.js +++ b/client/ext/filesystem/filesystem.js @@ -298,10 +298,8 @@ return ext.register("ext/filesystem/filesystem", { var node = doc.getNode(); apf.xmldb.setAttribute(node, "loading", "true"); - console.log('node', node); ide.addEventListener("afteropenfile", function(e) { apf.xmldb.setAttribute(e.node, "loading", ""); - console.log('internal node', e.node); }); if (doc.hasValue()) { From 60aeff1682dddfd43e4698c4a245e3297d731d8c Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 27 Jun 2011 10:30:20 +0200 Subject: [PATCH 27/34] fix blame plugin --- server/cloud9/ext/blame/{index.js => blame.js} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename server/cloud9/ext/blame/{index.js => blame.js} (96%) diff --git a/server/cloud9/ext/blame/index.js b/server/cloud9/ext/blame/blame.js similarity index 96% rename from server/cloud9/ext/blame/index.js rename to server/cloud9/ext/blame/blame.js index cab44667462..83a5a3c5e4d 100644 --- a/server/cloud9/ext/blame/index.js +++ b/server/cloud9/ext/blame/blame.js @@ -8,8 +8,8 @@ var Plugin = require("cloud9/plugin"); var Fs = require("fs"); var sys = require("sys"); -var BlamePlugin = module.exports = function(ide) { - this.ide = ide; +var BlamePlugin = module.exports = function(ide, workspace) { + Plugin.call(this, ide, workspace); this.hooks = ["command"]; this.name = "blame"; }; From 0f1b48900ad2f6bb625f30826dfd3c5866d4a25b Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 27 Jun 2011 10:43:46 +0200 Subject: [PATCH 28/34] move debugger buttons into the debugger plugin --- client/core/ext.js | 2 +- client/ext/debugger/debugger.js | 19 ++++++++++++ client/ext/debugger/debugger.xml | 43 ++++++++++++++++++++++++++++ client/ext/noderunner/noderunner.xml | 40 +++++++++++++------------- client/ext/run/run.js | 11 ++----- client/ext/run/run.xml | 41 ++------------------------ 6 files changed, 88 insertions(+), 68 deletions(-) diff --git a/client/core/ext.js b/client/core/ext.js index 645b2f81dae..c29eb6804a8 100644 --- a/client/core/ext.js +++ b/client/core/ext.js @@ -143,7 +143,7 @@ return ext = { } }, - initExtension : function(oExtension, amlParent){ + initExtension : function(oExtension, amlParent) { if (oExtension.inited) return; diff --git a/client/ext/debugger/debugger.js b/client/ext/debugger/debugger.js index bca42ed1188..fa0ec9992e3 100644 --- a/client/ext/debugger/debugger.js +++ b/client/ext/debugger/debugger.js @@ -35,6 +35,7 @@ return ext.register("ext/debugger/debugger", { }, nodes : [], + hotitems: {}, hook : function(){ ide.addEventListener("consolecommand.debug", function(e) { @@ -111,10 +112,28 @@ return ext.register("ext/debugger/debugger", { activeState: { x: -6, y: -360 } } }); + ext.initExtension(this); }, init : function(amlNode){ var _self = this; + + while(tbDebug.childNodes.length) { + var button = tbDebug.firstChild; + + if (button.nodeType == 1 && button.getAttribute("id") == "btnDebug") + ide.barTools.insertBefore(button, btnRun); + else + ide.barTools.appendChild(button); + if (button.nodeType == 1) { + this.nodes.push(button); + } + } + + this.hotitems["resume"] = [btnResume]; + this.hotitems["stepinto"] = [btnStepInto]; + this.hotitems["stepover"] = [btnStepOver]; + this.hotitems["stepout"] = [btnStepOut]; this.paths = {}; diff --git a/client/ext/debugger/debugger.xml b/client/ext/debugger/debugger.xml index 6013bb4f6a7..74bd01e328d 100644 --- a/client/ext/debugger/debugger.xml +++ b/client/ext/debugger/debugger.xml @@ -1,4 +1,47 @@ + + + + + + + + + + + + + + - - - OK - - - + + + OK + + + \ No newline at end of file diff --git a/client/ext/run/run.js b/client/ext/run/run.js index 46f25669030..19bb257b5e3 100644 --- a/client/ext/run/run.js +++ b/client/ext/run/run.js @@ -28,24 +28,19 @@ return ext.register("ext/run/run", { "stepover" : {hint: "step over the current expression on the execution stack"}, "stepout" : {hint: "step out of the current function scope"} }, - hotitems: {}, nodes : [], init : function(amlNode){ while(tbRun.childNodes.length) { var button = tbRun.firstChild; - ide.barTools.appendChild(button); - if (button.nodeType == 1) + ide.barTools.appendChild(button); + if (button.nodeType == 1) { this.nodes.push(button); + } } - this.hotitems["resume"] = [btnResume]; - this.hotitems["stepinto"] = [btnStepInto]; - this.hotitems["stepover"] = [btnStepOver]; - this.hotitems["stepout"] = [btnStepOut]; - var _self = this; mdlRunConfigurations.addEventListener("afterload", function(e) { _self.$updateMenu(); diff --git a/client/ext/run/run.xml b/client/ext/run/run.xml index 33956b6ddb6..07664cf0c75 100644 --- a/client/ext/run/run.xml +++ b/client/ext/run/run.xml @@ -86,18 +86,8 @@ - - - - - - - - - - + \ No newline at end of file From 27f5a9fdb25c2a3d5a862c8e43ed6e9238cbcee3 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 27 Jun 2011 10:44:16 +0200 Subject: [PATCH 29/34] decouple debugger and quickwatch plugins from the console --- client/ext/console/console.js | 55 +++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/client/ext/console/console.js b/client/ext/console/console.js index edab5407c3a..6789ea4b3fe 100644 --- a/client/ext/console/console.js +++ b/client/ext/console/console.js @@ -921,35 +921,40 @@ return ext.register("ext/console/console", { } }, - showObject : function(xmlNode, ref, expression){ + showObject : function(xmlNode, ref, expression) { if (ref && ref.dataType == apf.ARRAY) { - require("ext/debugger/debugger").showDebugFile(ref[0], ref[1] + 1, 0, ref[4]); + require(["ext/debugger/debugger"], function(dbg) { + dbg.showDebugFile(ref[0], ref[1] + 1, 0, ref[4]); + }); } else { - require("ext/quickwatch/quickwatch").toggleDialog(1); - - if (xmlNode && typeof xmlNode == "string") - xmlNode = apf.getXml(xmlNode); - - var name = xmlNode && xmlNode.getAttribute("name") || expression; - txtCurObject.setValue(name); - dgWatch.clear("loading"); - - if (xmlNode) { - setTimeout(function(){ - var model = dgWatch.getModel(); - var root = apf.getXml(""); - apf.xmldb.appendChild(root, xmlNode); - model.load(root); - //model.appendXml(xmlNode); - }, 10); - } - else if (ref) { + require(["ext/quickwatch/quickwatch"], function(quickwatch) { + quickwatch.toggleDialog(1); + + if (xmlNode && typeof xmlNode == "string") + xmlNode = apf.getXml(xmlNode); + + var name = xmlNode && xmlNode.getAttribute("name") || expression; + txtCurObject.setValue(name); + dgWatch.clear("loading"); + + if (xmlNode) { + setTimeout(function(){ + var model = dgWatch.getModel(); + var root = apf.getXml(""); + apf.xmldb.appendChild(root, xmlNode); + model.load(root); + //model.appendXml(xmlNode); + }, 10); + } + else if (ref) { + + } + else { + this.evaluate(expression); + } + }); - } - else { - this.evaluate(expression); - } } }, From 96588af29eb3ca90c5e444d5b268846c5cc9a7df Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 27 Jun 2011 10:44:34 +0200 Subject: [PATCH 30/34] bring back init function for server side plugins --- server/cloud9/ext/debugger/debugger.js | 14 ++++++++------ server/cloud9/workspace.js | 5 +++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/server/cloud9/ext/debugger/debugger.js b/server/cloud9/ext/debugger/debugger.js index bcbfc32011a..9e668ba8722 100644 --- a/server/cloud9/ext/debugger/debugger.js +++ b/server/cloud9/ext/debugger/debugger.js @@ -17,12 +17,6 @@ var DebuggerPlugin = module.exports = function(ide, workspace) { this.hooks = ["command"]; this.name = "debugger"; this.nodeCmd = process.argv[0]; - - var _self = this; - this.workspace.getExt("state").on("statechange", function(state) { - state.debugClient = !!_self.debugClient; - state.processRunning = !!_self.child; - }); }; sys.inherits(DebuggerPlugin, Plugin); @@ -31,6 +25,14 @@ sys.inherits(DebuggerPlugin, Plugin); this.NODE_DEBUG_PORT = 5858; this.CHROME_DEBUG_PORT = 9222; + this.init = function() { + var _self = this; + this.workspace.getExt("state").on("statechange", function(state) { + state.debugClient = !!_self.debugClient; + state.processRunning = !!_self.child; + }); + }; + this.command = function(user, message, client) { var _self = this; diff --git a/server/cloud9/workspace.js b/server/cloud9/workspace.js index c9949f07bbc..c9dc5e259b9 100644 --- a/server/cloud9/workspace.js +++ b/server/cloud9/workspace.js @@ -22,6 +22,11 @@ var Workspace = module.exports = function(config) { for (var name in plugins) { this.plugins[name] = new plugins[name](this.ide, this); } + + for (var name in plugins) { + if (this.plugins[name].init) + this.plugins[name].init(); + } }; this.getServerExclude = function(user) { From 5cddf112023f60c82bb4f6e762a636a5a3a1ca5a Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 27 Jun 2011 14:13:40 +0200 Subject: [PATCH 31/34] jsdav --- support/jsdav | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/jsdav b/support/jsdav index 1d8a95404f3..05299062ba9 160000 --- a/support/jsdav +++ b/support/jsdav @@ -1 +1 @@ -Subproject commit 1d8a95404f3bb8bfd04978858d54caa2bc682f74 +Subproject commit 05299062ba93fda04e34b9baf3c543942634bf7a From ff1f8303af362d38685c3e797b37a77a8160e974 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Mon, 27 Jun 2011 16:49:40 +0200 Subject: [PATCH 32/34] jsdav --- support/jsdav | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/support/jsdav b/support/jsdav index 05299062ba9..4610fcc2e7f 160000 --- a/support/jsdav +++ b/support/jsdav @@ -1 +1 @@ -Subproject commit 05299062ba93fda04e34b9baf3c543942634bf7a +Subproject commit 4610fcc2e7fcae3de35d9fc8d2adfb7fb85b6d27 From 1a1ff71ad2afdae5da6003257aca45e8a81d6324 Mon Sep 17 00:00:00 2001 From: linh81 Date: Fri, 1 Jul 2011 15:40:42 +0200 Subject: [PATCH 33/34] added 'plus' and 'minus' icons --- client/style/icons/minus.png | Bin 0 -> 1055 bytes client/style/icons/plus.png | Bin 0 -> 1168 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 client/style/icons/minus.png create mode 100644 client/style/icons/plus.png diff --git a/client/style/icons/minus.png b/client/style/icons/minus.png new file mode 100644 index 0000000000000000000000000000000000000000..26c85a94fc9b1d51a76f414c553fa80b05fd292c GIT binary patch literal 1055 zcmbVLziZS`91p#sQYbCUW zsoL1%tOUcwUO?FlQ<#kd%U(kSG|{T-YwVAM_bhN7jlHc@U?nh6+g;cSQEh9nZf~vG zd54|70Sd871w2G75PR!>q{bTC(^cs{x#n5WgOD|i?K{<|ECU0F2q+v(+b{z`M&JZV z&StaMfd~c2Ly;H6w2)OLQH2l;9+p}Qot9cPO9NZLO!2Q zG(<5?5$UMw6Dv;p(ezNkM3Ei30dcVp5=E_>w{(UkGA74QNF zdCyDY>Y*c2MSt8l6&=;P0phDD!keK@>(QDXl4mfM)%sEq?))D%#$Y}ZfD zNqPFwnkaPdBc~K%5A^b@x~JHO`oH4tbDjUm8Bd+zljiuVS%z1%1C#AZ>(j%@@F1T~ zOh`v#^49q~bgY)jre2S~HGdr+&!*l!*x4R|6N)r)$c4&2bNG6DBLjCI)n0Vv-N*N? zepor0nprve-rl?Nwea%U=N0kE#Fvk$y_ui$``4b!snN^KrKgh%*@Mw{$;g(Ai{`7j HyAOW@@5o5B literal 0 HcmV?d00001 diff --git a/client/style/icons/plus.png b/client/style/icons/plus.png new file mode 100644 index 0000000000000000000000000000000000000000..4d46ed93a7a9bbf204a8848d7309d57528423db4 GIT binary patch literal 1168 zcmbVMOK8+U7>+2dR#Zd}J_;S_rG(Zsj+@h z)v79rq86naq%2vNkk>!If_yt~aYeGM#Bv@tTLoNH97M%6s|A6yp|qkbQnc>Q5mZZ2 za|?PdkMo%wqG}n8;^{CY!zO5os;w*8irS7aXhE&I8Kb}6y-x#Oi_v>R8JMw?s7-I^ zaZqzlV@~a9R|So(+X`w+A|WskRzS(OGSB9SeCha6-f&vLw*Xi!56# z7MWszv7ASFIJe>-`urrw% zV$+>Y6iFFdQf!uEAZr+2T$9=^&Z6IL%&P6?x^2W}k!y81Dyc_dZ5d2*_jf~{BJoDt z>FA^=N{3{rT?R67T8h!+hS79QgwaGi5s3>3Py!^ARaGs%!ZYd z0X`%MDIp2N94EtgI2lZZxbHfjwJh{E_QN^{+ zheLhG=R~59wo#C4qWZ2DQsA8|9o{=u^+lEPPXCV=73-Jz?Y8wYnh{_y#nl>hDo z2SH->_1^yeXZ{uABd0eU@S%|_J1@Pfetv3n_gV`tVi zr-prFcRsCoeSTnIpyuSoOGkF0{^h${>xX^x_Mx$p$;Cc(-}!;c8*e{8UixxV!?#0~ nd#c78de_y|FIzB=nzw>_HCnfMe*L{l?;nwt8>O3x{YQTR?zw(w literal 0 HcmV?d00001 From c2c5c3972bce1a1c1bf0f32de943bbb7f94c1127 Mon Sep 17 00:00:00 2001 From: linh81 Date: Tue, 5 Jul 2011 09:55:40 +0200 Subject: [PATCH 34/34] added disabled state for header-btn --- client/style/skins.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/style/skins.xml b/client/style/skins.xml index a42d54ce172..b2b19609167 100644 --- a/client/style/skins.xml +++ b/client/style/skins.xml @@ -1475,6 +1475,10 @@ .header-btnOver { background-position : 0 -15px; } + + .header-btnDisabled { + background-position : 0 -30px; + } ]]>