diff options
| author | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-08 19:53:43 -0400 |
|---|---|---|
| committer | Sean Fridman <fridman@mail.sfsu.edu> | 2015-04-08 19:53:43 -0400 |
| commit | 51296eb133599d98dd05d04399898c42b1662ab5 (patch) | |
| tree | c9b6e7eadab9b5fb6df727581518b6a479eb966d /app/index.js | |
| parent | 47215a88acb2b4a612b6916f2f7b7a7660770c36 (diff) | |
Add static root to meta template info
Diffstat (limited to 'app/index.js')
| -rw-r--r-- | app/index.js | 36 |
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); |
