mirror of
https://github.com/TryGhost/Ghost.git
synced 2023-12-13 21:00:40 +01: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 _ = require('lodash');
|
||||||
const debug = require('ghost-ignition').debug('api:canary:utils:serializers:input:pages');
|
const debug = require('ghost-ignition').debug('api:canary:utils:serializers:input:pages');
|
||||||
const mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
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 url = require('./utils/url');
|
||||||
const localUtils = require('../../index');
|
const localUtils = require('../../index');
|
||||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||||
|
@ -143,7 +143,7 @@ module.exports = {
|
||||||
const html = frame.data.pages[0].html;
|
const html = frame.data.pages[0].html;
|
||||||
|
|
||||||
if (frame.options.source === 'html' && !_.isEmpty(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 mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
||||||
const url = require('./utils/url');
|
const url = require('./utils/url');
|
||||||
const localUtils = require('../../index');
|
const localUtils = require('../../index');
|
||||||
const renderers = require('../../../../../lib/mobiledoc/renderers');
|
const mobiledoc = require('../../../../../lib/mobiledoc');
|
||||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||||
|
|
||||||
const replacePageWithType = mapNQLKeyValues({
|
const replacePageWithType = mapNQLKeyValues({
|
||||||
|
@ -159,7 +159,7 @@ module.exports = {
|
||||||
const html = frame.data.posts[0].html;
|
const html = frame.data.posts[0].html;
|
||||||
|
|
||||||
if (frame.options.source === 'html' && !_.isEmpty(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 _ = require('lodash');
|
||||||
const mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
const mapNQLKeyValues = require('../../../../../../shared/nql-map-key-values');
|
||||||
const debug = require('ghost-ignition').debug('api:v2:utils:serializers:input:pages');
|
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 url = require('./utils/url');
|
||||||
const localUtils = require('../../index');
|
const localUtils = require('../../index');
|
||||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||||
|
@ -143,7 +143,7 @@ module.exports = {
|
||||||
const html = frame.data.pages[0].html;
|
const html = frame.data.pages[0].html;
|
||||||
|
|
||||||
if (frame.options.source === 'html' && !_.isEmpty(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 debug = require('ghost-ignition').debug('api:v2:utils:serializers:input:posts');
|
||||||
const url = require('./utils/url');
|
const url = require('./utils/url');
|
||||||
const localUtils = require('../../index');
|
const localUtils = require('../../index');
|
||||||
const renderers = require('../../../../../lib/mobiledoc/renderers');
|
const mobiledoc = require('../../../../../lib/mobiledoc');
|
||||||
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
const postsMetaSchema = require('../../../../../data/schema').tables.posts_meta;
|
||||||
|
|
||||||
const replacePageWithType = mapNQLKeyValues({
|
const replacePageWithType = mapNQLKeyValues({
|
||||||
|
@ -159,7 +159,7 @@ module.exports = {
|
||||||
const html = frame.data.posts[0].html;
|
const html = frame.data.posts[0].html;
|
||||||
|
|
||||||
if (frame.options.source === 'html' && !_.isEmpty(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 = {
|
const common = require('../common');
|
||||||
activate() {
|
|
||||||
// needed by ghost
|
|
||||||
},
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
get cards() {
|
get cards() {
|
||||||
return require('./cards');
|
return require('./cards');
|
||||||
},
|
},
|
||||||
|
@ -13,5 +11,21 @@ module.exports = {
|
||||||
|
|
||||||
get renderers() {
|
get renderers() {
|
||||||
return require('./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 = {
|
module.exports = {
|
||||||
get mobiledocHtmlRenderer() {
|
get mobiledocHtmlRenderer() {
|
||||||
return require('./mobiledoc-html-renderer');
|
return require('./mobiledoc-html-renderer');
|
||||||
|
@ -7,21 +5,5 @@ module.exports = {
|
||||||
|
|
||||||
get markdownHtmlRenderer() {
|
get markdownHtmlRenderer() {
|
||||||
return require('./markdown-html-renderer');
|
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…
Reference in a new issue