kopia lustrzana https://github.com/c9/core
Merge pull request +11504 from c9/fix/various
Fix several small issuespull/232/head
commit
39911319b1
|
@ -48,5 +48,5 @@ rules:
|
||||||
space-in-parens: [1, "never"]
|
space-in-parens: [1, "never"]
|
||||||
space-return-throw-case: [1, "always"]
|
space-return-throw-case: [1, "always"]
|
||||||
// space-before-function-paren: [3, {"named": "never", "anonymous": "never"}]
|
// space-before-function-paren: [3, {"named": "never", "anonymous": "never"}]
|
||||||
spaced-line-comment: 3
|
spaced-comment: 3
|
||||||
// valid-jsdoc: [1, { requireReturn: false, requireParamDescription: false, prefer: { "return": "return" } }]
|
// valid-jsdoc: [1, { requireReturn: false, requireParamDescription: false, prefer: { "return": "return" } }]
|
||||||
|
|
|
@ -412,7 +412,11 @@ function loadText(path, cb) {
|
||||||
var xhr = new window.XMLHttpRequest();
|
var xhr = new window.XMLHttpRequest();
|
||||||
xhr.open("GET", path, true);
|
xhr.open("GET", path, true);
|
||||||
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
xhr.onload = function(e) { cb(null, xhr.responseText, xhr); };
|
xhr.onload = function(e) {
|
||||||
|
if (xhr.status > 399 && xhr.status < 600)
|
||||||
|
return cb(xhr);
|
||||||
|
cb(null, xhr.responseText, xhr);
|
||||||
|
};
|
||||||
xhr.onabort = xhr.onerror = function(e) { cb(e); };
|
xhr.onabort = xhr.onerror = function(e) { cb(e); };
|
||||||
xhr.send("");
|
xhr.send("");
|
||||||
}
|
}
|
||||||
|
@ -425,12 +429,9 @@ var loadScript = function(path, id, callback) {
|
||||||
if (!/https?:/.test(path))
|
if (!/https?:/.test(path))
|
||||||
path = host + path;
|
path = host + path;
|
||||||
var cb = function(e, val, deps) {
|
var cb = function(e, val, deps) {
|
||||||
if (e) console.error("Couldn't load module " + module, e);
|
if (e) return processLoadQueue({ id: id, path: path });
|
||||||
|
|
||||||
nextModule = {
|
nextModule = { name: id, deps: deps };
|
||||||
name: id,
|
|
||||||
deps: deps
|
|
||||||
};
|
|
||||||
window.eval(val + "\n//# sourceURL=" + path);
|
window.eval(val + "\n//# sourceURL=" + path);
|
||||||
callback(null, id);
|
callback(null, id);
|
||||||
return define.loaded[id];
|
return define.loaded[id];
|
||||||
|
@ -547,9 +548,7 @@ function post(path, val, progress, cb) {
|
||||||
cb(null, xhr.responseText, xhr);
|
cb(null, xhr.responseText, xhr);
|
||||||
};
|
};
|
||||||
xhr.onreadystatechange = function(e) { progress(xhr.responseText, xhr); };
|
xhr.onreadystatechange = function(e) { progress(xhr.responseText, xhr); };
|
||||||
xhr.onabort = xhr.onerror = function(e) {
|
xhr.onabort = xhr.onerror = function(e) { cb(e); };
|
||||||
xhr && cb(e);
|
|
||||||
};
|
|
||||||
xhr.send(val);
|
xhr.send(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
"c9.ide.language.html.diff": "#24f3608d26",
|
"c9.ide.language.html.diff": "#24f3608d26",
|
||||||
"c9.ide.language.javascript": "#1a0b1584c2",
|
"c9.ide.language.javascript": "#1a0b1584c2",
|
||||||
"c9.ide.language.javascript.immediate": "#c8b1e5767a",
|
"c9.ide.language.javascript.immediate": "#c8b1e5767a",
|
||||||
"c9.ide.language.javascript.eslint": "#a234af16c0",
|
"c9.ide.language.javascript.eslint": "#8d35953ff4",
|
||||||
"c9.ide.language.javascript.tern": "#f9ba3813d7",
|
"c9.ide.language.javascript.tern": "#f9ba3813d7",
|
||||||
"c9.ide.language.javascript.infer": "#9cf94f77be",
|
"c9.ide.language.javascript.infer": "#9cf94f77be",
|
||||||
"c9.ide.language.jsonalyzer": "#f0bb823c6f",
|
"c9.ide.language.jsonalyzer": "#f0bb823c6f",
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
"c9.ide.find": "#e33fbaed2f",
|
"c9.ide.find": "#e33fbaed2f",
|
||||||
"c9.ide.find.infiles": "#c3bf17286d",
|
"c9.ide.find.infiles": "#c3bf17286d",
|
||||||
"c9.ide.find.replace": "#8cbce45290",
|
"c9.ide.find.replace": "#8cbce45290",
|
||||||
"c9.ide.run.debug": "#3e06ddc0d2",
|
"c9.ide.run.debug": "#8b77a8379d",
|
||||||
"c9.automate": "#47e2c429c9",
|
"c9.automate": "#47e2c429c9",
|
||||||
"c9.ide.ace.emmet": "#6dc4585e02",
|
"c9.ide.ace.emmet": "#6dc4585e02",
|
||||||
"c9.ide.ace.gotoline": "#a8ff07c8f4",
|
"c9.ide.ace.gotoline": "#a8ff07c8f4",
|
||||||
|
|
|
@ -598,7 +598,7 @@ define(function(require, exports, module) {
|
||||||
|
|
||||||
api[type].get("persistent/" + apiKey, function(err, data){
|
api[type].get("persistent/" + apiKey, function(err, data){
|
||||||
if (err) return callback(err);
|
if (err) return callback(err);
|
||||||
try { callback(null, JSON.stringify(data)); }
|
try { callback(null, JSON.parse(data)); }
|
||||||
catch(e){ return callback(e); }
|
catch(e){ return callback(e); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -613,7 +613,11 @@ define(function(require, exports, module) {
|
||||||
else if (context == "workspace") type = "project";
|
else if (context == "workspace") type = "project";
|
||||||
else throw new Error("Unsupported context: " + context);
|
else throw new Error("Unsupported context: " + context);
|
||||||
|
|
||||||
api[type].put("persistent/" + apiKey, { data: JSON.stringify(data) }, callback);
|
api[type].put("persistent/" + apiKey, {
|
||||||
|
body: {
|
||||||
|
data: JSON.stringify(data)
|
||||||
|
}
|
||||||
|
}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Register and define API *****/
|
/***** Register and define API *****/
|
||||||
|
|
|
@ -45,7 +45,7 @@ define(function(require, exports, module) {
|
||||||
var ENABLED = c9.location.indexOf("debug=2") > -1;
|
var ENABLED = c9.location.indexOf("debug=2") > -1;
|
||||||
var HASSDK = ENABLED || experimental.addExperiment("sdk", false, "SDK/Load Custom Plugins");
|
var HASSDK = ENABLED || experimental.addExperiment("sdk", false, "SDK/Load Custom Plugins");
|
||||||
|
|
||||||
var reParts = /^(builders|keymaps|modes|outline|runners|snippets|themes)\/(.*)/;
|
var reParts = /^(builders|keymaps|modes|outline|runners|snippets|themes|templates)\/(.*)/;
|
||||||
var reModule = /(?:_highlight_rules|_test|_worker|_fold|_behaviou?r)\.js$/;
|
var reModule = /(?:_highlight_rules|_test|_worker|_fold|_behaviou?r)\.js$/;
|
||||||
var jsExtRe = /\.js$/;
|
var jsExtRe = /\.js$/;
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,6 @@ function plugin(options, imports, register) {
|
||||||
|
|
||||||
api.get("/configs/require_config.js", function(req, res, next) {
|
api.get("/configs/require_config.js", function(req, res, next) {
|
||||||
var config = res.getOptions().requirejsConfig || {};
|
var config = res.getOptions().requirejsConfig || {};
|
||||||
config.waitSeconds = 240;
|
|
||||||
|
|
||||||
res.writeHead(200, {"Content-Type": "application/javascript"});
|
res.writeHead(200, {"Content-Type": "application/javascript"});
|
||||||
res.end("requirejs.config(" + JSON.stringify(config) + ");");
|
res.end("requirejs.config(" + JSON.stringify(config) + ");");
|
||||||
|
@ -212,6 +211,54 @@ function plugin(options, imports, register) {
|
||||||
|
|
||||||
api.get("/api.json", {name: "api"}, frontdoor.middleware.describeApi(api));
|
api.get("/api.json", {name: "api"}, frontdoor.middleware.describeApi(api));
|
||||||
|
|
||||||
|
api.get("/api/project/:pid/persistent/:apikey", {
|
||||||
|
params: {
|
||||||
|
pid: { type: "number" },
|
||||||
|
apikey: { type: "string" }
|
||||||
|
}
|
||||||
|
}, persistentDataApiMock);
|
||||||
|
api.put("/api/project/:pid/persistent/:apikey", {
|
||||||
|
params: {
|
||||||
|
data: { type: "string", source: "body" },
|
||||||
|
pid: { type: "number" },
|
||||||
|
apikey: { type: "string" },
|
||||||
|
}
|
||||||
|
}, persistentDataApiMock);
|
||||||
|
api.get("/api/user/persistent/:apikey", {
|
||||||
|
params: {
|
||||||
|
apikey: { type: "string" }
|
||||||
|
}
|
||||||
|
}, persistentDataApiMock);
|
||||||
|
api.put("/api/user/persistent/:apikey", {
|
||||||
|
params: {
|
||||||
|
data: { type: "string", source: "body" },
|
||||||
|
apikey: { type: "string" },
|
||||||
|
}
|
||||||
|
}, persistentDataApiMock);
|
||||||
|
|
||||||
|
function persistentDataApiMock(req, res, next) {
|
||||||
|
var name = (req.params.pid || 0) + "-" + req.params.apikey;
|
||||||
|
var data = req.params.data;
|
||||||
|
console.log(name, data)
|
||||||
|
if (/[^\w+=\-]/.test(name))
|
||||||
|
return next(new Error("Invalid apikey"));
|
||||||
|
var path = join(options.installPath, ".c9", "persistent");
|
||||||
|
var method = req.method.toLowerCase()
|
||||||
|
if (method == "get") {
|
||||||
|
res.writeHead(200, {"Content-Type": "application/octet-stream"});
|
||||||
|
var stream = fs.createReadStream(path + "/" + name);
|
||||||
|
stream.pipe(res);
|
||||||
|
} else if (method == "put") {
|
||||||
|
require("mkdirp")(path, function(e) {
|
||||||
|
fs.writeFile(path + "/" + name, data, "", function(err) {
|
||||||
|
if (err) return next(err);
|
||||||
|
res.writeHead(200, {"Content-Type": "application/octet-stream"});
|
||||||
|
res.end("");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// fake authentication
|
// fake authentication
|
||||||
api.authenticate = api.authenticate || function() {
|
api.authenticate = api.authenticate || function() {
|
||||||
return function(req, res, next) {
|
return function(req, res, next) {
|
||||||
|
|
|
@ -63,7 +63,7 @@ module.exports = function(manifest, installPath) {
|
||||||
ideBaseUrl: "http://c9.io",
|
ideBaseUrl: "http://c9.io",
|
||||||
previewUrl: "/preview",
|
previewUrl: "/preview",
|
||||||
dashboardUrl: "https://c9.io/dashboard.html",
|
dashboardUrl: "https://c9.io/dashboard.html",
|
||||||
apiUrl: "https://api.c9.dev",
|
apiUrl: "/api",
|
||||||
homeUrl: "/home",
|
homeUrl: "/home",
|
||||||
collab: false,
|
collab: false,
|
||||||
installed: true,
|
installed: true,
|
||||||
|
|
Ładowanie…
Reference in New Issue