Skip to content

Commit

Permalink
Merge pull request #1219 from ajaxorg/stateless_runvm
Browse files Browse the repository at this point in the history
Stateless runvm
  • Loading branch information
Zef Hemel committed Apr 4, 2012
2 parents d210a2d + 8565d35 commit 4e985d8
Show file tree
Hide file tree
Showing 26 changed files with 183 additions and 223 deletions.
2 changes: 1 addition & 1 deletion bin/cloud9.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ if (parseInt(process.version.split(".")[1], 10) < 2) {

var options = Parser.parse([
{short: "w", long: "workspace", description: "Path to the workspace that will be loaded in Cloud9 (may be relative or absolute).", value: true, def: "." },
{short: "p", long: "port", parser: parseInt, description: "Port number where Cloud9 will serve from.", value: true, def: process.env.C9_PORT || 3000 },
{short: "p", long: "port", parser: parseInt, description: "Port number where Cloud9 will serve from.", value: true, def: process.env.PORT || 3000 },
{short: "l", long: "ip", description: "IP address where Cloud9 will serve from.", value: true, def: process.env.C9_PORT ? "0.0.0.0" : "127.0.0.1" },
{short: "a", long: "action", description: "Define an action to execute after the Cloud9 server is started.", value: true, def: null, parser: function(value) {
return value.split(/\s+/g);
Expand Down
4 changes: 2 additions & 2 deletions client/core/ide.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ define(function(require, exports, module) {
window.onerror = function(m, u, l) {
if (window.console)
console.log("An error occurred, the Cloud9 system admin has been notified.");
apf.ajax("/debug", {
apf.ajax("/api/debug", {
method : "POST",
contentType : "application/json",
data : apf.serialize({
Expand All @@ -75,7 +75,7 @@ define(function(require, exports, module) {

//Catch all APF Routed errors
apf.addEventListener("error", function(e){
apf.ajax("/debug", {
apf.ajax("/api/debug", {
method : "POST",
contentType : "application/json",
data : apf.serialize({
Expand Down
4 changes: 2 additions & 2 deletions client/core/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ module.exports = {
saveToFile : function() {
var data = this.model.data && apf.xmldb.cleanXml(this.model.data.xml) || "";
if (ide.onLine) {
ide.send(JSON.stringify({
ide.send({
command: "settings",
action: "set",
settings: data
}));
});
ide.dispatchEvent("track_action", {
type: "save settings",
settings: data
Expand Down
38 changes: 21 additions & 17 deletions client/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
*/
define(function(require, exports, module) {

exports.alert = function(title, header, msg, onhide) {
winAlert.show();
winAlert.setAttribute('title', title);
Expand All @@ -21,7 +21,7 @@ exports.alert = function(title, header, msg, onhide) {
};

exports.confirm = function(title, header, msg, onconfirm, oncancel) {
winConfirm.show();
winConfirm.show();
winConfirm.setAttribute("title", title);
winConfirmHeader.$ext.innerHTML = header;
winConfirmMsg.$ext.innerHTML = msg;
Expand All @@ -30,7 +30,7 @@ exports.confirm = function(title, header, msg, onconfirm, oncancel) {
};

exports.question = function(title, header, msg, onyes, onyestoall, onno, onnotoall) {
winQuestion.show();
winQuestion.show();
winQuestion.setAttribute("title", title);
winQuestionHeader.$ext.innerHTML = header;
winQuestionMsg.$ext.innerHTML = msg;
Expand All @@ -46,7 +46,7 @@ exports.removeInteractive = function (amlNode) {

if (amlNode.confirmed == undefined)
amlNode.confirmed = false;

if (!amlNode.confirmed) {
var files = amlNode.getSelection();

Expand Down Expand Up @@ -111,7 +111,8 @@ var SupportedIcons = {
"text/x-script.ocaml": 'page_white_code',
"text/x-script.clojure": 'page_white_code',
"application/x-httpd-php": 'page_white_php',
"text/x-coldfusion": 'page_white_php',
"application/x-sh": "page_white_wrench",
"text/x-coldfusion": 'page_white_coldfusion',
"text/x-script.ruby": "page_white_ruby",
"text/x-script.coffeescript": 'page_white_cup',
"text/cpp": 'page_white_cplusplus',
Expand All @@ -120,14 +121,14 @@ var SupportedIcons = {
"text/text/x-java-source": 'page_white_cup',
"text/x-markdown": 'page_white_text'
};

var contentTypes = {
"js": "application/javascript",
"json": "application/json",
"css": "text/css",
"scss": "text/x-scss",
"sass": "text/x-sass",

"xml": "application/xml",
"rdf": "application/rdf+xml",
"rss": "application/rss+xml",
Expand All @@ -137,27 +138,27 @@ var contentTypes = {
"atom": "application/atom+xml",
"mathml": "application/mathml+xml",
"mml": "application/mathml+xml",

"php": "application/x-httpd-php",
"phtml": "application/x-httpd-php",
"html": "text/html",
"xhtml": "application/xhtml+xml",
"coffee": "text/x-script.coffeescript",
"py": "text/x-script.python",

"ru": "text/x-script.ruby",
"gemspec": "text/x-script.ruby",
"rake": "text/x-script.ruby",
"rb": "text/x-script.ruby",

"c": "text/x-c",
"cc": "text/x-c",
"cpp": "text/x-c",
"cxx": "text/x-c",
"h": "text/x-c",
"hh": "text/x-c",
"hpp": "text/x-c",

"bmp": "image",
"djv": "image",
"djvu": "image",
Expand All @@ -181,22 +182,25 @@ var contentTypes = {
"ml": "text/x-script.ocaml",
"mli": "text/x-script.ocaml",
"cfm": "text/x-coldfusion",
"sql": "text/x-sql"
"sql": "text/x-sql",

"sh": "application/x-sh",
"bash": "application/x-sh"
};

exports.getFileIcon = function(xmlNode) {
var name = xmlNode.getAttribute('name');
var icon = "page_white_text";
var ext;

if (name) {
ext = name.split(".").pop();
icon = SupportedIcons[contentTypes[ext]] || "page_white_text";
}
return icon + ".png";
};


exports.getContentType = function(filename) {
var type = filename.split(".").pop() || "";
return contentTypes[type] || "text/plain";
Expand Down Expand Up @@ -319,11 +323,11 @@ exports.isFalse = function(c){
/*
* JavaScript Linkify - v0.3 - 6/27/2009
* http://benalman.com/projects/javascript-linkify/
*
*
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*
*
* Some regexps adapted from http://userscripts.org/scripts/review/7122
*/
exports.linkify=function(){var k="[a-z\\d.-]+://",h="(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])",c="(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+",n="(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)",f="(?:"+c+n+"|"+h+")",o="(?:[;/][^#?<>\\s]*)?",e="(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?",d="\\b"+k+"[^<>\\s]+",a="\\b"+f+o+e+"(?!\\w)",m="mailto:",j="(?:"+m+")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@"+f+e+"(?!\\w)",l=new RegExp("(?:"+d+"|"+a+"|"+j+")","ig"),g=new RegExp("^"+k,"i"),b={"'":"`",">":"<",")":"(","]":"[","}":"{","B;":"B+","b:":"b9"},i={callback:function(q,p){return p?'<a href="'+p+'" title="'+p+'">'+q+"</a>":q},punct_regexp:/(?:[!?.,:;'"]|(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/};return function(u,z){z=z||{};var w,v,A,p,x="",t=[],s,E,C,y,q,D,B,r;for(v in i){if(z[v]===undefined){z[v]=i[v]}}while(w=l.exec(u)){A=w[0];E=l.lastIndex;C=E-A.length;if(/[\/:]/.test(u.charAt(C-1))){continue}do{y=A;r=A.substr(-1);B=b[r];if(B){q=A.match(new RegExp("\\"+B+"(?!$)","g"));D=A.match(new RegExp("\\"+r,"g"));if((q?q.length:0)<(D?D.length:0)){A=A.substr(0,A.length-1);E--}}if(z.punct_regexp){A=A.replace(z.punct_regexp,function(F){E-=F.length;return""})}}while(A.length&&A!==y);p=A;if(!g.test(p)){p=(p.indexOf("@")!==-1?(!p.indexOf(m)?"":m):!p.indexOf("irc.")?"irc://":!p.indexOf("ftp.")?"ftp://":"http://")+p}if(s!=C){t.push([u.slice(s,C)]);s=E}t.push([A,p])}t.push([u.substr(s)]);for(v=0;v<t.length;v++){x+=z.callback.apply(window,t[v])}return x||u}}();
Expand Down
6 changes: 5 additions & 1 deletion client/ext/code/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ var SupportedModes = {
"application/atom+xml": "xml",
"application/mathml+xml": "xml",
"application/x-httpd-php": "php",
"application/x-sh": "sh",
"text/x-script.python": "python",
"text/x-script.ruby": "ruby",
"text/x-script.perl": "perl",
Expand Down Expand Up @@ -138,7 +139,10 @@ var contentTypes = {

"ps1": "text/x-script.powershell",
"cfm": "text/x-coldfusion",
"sql": "text/x-sql"
"sql": "text/x-sql",

"sh": "application/x-sh",
"bash": "application/x-sh"
};

module.exports = ext.register("ext/code/code", {
Expand Down
11 changes: 6 additions & 5 deletions client/ext/code/code.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
softtabs = "[{require('ext/settings/settings').model}::editors/code/@softtabs]"
tabsize = "[{require('ext/settings/settings').model}::editors/code/@tabsize]"
scrollspeed = "[{require('ext/settings/settings').model}::editors/code/@scrollspeed]"

fontsize = "[{require('ext/settings/settings').model}::editors/code/@fontsize]"
wrapmode = "[{require('ext/settings/settings').model}::editors/code/@wrapmode]"
wrapmodeViewport = "[{require('ext/settings/settings').model}::editors/code/@wrapmodeViewport]"
Expand All @@ -25,25 +25,25 @@
gutter = "[{require('ext/settings/settings').model}::editors/code/@gutter]"
highlightselectedword = "[{require('ext/settings/settings').model}::editors/code/@highlightselectedword]"
autohidehorscrollbar = "[{require('ext/settings/settings').model}::editors/code/@autohidehorscrollbar]"

contextmenu = "mnuCtxEditor"
debugger = "{this.syntax == 'javascript' ? dbg : null}"
readonly = "{[@loading] or cloud9config.readonly or (location.host and window.stDebugProcessRunning and stDebugProcessRunning.active and [@scriptid])}"
/>

<a:menu id="mnuCtxEditor" render="runtime">
<a:item onclick="tabEditors.getPage().$at.undo()">Undo</a:item>
<a:item onclick="tabEditors.getPage().$at.redo()">Redo</a:item>
<a:divider />
<a:item
<a:item
visible="{stDebugProcessRunning.active and !stRunning.active}"
onclick="
require('ext/quickwatch/quickwatch').toggleDialog(1, true);
">Quick Watch</a:item>
<a:divider visible="{stDebugProcessRunning.active and !stRunning.active}" />
<a:item onclick="ceEditor.$editor.getSelection().selectAll()">Select All</a:item>
</a:menu>

<a:menu id="mnuSyntax">
<a:item type="radio" value="auto">Auto-Select</a:item>
<a:item type="radio" value="text/plain">Plain Text</a:item>
Expand All @@ -58,6 +58,7 @@
<a:item type="radio" value="text/x-java-source">Java</a:item>
<a:item type="radio" value="application/javascript">JavaScript</a:item>
<a:item type="radio" value="application/x-latex">Latex</a:item>
<a:item type="radio" value="application/x-sh">Shell Script</a:item>
<a:item type="radio" value="text/x-lua">Lua</a:item>
<a:item type="radio" value="text/x-markdown">Markdown</a:item>
<a:item type="radio" value="text/x-script.ocaml">OCaml</a:item>
Expand Down
4 changes: 2 additions & 2 deletions client/ext/debugger/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ var dock = require("ext/dockpanel/dockpanel");
var fs = require("ext/filesystem/filesystem");
var noderunner = require("ext/noderunner/noderunner");
var markup = require("text!ext/debugger/debugger.xml");
var inspector = require("ext/debugger/inspector");
var settings = require("ext/settings/settings");
require("ext/debugger/inspector");
require("ext/settings/settings");

module.exports = ext.register("ext/debugger/debugger", {
name : "Debug",
Expand Down
17 changes: 14 additions & 3 deletions client/ext/noderunner/noderunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module.exports = ext.register("ext/noderunner/noderunner", {

init : function(){
var _self = this;
ide.addEventListener("socketConnect", this.onConnect.bind(this));
ide.addEventListener("socketDisconnect", this.onDisconnect.bind(this));
ide.addEventListener("socketMessage", this.onMessage.bind(this));

Expand All @@ -59,6 +60,8 @@ module.exports = ext.register("ext/noderunner/noderunner", {
return false;
});

this.nodePid = null;

ide.addEventListener("loadsettings", function(e){
_self.NODE_VERSION = e.model.queryValue("auto/node-version/@version") || "auto";
});
Expand Down Expand Up @@ -102,8 +105,11 @@ module.exports = ext.register("ext/noderunner/noderunner", {
break;

case "state":
stDebugProcessRunning.setProperty("active", message.debugClient || message.nodeDebugClient);
stProcessRunning.setProperty("active", message.processRunning || message.nodeProcessRunning || message.pythonProcessRunning);
this.nodePid = message.processRunning || 0;

stDebugProcessRunning.setProperty("active", !!message.debugClient);
stProcessRunning.setProperty("active", !!message.processRunning);

dbgNode.setProperty("strip", message.workspaceDir + "/");
ide.dispatchEvent("noderunnerready");
break;
Expand Down Expand Up @@ -157,6 +163,10 @@ module.exports = ext.register("ext/noderunner/noderunner", {
}
},

onConnect : function() {
ide.send({"command": "state"});
},

onDisconnect : function() {
stDebugProcessRunning.deactivate();
},
Expand Down Expand Up @@ -196,7 +206,8 @@ module.exports = ext.register("ext/noderunner/noderunner", {

ide.send({
"command": "kill",
"runner" : "node"
"runner" : "node",
"pid" : this.nodePid
});
},

Expand Down
7 changes: 2 additions & 5 deletions client/ext/openfiles/openfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ module.exports = ext.register("ext/openfiles/openfiles", {
});

ide.addEventListener("treechange", function(e) {

var path = e.path
.replace(/\/([^/]*)/g, "/node()[@name=\"$1\"]")
.replace(/\[@name="workspace"\]/, "")
.replace(/\//, "");
var path = "//folder[@path='" + e.path.replace(/\/$/, "") + "']";
var parent = trFiles.getModel().data.selectSingleNode(path);

if (!parent)
return;

Expand Down
Loading

0 comments on commit 4e985d8

Please sign in to comment.