summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-04-13 17:57:17 -0400
committerJules Laplace <jules@okfoc.us>2015-04-13 17:57:17 -0400
commit34f1ca02bea38e0b7ef185ebf07d3ec6df30f370 (patch)
tree234b767a8fef77a7a29ff8d0f519ba462129cb92 /app
parent3e255208a9776ad377f3b62d79d982138e89539a (diff)
split up the projects by category, add a schema flag so we can use the same singular template
Diffstat (limited to 'app')
-rw-r--r--app/index.js6
-rw-r--r--app/node_modules/okquery/index.js6
-rw-r--r--app/node_modules/okview/index.js2
3 files changed, 10 insertions, 4 deletions
diff --git a/app/index.js b/app/index.js
index 419adfc..7860f76 100644
--- a/app/index.js
+++ b/app/index.js
@@ -87,7 +87,6 @@ function OKCMS(options) {
this._createResources(resourceConfig, db, schemas);
var errorHandler = createErrorHandlerProducer(
templateProvider, adminTemplateProvider, debug);
-
// Create view instances from config
var views = this._views =
this._createViews(viewConfig, db, meta, resourceCache, templateProvider,
@@ -141,7 +140,7 @@ OKCMS.prototype._createResources = function(resourceConfig, db, schemaCache) {
var type = config.type;
var schema = schemaCache[type];
if (!schema)
- throw new Error('Resource config references nonexistent schema');
+ throw new Error('Resource config references nonexistent schema ' + type);
var resource = OKResource({
type: type,
db: db,
@@ -244,7 +243,8 @@ OKCMS.prototype._createQueries = function(queryConfig, resourceCache) {
var query = config.query || '*';
return new OKQuery({
resource: resource,
- query: query
+ query: query,
+ as: config.as,
});
});
};
diff --git a/app/node_modules/okquery/index.js b/app/node_modules/okquery/index.js
index 9cc8b78..519bc08 100644
--- a/app/node_modules/okquery/index.js
+++ b/app/node_modules/okquery/index.js
@@ -33,6 +33,12 @@ function OKQuery(options) {
enumerable: true
});
+ Object.defineProperty(this, 'as', {
+ value: options.as,
+ writable: false,
+ enumerable: true
+ });
+
this.get = createQuery(resource, query, {
default: options.default
});
diff --git a/app/node_modules/okview/index.js b/app/node_modules/okview/index.js
index 63f22b5..951261c 100644
--- a/app/node_modules/okview/index.js
+++ b/app/node_modules/okview/index.js
@@ -139,7 +139,7 @@ function fetchTemplateData(meta, queries, id) {
return cache;
}
var resource = queries[i].resource;
- var type = queries[i].type;
+ var type = queries[i].as || queries[i].type;
var manyResult = isarray(result);
// Inform template of ID in generic field
if (manyResult) {