summaryrefslogtreecommitdiff
path: root/app/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/index.js')
-rw-r--r--app/index.js36
1 files changed, 29 insertions, 7 deletions
diff --git a/app/index.js b/app/index.js
index 792c10a..94d87dc 100644
--- a/app/index.js
+++ b/app/index.js
@@ -4,6 +4,7 @@ var withTrailingSlash = require('okutil').withTrailingSlash;
var withoutTrailingSlash = require('okutil').withoutTrailingSlash;
var assign = require('object-assign');
var express = require('express');
+var Q = require('q');
var OKQuery = require('okquery');
var OKView = require('okview');
var OKDB = require('okdb');
@@ -32,6 +33,34 @@ function OKCMS(options) {
var adminTemplateRoot = options.templateRoot ||
path.join(__dirname, '../themes/okadmin/templates');
+ // Set metadata defaults
+ // TODO Abstract this out somewhere else
+ var meta = {
+ type: 'meta',
+ get: function() {
+ return Q.promise(function(resolve, reject) {
+ db.getMeta().then(function(metadata) {
+ resolve(assign({}, {
+ static: ''
+ }, metadata));
+ }).fail(reject);
+ });
+ }
+ };
+
+ var adminMeta ={
+ type: 'meta',
+ get: function() {
+ return Q.promise(function(resolve, reject) {
+ db.getMeta().then(function(metadata) {
+ resolve(assign({}, {
+ static: withoutTrailingSlash(adminPath)
+ }, metadata));
+ }).fail(reject);
+ });
+ }
+ };
+
var schemaConfig = options.schemas || {};
var resourceConfig = options.resources || [];
var viewConfig = options.views || {
@@ -44,13 +73,6 @@ function OKCMS(options) {
new OKTemplate({root: adminTemplateRoot});
var db = new OKDB(options.db || 'fs');
- // Special query to get project wide meta data
- var meta = this._meta = {
- type: 'meta',
- get: function() {
- return db.getMeta();
- }
- };
var schemas = this._schemas = this._createSchemas(schemaConfig);
var resourceCache = this._resourceCache =
this._createResources(resourceConfig, db, schemas);