mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-15 03:01:37 -05:00
Moved htmlToMobiledocConverter()
out of renderers
no issue - prep for extraction of various Koenig repos - html->mobiledoc doesn't really fit into the "renderer" naming as it's more of a converter than a renderer and doesn't follow the same pattern
This commit is contained in:
parent
4949ad9214
commit
0741114d11
6 changed files with 26 additions and 30 deletions
|
@ -1,7 +1,7 @@
|
|||
const _ = require('lodash');
|
||||
const debug = require('ghost-ignition').debug('api:canary:utils:serializers:input:pages');
|
||||
const mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
||||
const renderers = require('../../../../../lib/mobiledoc/renderers');
|
||||
const mobiledoc = require('../../../../../lib/mobiledoc');
|
||||
const url = require('./utils/url');
|
||||
const localUtils = require('../../index');
|
||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||
|
@ -143,7 +143,7 @@ module.exports = {
|
|||
const html = frame.data.pages[0].html;
|
||||
|
||||
if (frame.options.source === 'html' && !_.isEmpty(html)) {
|
||||
frame.data.pages[0].mobiledoc = JSON.stringify(renderers.htmlToMobiledocConverter(html));
|
||||
frame.data.pages[0].mobiledoc = JSON.stringify(mobiledoc.htmlToMobiledocConverter(html));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const debug = require('ghost-ignition').debug('api:canary:utils:serializers:inpu
|
|||
const mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
||||
const url = require('./utils/url');
|
||||
const localUtils = require('../../index');
|
||||
const renderers = require('../../../../../lib/mobiledoc/renderers');
|
||||
const mobiledoc = require('../../../../../lib/mobiledoc');
|
||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||
|
||||
const replacePageWithType = mapNQLKeyValues({
|
||||
|
@ -159,7 +159,7 @@ module.exports = {
|
|||
const html = frame.data.posts[0].html;
|
||||
|
||||
if (frame.options.source === 'html' && !_.isEmpty(html)) {
|
||||
frame.data.posts[0].mobiledoc = JSON.stringify(renderers.htmlToMobiledocConverter(html));
|
||||
frame.data.posts[0].mobiledoc = JSON.stringify(mobiledoc.htmlToMobiledocConverter(html));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const _ = require('lodash');
|
||||
const mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
||||
const debug = require('ghost-ignition').debug('api:v2:utils:serializers:input:pages');
|
||||
const renderers = require('../../../../../lib/mobiledoc/renderers');
|
||||
const mobiledoc = require('../../../../../lib/mobiledoc');
|
||||
const url = require('./utils/url');
|
||||
const localUtils = require('../../index');
|
||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||
|
@ -143,7 +143,7 @@ module.exports = {
|
|||
const html = frame.data.pages[0].html;
|
||||
|
||||
if (frame.options.source === 'html' && !_.isEmpty(html)) {
|
||||
frame.data.pages[0].mobiledoc = JSON.stringify(renderers.htmlToMobiledocConverter(html));
|
||||
frame.data.pages[0].mobiledoc = JSON.stringify(mobiledoc.htmlToMobiledocConverter(html));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
|||
const debug = require('ghost-ignition').debug('api:v2:utils:serializers:input:posts');
|
||||
const url = require('./utils/url');
|
||||
const localUtils = require('../../index');
|
||||
const renderers = require('../../../../../lib/mobiledoc/renderers');
|
||||
const mobiledoc = require('../../../../../lib/mobiledoc');
|
||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||
|
||||
const replacePageWithType = mapNQLKeyValues({
|
||||
|
@ -159,7 +159,7 @@ module.exports = {
|
|||
const html = frame.data.posts[0].html;
|
||||
|
||||
if (frame.options.source === 'html' && !_.isEmpty(html)) {
|
||||
frame.data.posts[0].mobiledoc = JSON.stringify(renderers.htmlToMobiledocConverter(html));
|
||||
frame.data.posts[0].mobiledoc = JSON.stringify(mobiledoc.htmlToMobiledocConverter(html));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
module.exports = {
|
||||
activate() {
|
||||
// needed by ghost
|
||||
},
|
||||
const common = require('../common');
|
||||
|
||||
module.exports = {
|
||||
get cards() {
|
||||
return require('./cards');
|
||||
},
|
||||
|
@ -13,5 +11,21 @@ module.exports = {
|
|||
|
||||
get renderers() {
|
||||
return require('./renderers');
|
||||
},
|
||||
|
||||
get htmlToMobiledocConverter() {
|
||||
try {
|
||||
return require('@tryghost/html-to-mobiledoc').toMobiledoc;
|
||||
} catch (err) {
|
||||
return () => {
|
||||
throw new common.errors.InternalServerError({
|
||||
message: 'Unable to convert from source HTML to Mobiledoc',
|
||||
context: 'The html-to-mobiledoc package was not installed',
|
||||
help: 'Please review any errors from the install process by checking the Ghost logs',
|
||||
code: 'HTML_TO_MOBILEDOC_INSTALLATION',
|
||||
err: err
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const common = require('../../common');
|
||||
|
||||
module.exports = {
|
||||
get mobiledocHtmlRenderer() {
|
||||
return require('./mobiledoc-html-renderer');
|
||||
|
@ -7,21 +5,5 @@ module.exports = {
|
|||
|
||||
get markdownHtmlRenderer() {
|
||||
return require('./markdown-html-renderer');
|
||||
},
|
||||
|
||||
get htmlToMobiledocConverter() {
|
||||
try {
|
||||
return require('@tryghost/html-to-mobiledoc').toMobiledoc;
|
||||
} catch (err) {
|
||||
return () => {
|
||||
throw new common.errors.InternalServerError({
|
||||
message: 'Unable to convert from source HTML to Mobiledoc',
|
||||
context: 'The html-to-mobiledoc package was not installed',
|
||||
help: 'Please review any errors from the install process by checking the Ghost logs',
|
||||
code: 'HTML_TO_MOBILEDOC_INSTALLATION',
|
||||
err: err
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue