mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into mjmh
This commit is contained in:
commit
63f982bc6b
|
@ -1,6 +1,8 @@
|
||||||
v2.2.0 (XXXX-XX-XX)
|
v2.2.0 (XXXX-XX-XX)
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
|
* added mountedApp function for foxx-manager
|
||||||
|
|
||||||
* cleanup of version-check, added module org/arangodb/database-version,
|
* cleanup of version-check, added module org/arangodb/database-version,
|
||||||
added --check-version option
|
added --check-version option
|
||||||
|
|
||||||
|
|
|
@ -1392,22 +1392,6 @@ function require (path) {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// @brief moduleFilename
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
Module.prototype.foxxFilename = function (path) {
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var prefix = fileUri2Path(this._origin);
|
|
||||||
|
|
||||||
if (path === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fs.safeJoin(prefix, path);
|
|
||||||
};
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- ArangoApp
|
// --SECTION-- ArangoApp
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -1430,6 +1414,7 @@ function require (path) {
|
||||||
this._root = root;
|
this._root = root;
|
||||||
this._path = path;
|
this._path = path;
|
||||||
this._options = options;
|
this._options = options;
|
||||||
|
this._exports = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -1659,8 +1644,6 @@ function require (path) {
|
||||||
var prefix = fs.safeJoin(this._root, this._path);
|
var prefix = fs.safeJoin(this._root, this._path);
|
||||||
|
|
||||||
context.foxxFilename = function (path) {
|
context.foxxFilename = function (path) {
|
||||||
console.log("XXXXXXXXXXXXXXXXX path %s", path);
|
|
||||||
|
|
||||||
return fs.safeJoin(prefix, path);
|
return fs.safeJoin(prefix, path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,12 @@ var developmentMode = require("internal").developmentMode;
|
||||||
|
|
||||||
var DEVELOPMENTMOUNTS = null;
|
var DEVELOPMENTMOUNTS = null;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief mounted apps
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
var MOUNTED_APPS = {};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- private functions
|
// --SECTION-- private functions
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -127,7 +133,8 @@ function checkManifest (filename, mf) {
|
||||||
"setup": [ false, "string" ],
|
"setup": [ false, "string" ],
|
||||||
"teardown": [ false, "string" ],
|
"teardown": [ false, "string" ],
|
||||||
"thumbnail": [ false, "string" ],
|
"thumbnail": [ false, "string" ],
|
||||||
"version": [ true, "string" ]
|
"version": [ true, "string" ],
|
||||||
|
"exports": [ false, "object" ]
|
||||||
};
|
};
|
||||||
|
|
||||||
var att, failed = false;
|
var att, failed = false;
|
||||||
|
@ -642,6 +649,8 @@ function mountAalApp (app, mount, options) {
|
||||||
function routingAalApp (app, mount, options) {
|
function routingAalApp (app, mount, options) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
MOUNTED_APPS[mount] = app;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var i, prefix;
|
var i, prefix;
|
||||||
|
|
||||||
|
@ -711,12 +720,7 @@ function routingAalApp (app, mount, options) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// mount all applications
|
// template for app context
|
||||||
var controllers = app._manifest.controllers;
|
|
||||||
|
|
||||||
for (i in controllers) {
|
|
||||||
if (controllers.hasOwnProperty(i)) {
|
|
||||||
var file = controllers[i];
|
|
||||||
var devel = false;
|
var devel = false;
|
||||||
var root;
|
var root;
|
||||||
|
|
||||||
|
@ -731,21 +735,52 @@ function routingAalApp (app, mount, options) {
|
||||||
root = module.appPath();
|
root = module.appPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var appContextTempl = app.createAppContext();
|
||||||
|
|
||||||
|
appContextTempl.mount = mount; // global mount
|
||||||
|
appContextTempl.options = options;
|
||||||
|
appContextTempl.collectionPrefix = prefix; // collection prefix
|
||||||
|
appContextTempl.basePath = fs.join(root, app._path);
|
||||||
|
|
||||||
|
appContextTempl.isDevelopment = devel;
|
||||||
|
appContextTempl.isProduction = ! devel;
|
||||||
|
|
||||||
|
var appContext;
|
||||||
|
var file;
|
||||||
|
|
||||||
|
// mount all exports
|
||||||
|
if (app._manifest.hasOwnProperty("exports")) {
|
||||||
|
var exps = app._manifest.exports;
|
||||||
|
|
||||||
|
for (i in exps) {
|
||||||
|
if (exps.hasOwnProperty(i)) {
|
||||||
|
file = exps[i];
|
||||||
|
var result = {};
|
||||||
|
var context = { exports: result };
|
||||||
|
|
||||||
|
appContext = Object.create(appContextTempl);
|
||||||
|
appContext.prefix = "/";
|
||||||
|
extendContext(appContext, app, root);
|
||||||
|
|
||||||
|
app.loadAppScript(appContext, file, { context: context });
|
||||||
|
|
||||||
|
app._exports[i] = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mount all controllers
|
||||||
|
var controllers = app._manifest.controllers;
|
||||||
|
|
||||||
|
for (i in controllers) {
|
||||||
|
if (controllers.hasOwnProperty(i)) {
|
||||||
|
file = controllers[i];
|
||||||
|
|
||||||
// set up a context for the application start function
|
// set up a context for the application start function
|
||||||
var appContext = app.createAppContext();
|
appContext = Object.create(appContextTempl);
|
||||||
|
|
||||||
appContext.mount = mount; // global mount
|
|
||||||
appContext.prefix = arangodb.normalizeURL("/" + i); // app mount
|
appContext.prefix = arangodb.normalizeURL("/" + i); // app mount
|
||||||
appContext.collectionPrefix = prefix; // collection prefix
|
|
||||||
appContext.options = options;
|
|
||||||
appContext.basePath = fs.join(root, app._path);
|
|
||||||
|
|
||||||
appContext.isDevelopment = devel;
|
|
||||||
appContext.isProduction = ! devel;
|
|
||||||
|
|
||||||
appContext.routingInfo = {};
|
appContext.routingInfo = {};
|
||||||
appContext.foxxes = [];
|
appContext.foxxes = [];
|
||||||
|
|
||||||
extendContext(appContext, app, root);
|
extendContext(appContext, app, root);
|
||||||
|
|
||||||
app.loadAppScript(appContext, file, { transform: transformScript(file) });
|
app.loadAppScript(appContext, file, { transform: transformScript(file) });
|
||||||
|
@ -796,10 +831,15 @@ function routingAalApp (app, mount, options) {
|
||||||
// install all files and assets
|
// install all files and assets
|
||||||
installAssets(app, routes);
|
installAssets(app, routes);
|
||||||
|
|
||||||
|
// remember mount point
|
||||||
|
MOUNTED_APPS[mount] = app;
|
||||||
|
|
||||||
// and return all routes
|
// and return all routes
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
|
delete MOUNTED_APPS[mount];
|
||||||
|
|
||||||
console.errorLines(
|
console.errorLines(
|
||||||
"Cannot compute Foxx application routes: %s", String(err.stack || err));
|
"Cannot compute Foxx application routes: %s", String(err.stack || err));
|
||||||
}
|
}
|
||||||
|
@ -1364,6 +1404,18 @@ exports.developmentMounts = function () {
|
||||||
return DEVELOPMENTMOUNTS;
|
return DEVELOPMENTMOUNTS;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief returns the app for a mount path
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
exports.mountedApp = function (path) {
|
||||||
|
if (MOUNTED_APPS.hasOwnProperty(path)) {
|
||||||
|
return MOUNTED_APPS[path]._exports;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
};
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- END-OF-FILE
|
// --SECTION-- END-OF-FILE
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
|
@ -106,6 +106,7 @@ Model = function (attributes) {
|
||||||
|
|
||||||
Model.fromClient = function (attributes) {
|
Model.fromClient = function (attributes) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var instance = new this();
|
var instance = new this();
|
||||||
instance.attributes = whitelistProperties(attributes, this.attributes, false);
|
instance.attributes = whitelistProperties(attributes, this.attributes, false);
|
||||||
instance.attributes = fillInDefaults(instance.attributes, this.attributes);
|
instance.attributes = fillInDefaults(instance.attributes, this.attributes);
|
||||||
|
|
Loading…
Reference in New Issue