kopia lustrzana https://github.com/c9/core
add example of resolving config on client side
rodzic
dc05adac25
commit
3d654fc187
|
@ -94,6 +94,11 @@ function plugin(options, imports, register) {
|
|||
source: "query",
|
||||
optional: true
|
||||
},
|
||||
settings: {
|
||||
type: "number",
|
||||
source: "query",
|
||||
optional: true
|
||||
},
|
||||
}
|
||||
}, function(req, res, next) {
|
||||
|
||||
|
@ -116,11 +121,18 @@ function plugin(options, imports, register) {
|
|||
});
|
||||
|
||||
opts.options.debug = req.params.debug !== undefined;
|
||||
var workspaceSettings = getSettings(configName, options);
|
||||
|
||||
res.setHeader("Cache-Control", "no-cache, no-store");
|
||||
|
||||
if (req.params.settings == 1)
|
||||
return res.json(workspaceSettings);
|
||||
|
||||
if (req.params.config == 1)
|
||||
return res.json(getConfig(configName, opts));
|
||||
return res.json(getConfig(configName, workspaceSettings));
|
||||
|
||||
res.render(__dirname + "/views/standalone.html.ejs", {
|
||||
architectConfig: getConfig(configName, opts),
|
||||
architectConfig: getConfig(configName, workspaceSettings),
|
||||
configName: configName,
|
||||
packed: opts.packed,
|
||||
standalone: true,
|
||||
|
@ -326,9 +338,7 @@ function getConfigName(requested, options) {
|
|||
return name;
|
||||
}
|
||||
|
||||
function getConfig(configName, options) {
|
||||
var filename = __dirname + "/../../configs/client-" + configName + ".js";
|
||||
|
||||
function getSettings(configName, options) {
|
||||
var installPath = options.settingDir || options.installPath || "";
|
||||
var workspaceDir = options.options.workspaceDir;
|
||||
var settings = {
|
||||
|
@ -347,6 +357,14 @@ function getConfig(configName, options) {
|
|||
settings[type] = data;
|
||||
}
|
||||
options.options.settings = settings;
|
||||
|
||||
return require(filename)(options.options);
|
||||
options.options.configName = configName;
|
||||
options.options.manifest = {
|
||||
version: options.options.manifest.version
|
||||
};
|
||||
return options.options;
|
||||
}
|
||||
|
||||
function getConfig(configName, options) {
|
||||
var filename = __dirname + "/../../configs/client-" + configName + ".js";
|
||||
return require(filename)(options);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var start = Date.now();
|
||||
var loadingIde = document.querySelector("#loadingide");
|
||||
document.body.className = "loading " + loadingIde.className;
|
||||
|
||||
|
@ -95,11 +96,11 @@
|
|||
<script src="/static/mini_require.js"></script>
|
||||
<script src="/configs/require_config.js"></script>
|
||||
<script>
|
||||
var start = Date.now();
|
||||
|
||||
var plugins;
|
||||
require(["lib/architect/architect", "text!/ide.html?config=1"], function (architect, pluginJSON) {
|
||||
plugins = JSON.parse(pluginJSON);
|
||||
require(["text!/ide.html?settings=1"], function(workspaceSettings) {
|
||||
workspaceSettings = JSON.parse(workspaceSettings);
|
||||
require(["lib/architect/architect", "configs/ide/" + workspaceSettings.configName], function(architect, config) {
|
||||
plugins = config(workspaceSettings);
|
||||
plugins.push({
|
||||
consumes: [],
|
||||
provides: ["auth.bootstrap"],
|
||||
|
@ -179,6 +180,7 @@
|
|||
return alert("Unable to load html5.js.\n\nThis may be caused by a false positive in your virus scanner. Please try reloading with ?packed=1 added to the URL.");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Ładowanie…
Reference in New Issue