mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
6f6c8f4521
refs #9178 - avoid importing 4 modules (logging, errors, events and i18n) - simply require common in each file
47 lines
1.6 KiB
JavaScript
47 lines
1.6 KiB
JavaScript
var SimpleDom = require('simple-dom'),
|
|
Renderer = require('mobiledoc-dom-renderer').default,
|
|
config = require('../config'),
|
|
common = require('../lib/common'),
|
|
defaults = require(config.get('paths').internalAppPath + 'default-cards'),
|
|
options = {
|
|
dom: new SimpleDom.Document(),
|
|
cards: defaults.cards,
|
|
atoms: defaults.atoms,
|
|
unknownCardHandler: function (args) {
|
|
common.logging.error(new common.errors.InternalServerError({
|
|
message: 'Mobiledoc card \'' + args.env.name + '\' not found.'
|
|
}));
|
|
}
|
|
};
|
|
|
|
// function getCards() {
|
|
// return config.get('apps:internal').reduce(
|
|
// 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() {
|
|
// return config.get('apps:internal').reduce(
|
|
// 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),
|
|
rendered = renderer.render(mobiledoc),
|
|
serializer = new SimpleDom.HTMLSerializer(SimpleDom.voidMap),
|
|
html = serializer.serializeChildren(rendered.result);
|
|
return html;
|
|
}
|
|
};
|