Merge pull request +11504 from c9/fix/various

Fix several small issues
pull/232/head
Harutyun Amirjanyan 2016-01-11 21:26:27 +04:00
commit 39911319b1
7 zmienionych plików z 67 dodań i 17 usunięć

Wyświetl plik

@ -48,5 +48,5 @@ rules:
space-in-parens: [1, "never"]
space-return-throw-case: [1, "always"]
// 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" } }]

Wyświetl plik

@ -412,7 +412,11 @@ function loadText(path, cb) {
var xhr = new window.XMLHttpRequest();
xhr.open("GET", path, true);
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.send("");
}
@ -425,12 +429,9 @@ var loadScript = function(path, id, callback) {
if (!/https?:/.test(path))
path = host + path;
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 = {
name: id,
deps: deps
};
nextModule = { name: id, deps: deps };
window.eval(val + "\n//# sourceURL=" + path);
callback(null, id);
return define.loaded[id];
@ -547,9 +548,7 @@ function post(path, val, progress, cb) {
cb(null, xhr.responseText, xhr);
};
xhr.onreadystatechange = function(e) { progress(xhr.responseText, xhr); };
xhr.onabort = xhr.onerror = function(e) {
xhr && cb(e);
};
xhr.onabort = xhr.onerror = function(e) { cb(e); };
xhr.send(val);
}

Wyświetl plik

@ -62,7 +62,7 @@
"c9.ide.language.html.diff": "#24f3608d26",
"c9.ide.language.javascript": "#1a0b1584c2",
"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.infer": "#9cf94f77be",
"c9.ide.language.jsonalyzer": "#f0bb823c6f",
@ -71,7 +71,7 @@
"c9.ide.find": "#e33fbaed2f",
"c9.ide.find.infiles": "#c3bf17286d",
"c9.ide.find.replace": "#8cbce45290",
"c9.ide.run.debug": "#3e06ddc0d2",
"c9.ide.run.debug": "#8b77a8379d",
"c9.automate": "#47e2c429c9",
"c9.ide.ace.emmet": "#6dc4585e02",
"c9.ide.ace.gotoline": "#a8ff07c8f4",

Wyświetl plik

@ -598,7 +598,7 @@ define(function(require, exports, module) {
api[type].get("persistent/" + apiKey, function(err, data){
if (err) return callback(err);
try { callback(null, JSON.stringify(data)); }
try { callback(null, JSON.parse(data)); }
catch(e){ return callback(e); }
});
}
@ -613,7 +613,11 @@ define(function(require, exports, module) {
else if (context == "workspace") type = "project";
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 *****/

Wyświetl plik

@ -45,7 +45,7 @@ define(function(require, exports, module) {
var ENABLED = c9.location.indexOf("debug=2") > -1;
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 jsExtRe = /\.js$/;

Wyświetl plik

@ -183,7 +183,6 @@ function plugin(options, imports, register) {
api.get("/configs/require_config.js", function(req, res, next) {
var config = res.getOptions().requirejsConfig || {};
config.waitSeconds = 240;
res.writeHead(200, {"Content-Type": "application/javascript"});
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/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
api.authenticate = api.authenticate || function() {
return function(req, res, next) {

Wyświetl plik

@ -63,7 +63,7 @@ module.exports = function(manifest, installPath) {
ideBaseUrl: "http://c9.io",
previewUrl: "/preview",
dashboardUrl: "https://c9.io/dashboard.html",
apiUrl: "https://api.c9.dev",
apiUrl: "/api",
homeUrl: "/home",
collab: false,
installed: true,