2017-11-01 16:44:54 +03:00
|
|
|
var SimpleDom = require('simple-dom'),
|
|
|
|
Renderer = require('mobiledoc-dom-renderer').default,
|
|
|
|
config = require('../config'),
|
2017-12-12 00:47:46 +03:00
|
|
|
common = require('../lib/common'),
|
2017-11-01 16:44:54 +03:00
|
|
|
defaults = require(config.get('paths').internalAppPath + 'default-cards'),
|
2017-03-14 21:07:33 +03:00
|
|
|
options = {
|
|
|
|
dom: new SimpleDom.Document(),
|
|
|
|
cards: defaults.cards,
|
2017-03-24 13:03:33 +03:00
|
|
|
atoms: defaults.atoms,
|
|
|
|
unknownCardHandler: function (args) {
|
2017-12-12 00:47:46 +03:00
|
|
|
common.logging.error(new common.errors.InternalServerError({
|
|
|
|
message: 'Mobiledoc card \'' + args.env.name + '\' not found.'
|
|
|
|
}));
|
2017-03-24 13:03:33 +03:00
|
|
|
}
|
2017-03-14 21:07:33 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// function getCards() {
|
2017-05-29 22:48:42 +03:00
|
|
|
// return config.get('apps:internal').reduce(
|
2017-03-14 21:07:33 +03:00
|
|
|
// function (cards, appName) {
|
|
|
|
// var app = require(path.join(config.get('paths').internalAppPath, appName));
|
|
|
|
// if (app.hasOwnProperty('cards')) {
|
|
|
|
// cards = cards.concat(app.cards);
|
|
|
|
// }
|
|
|
|
// return cards;
|
|
|
|
// }, [ ]);
|
|
|
|
// }
|
|
|
|
// function getAtoms() {
|
2017-05-29 22:48:42 +03:00
|
|
|
// return config.get('apps:internal').reduce(
|
2017-03-14 21:07:33 +03:00
|
|
|
// function (atoms, appName) {
|
|
|
|
// var app = require(path.join(config.get('paths').internalAppPath, appName));
|
|
|
|
// if (app.hasOwnProperty('atoms')) {
|
|
|
|
// atoms = atoms.concat(app.atoms);
|
|
|
|
// }
|
|
|
|
// return atoms;
|
|
|
|
// }, [ ]);
|
|
|
|
// }
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
render: function (mobiledoc) {
|
|
|
|
var renderer = new Renderer(options),
|
2017-11-01 16:44:54 +03:00
|
|
|
rendered = renderer.render(mobiledoc),
|
|
|
|
serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap),
|
|
|
|
html = serializer.serializeChildren(rendered.result);
|
2017-03-14 21:07:33 +03:00
|
|
|
return html;
|
|
|
|
}
|
|
|
|
};
|