From 50b65bca0cd89538b80bac5dba3a9b687d1c6f13 Mon Sep 17 00:00:00 2001 From: Katharina Irrgang Date: Thu, 14 Dec 2017 15:44:01 +0100 Subject: [PATCH] Moved default-cards app to lib/mobiledoc (#9341) refs #9178, refs https://github.com/TryGhost/Ghost/pull/9338 --- core/server/config/overrides.json | 3 +-- .../default-cards => lib/mobiledoc}/atoms/index.js | 0 .../mobiledoc}/atoms/soft-return.js | 0 .../{apps/default-cards => lib/mobiledoc}/cards/hr.js | 0 .../default-cards => lib/mobiledoc}/cards/html.js | 0 .../default-cards => lib/mobiledoc}/cards/image.js | 0 .../default-cards => lib/mobiledoc}/cards/index.js | 0 .../default-cards => lib/mobiledoc}/cards/markdown.js | 0 .../mobiledoc}/converters/index.js | 0 .../mobiledoc}/converters/markdown-converter.js | 0 .../mobiledoc}/converters/mobiledoc-converter.js | 10 +++++----- .../{apps/default-cards => lib/mobiledoc}/index.js | 0 core/server/models/post.js | 4 ++-- .../mobiledoc}/atoms/soft-return_spec.js | 2 +- .../default-cards => lib/mobiledoc}/cards/hr_spec.js | 2 +- .../default-cards => lib/mobiledoc}/cards/html_spec.js | 2 +- .../mobiledoc}/cards/image_spec.js | 2 +- .../mobiledoc}/cards/markdown_spec.js | 2 +- .../mobiledoc}/converters/mobiledoc-converter_spec.js | 2 +- core/test/unit/services/apps/lifecycle_spec.js | 10 ++++------ 20 files changed, 18 insertions(+), 21 deletions(-) rename core/server/{apps/default-cards => lib/mobiledoc}/atoms/index.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/atoms/soft-return.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/cards/hr.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/cards/html.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/cards/image.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/cards/index.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/cards/markdown.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/converters/index.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/converters/markdown-converter.js (100%) rename core/server/{apps/default-cards => lib/mobiledoc}/converters/mobiledoc-converter.js (86%) rename core/server/{apps/default-cards => lib/mobiledoc}/index.js (100%) rename core/test/unit/{apps/default-cards => lib/mobiledoc}/atoms/soft-return_spec.js (84%) rename core/test/unit/{apps/default-cards => lib/mobiledoc}/cards/hr_spec.js (85%) rename core/test/unit/{apps/default-cards => lib/mobiledoc}/cards/html_spec.js (94%) rename core/test/unit/{apps/default-cards => lib/mobiledoc}/cards/image_spec.js (88%) rename core/test/unit/{apps/default-cards => lib/mobiledoc}/cards/markdown_spec.js (93%) rename core/test/unit/{apps/default-cards => lib/mobiledoc}/converters/mobiledoc-converter_spec.js (91%) diff --git a/core/server/config/overrides.json b/core/server/config/overrides.json index 21d8bc6cc4..6e2809acd6 100644 --- a/core/server/config/overrides.json +++ b/core/server/config/overrides.json @@ -16,8 +16,7 @@ "internal": [ "private-blogging", "subscribers", - "amp", - "default-cards" + "amp" ] }, "routeKeywords": { diff --git a/core/server/apps/default-cards/atoms/index.js b/core/server/lib/mobiledoc/atoms/index.js similarity index 100% rename from core/server/apps/default-cards/atoms/index.js rename to core/server/lib/mobiledoc/atoms/index.js diff --git a/core/server/apps/default-cards/atoms/soft-return.js b/core/server/lib/mobiledoc/atoms/soft-return.js similarity index 100% rename from core/server/apps/default-cards/atoms/soft-return.js rename to core/server/lib/mobiledoc/atoms/soft-return.js diff --git a/core/server/apps/default-cards/cards/hr.js b/core/server/lib/mobiledoc/cards/hr.js similarity index 100% rename from core/server/apps/default-cards/cards/hr.js rename to core/server/lib/mobiledoc/cards/hr.js diff --git a/core/server/apps/default-cards/cards/html.js b/core/server/lib/mobiledoc/cards/html.js similarity index 100% rename from core/server/apps/default-cards/cards/html.js rename to core/server/lib/mobiledoc/cards/html.js diff --git a/core/server/apps/default-cards/cards/image.js b/core/server/lib/mobiledoc/cards/image.js similarity index 100% rename from core/server/apps/default-cards/cards/image.js rename to core/server/lib/mobiledoc/cards/image.js diff --git a/core/server/apps/default-cards/cards/index.js b/core/server/lib/mobiledoc/cards/index.js similarity index 100% rename from core/server/apps/default-cards/cards/index.js rename to core/server/lib/mobiledoc/cards/index.js diff --git a/core/server/apps/default-cards/cards/markdown.js b/core/server/lib/mobiledoc/cards/markdown.js similarity index 100% rename from core/server/apps/default-cards/cards/markdown.js rename to core/server/lib/mobiledoc/cards/markdown.js diff --git a/core/server/apps/default-cards/converters/index.js b/core/server/lib/mobiledoc/converters/index.js similarity index 100% rename from core/server/apps/default-cards/converters/index.js rename to core/server/lib/mobiledoc/converters/index.js diff --git a/core/server/apps/default-cards/converters/markdown-converter.js b/core/server/lib/mobiledoc/converters/markdown-converter.js similarity index 100% rename from core/server/apps/default-cards/converters/markdown-converter.js rename to core/server/lib/mobiledoc/converters/markdown-converter.js diff --git a/core/server/apps/default-cards/converters/mobiledoc-converter.js b/core/server/lib/mobiledoc/converters/mobiledoc-converter.js similarity index 86% rename from core/server/apps/default-cards/converters/mobiledoc-converter.js rename to core/server/lib/mobiledoc/converters/mobiledoc-converter.js index bc7045f056..50a36349dc 100644 --- a/core/server/apps/default-cards/converters/mobiledoc-converter.js +++ b/core/server/lib/mobiledoc/converters/mobiledoc-converter.js @@ -1,12 +1,12 @@ 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'), + common = require('../../common'), + atoms = require('../atoms'), + cards = require('../cards'), options = { dom: new SimpleDom.Document(), - cards: defaults.cards, - atoms: defaults.atoms, + cards: cards, + atoms: atoms, unknownCardHandler: function (args) { common.logging.error(new common.errors.InternalServerError({ message: 'Mobiledoc card \'' + args.env.name + '\' not found.' diff --git a/core/server/apps/default-cards/index.js b/core/server/lib/mobiledoc/index.js similarity index 100% rename from core/server/apps/default-cards/index.js rename to core/server/lib/mobiledoc/index.js diff --git a/core/server/models/post.js b/core/server/models/post.js index fe69c5830a..f9380b8886 100644 --- a/core/server/models/post.js +++ b/core/server/models/post.js @@ -11,7 +11,7 @@ var _ = require('lodash'), htmlToText = require('html-to-text'), ghostBookshelf = require('./base'), config = require('../config'), - defaultCardsApp = require('../apps/default-cards'), + converters = require('../lib/mobiledoc/converters'), urlService = require('../services/url'), Post, Posts; @@ -216,7 +216,7 @@ Post = ghostBookshelf.Model.extend({ ghostBookshelf.Model.prototype.onSaving.call(this, model, attr, options); if (mobiledoc) { - this.set('html', defaultCardsApp.converters.mobiledocConverter.render(JSON.parse(mobiledoc))); + this.set('html', converters.mobiledocConverter.render(JSON.parse(mobiledoc))); } if (this.hasChanged('html') || !this.get('plaintext')) { diff --git a/core/test/unit/apps/default-cards/atoms/soft-return_spec.js b/core/test/unit/lib/mobiledoc/atoms/soft-return_spec.js similarity index 84% rename from core/test/unit/apps/default-cards/atoms/soft-return_spec.js rename to core/test/unit/lib/mobiledoc/atoms/soft-return_spec.js index 7e4f88ba3d..ff89b2d1ab 100644 --- a/core/test/unit/apps/default-cards/atoms/soft-return_spec.js +++ b/core/test/unit/lib/mobiledoc/atoms/soft-return_spec.js @@ -1,5 +1,5 @@ var should = require('should'), // jshint ignore:line - card = require('../../../../../server/apps/default-cards/atoms/soft-return'), + card = require('../../../../../server/lib/mobiledoc/atoms/soft-return'), SimpleDom = require('simple-dom'), opts; diff --git a/core/test/unit/apps/default-cards/cards/hr_spec.js b/core/test/unit/lib/mobiledoc/cards/hr_spec.js similarity index 85% rename from core/test/unit/apps/default-cards/cards/hr_spec.js rename to core/test/unit/lib/mobiledoc/cards/hr_spec.js index 2c756befc5..f52a9e696b 100644 --- a/core/test/unit/apps/default-cards/cards/hr_spec.js +++ b/core/test/unit/lib/mobiledoc/cards/hr_spec.js @@ -1,5 +1,5 @@ var should = require('should'), // jshint ignore:line - card = require('../../../../../server/apps/default-cards/cards/hr'), + card = require('../../../../../server/lib/mobiledoc/cards/hr'), SimpleDom = require('simple-dom'), opts; diff --git a/core/test/unit/apps/default-cards/cards/html_spec.js b/core/test/unit/lib/mobiledoc/cards/html_spec.js similarity index 94% rename from core/test/unit/apps/default-cards/cards/html_spec.js rename to core/test/unit/lib/mobiledoc/cards/html_spec.js index 51127408a6..8d5fb50286 100644 --- a/core/test/unit/apps/default-cards/cards/html_spec.js +++ b/core/test/unit/lib/mobiledoc/cards/html_spec.js @@ -1,5 +1,5 @@ var should = require('should'), // jshint ignore:line - card = require('../../../../../server/apps/default-cards/cards/html'), + card = require('../../../../../server/lib/mobiledoc/cards/html'), SimpleDom = require('simple-dom'), opts; diff --git a/core/test/unit/apps/default-cards/cards/image_spec.js b/core/test/unit/lib/mobiledoc/cards/image_spec.js similarity index 88% rename from core/test/unit/apps/default-cards/cards/image_spec.js rename to core/test/unit/lib/mobiledoc/cards/image_spec.js index 52aff4330e..02b29e64f5 100644 --- a/core/test/unit/apps/default-cards/cards/image_spec.js +++ b/core/test/unit/lib/mobiledoc/cards/image_spec.js @@ -1,5 +1,5 @@ var should = require('should'), // jshint ignore:line - card = require('../../../../../server/apps/default-cards/cards/image'), + card = require('../../../../../server/lib/mobiledoc/cards/image'), SimpleDom = require('simple-dom'), opts; diff --git a/core/test/unit/apps/default-cards/cards/markdown_spec.js b/core/test/unit/lib/mobiledoc/cards/markdown_spec.js similarity index 93% rename from core/test/unit/apps/default-cards/cards/markdown_spec.js rename to core/test/unit/lib/mobiledoc/cards/markdown_spec.js index 99126316e5..64e025f877 100644 --- a/core/test/unit/apps/default-cards/cards/markdown_spec.js +++ b/core/test/unit/lib/mobiledoc/cards/markdown_spec.js @@ -1,5 +1,5 @@ var should = require('should'), // jshint ignore:line - card = require('../../../../../server/apps/default-cards/cards/markdown'), + card = require('../../../../../server/lib/mobiledoc/cards/markdown'), SimpleDom = require('simple-dom'), opts; diff --git a/core/test/unit/apps/default-cards/converters/mobiledoc-converter_spec.js b/core/test/unit/lib/mobiledoc/converters/mobiledoc-converter_spec.js similarity index 91% rename from core/test/unit/apps/default-cards/converters/mobiledoc-converter_spec.js rename to core/test/unit/lib/mobiledoc/converters/mobiledoc-converter_spec.js index 93c84c53c7..143658eb81 100644 --- a/core/test/unit/apps/default-cards/converters/mobiledoc-converter_spec.js +++ b/core/test/unit/lib/mobiledoc/converters/mobiledoc-converter_spec.js @@ -1,5 +1,5 @@ var should = require('should'), // jshint ignore:line - converter = require('../../../../../server/apps/default-cards/converters/mobiledoc-converter'); + converter = require('../../../../../server/lib/mobiledoc/converters/mobiledoc-converter'); describe('Convert mobiledoc to HTML ', function () { var mobiledoc = { diff --git a/core/test/unit/services/apps/lifecycle_spec.js b/core/test/unit/services/apps/lifecycle_spec.js index 0275d9af08..e56fe462c3 100644 --- a/core/test/unit/services/apps/lifecycle_spec.js +++ b/core/test/unit/services/apps/lifecycle_spec.js @@ -47,13 +47,12 @@ describe('Apps', function () { settingsEditStub.callCount.should.eql(0); // Test that activate is called 4 times, and install 0 time - loaderActivateStub.callCount.should.eql(4); + loaderActivateStub.callCount.should.eql(3); loaderInstallStub.callCount.should.eql(0); // Test that the 4 internal apps are loaded as expected - availableApps.should.be.an.Array().with.lengthOf(4); + availableApps.should.be.an.Array().with.lengthOf(3); availableApps.should.containEql('amp'); - availableApps.should.containEql('default-cards'); availableApps.should.containEql('private-blogging'); availableApps.should.containEql('subscribers'); @@ -81,13 +80,12 @@ describe('Apps', function () { settingsEditStub.firstCall.args[0].settings[0].value.should.eql(['testA', 'testB']); // Test that activate is called 6 times, and install only 1 time - loaderActivateStub.callCount.should.eql(6); + loaderActivateStub.callCount.should.eql(5); loaderInstallStub.callCount.should.eql(1); // Test that the 4 internal apps are loaded as expected - availableApps.should.be.an.Array().with.lengthOf(6); + availableApps.should.be.an.Array().with.lengthOf(5); availableApps.should.containEql('amp'); - availableApps.should.containEql('default-cards'); availableApps.should.containEql('private-blogging'); availableApps.should.containEql('subscribers'); availableApps.should.containEql('testA');