0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

[WIP] Mobile-Doc based renderer (#7437)

Refs #7429

Added mobile-doc renderer

------------

- Added generic mobiledoc-renderer
- Kept the existing showdown editor for legacy mode.
This commit is contained in:
Ryan McCarvill 2016-09-27 02:23:49 +13:00 committed by Katharina Irrgang
parent 6c24084e68
commit 7edc518d5a
2 changed files with 24 additions and 15 deletions

View file

@ -1,18 +1,20 @@
// # Post Model
var _ = require('lodash'),
uuid = require('node-uuid'),
moment = require('moment'),
Promise = require('bluebird'),
sequence = require('../utils/sequence'),
errors = require('../errors'),
Showdown = require('showdown-ghost'),
converter = new Showdown.converter({extensions: ['ghostgfm', 'footnotes', 'highlight']}),
ghostBookshelf = require('./base'),
events = require('../events'),
config = require('../config'),
utils = require('../utils'),
baseUtils = require('./base/utils'),
i18n = require('../i18n'),
var _ = require('lodash'),
uuid = require('node-uuid'),
moment = require('moment'),
Promise = require('bluebird'),
sequence = require('../utils/sequence'),
errors = require('../errors'),
Showdown = require('showdown-ghost'),
legacyConverter = new Showdown.converter({extensions: ['ghostgfm', 'footnotes', 'highlight']}),
Mobiledoc = require('mobiledoc-html-renderer').default,
converter = new Mobiledoc(),
ghostBookshelf = require('./base'),
events = require('../events'),
config = require('../config'),
utils = require('../utils'),
baseUtils = require('./base/utils'),
i18n = require('../i18n'),
Post,
Posts;
@ -156,6 +158,7 @@ Post = ghostBookshelf.Model.extend({
tagsToCheck = this.get('tags'),
publishedAt = this.get('published_at'),
publishedAtHasChanged = this.hasDateChanged('published_at'),
mobiledoc = this.get('mobiledoc'),
tags = [];
// CASE: disallow published -> scheduled
@ -205,7 +208,12 @@ Post = ghostBookshelf.Model.extend({
ghostBookshelf.Model.prototype.saving.call(this, model, attr, options);
this.set('html', converter.makeHtml(_.toString(this.get('markdown'))));
if (mobiledoc) {
this.set('html', converter.render(JSON.parse(mobiledoc)).result);
} else {
// legacy showdown mode
this.set('html', legacyConverter.makeHtml(_.toString(this.get('markdown'))));
}
// disabling sanitization until we can implement a better version
title = this.get('title') || i18n.t('errors.models.post.untitled');

View file

@ -54,6 +54,7 @@
"knex": "0.12.1",
"lodash": "4.16.0",
"moment": "2.15.1",
"mobiledoc-html-renderer": "0.3.0",
"moment-timezone": "0.5.5",
"morgan": "1.7.0",
"multer": "1.2.0",