-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
35 lines (31 loc) · 1.18 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'use strict';
var _ = require('lodash'),
pkg = require('../../package.json');
module.exports = function (webinterface) {
webinterface.get('/', function(req, res) {
var app = webinterface.get('app'),
viewableModules = app.modules.filter(function (module) {
return module.viewId;
}),
config = viewableModules.map(function (module) {
return _.extend({ id: module.id, viewId: module.viewId, title: module.title }, module.config);
}),
ids = viewableModules.map(function (module) {
return module.id;
}),
data = viewableModules.map(function (module) {
return module.attributes;
}),
dataMap = _.zipObject(ids, data);
res.render('index', {
title: app.title,
modules: JSON.stringify(config),
dataMap: JSON.stringify(dataMap),
allViews: _.map(app.views, function (view) { return view.getFullHtml(); }).join(''),
dashboard: {
homepage: pkg.homepage,
version: pkg.version
}
});
});
};