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:
parent
6c24084e68
commit
7edc518d5a
2 changed files with 24 additions and 15 deletions
|
@ -6,7 +6,9 @@ var _ = require('lodash'),
|
|||
sequence = require('../utils/sequence'),
|
||||
errors = require('../errors'),
|
||||
Showdown = require('showdown-ghost'),
|
||||
converter = new Showdown.converter({extensions: ['ghostgfm', 'footnotes', 'highlight']}),
|
||||
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'),
|
||||
|
@ -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');
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue