From 05944b6913a957c4af327c67764d6f50e3e53942 Mon Sep 17 00:00:00 2001 From: Matthieu Bergel Date: Mon, 15 Jan 2018 21:49:16 +0100 Subject: [PATCH] Updates following Ghost latest releases: - Ghost 1.19.0: Moved errors,logging,i18n and events to lib/common (https://github.com/TryGhost/Ghost/commit/ac2578b41), Moved utils/url.js to UrlService (https://github.com/TryGhost/Ghost/commit/4265afe58) - Ghost 1.19.1: moved markdown-converter to lib/mobiledoc (https://github.com/TryGhost/Ghost/pull/9341) Updated patch --- README.md | 3 ++- ...a_register_events.patch => ghost_algolia_init.patch | 6 +++--- index.js | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) rename ghost_algolia_register_events.patch => ghost_algolia_init.patch (78%) diff --git a/README.md b/README.md index 456e8bc..6597fe2 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Finally, add `importance` as a custom ranking attribute in the ranking tab under 5. Apply the `ghost_algolia_register_events.patch` patch found in the app download by running the following command from the ghost root: ```shell - patch -p1 < ./content/apps/ghost-algolia/ghost_algolia_register_events.patch + patch -p1 < ./content/apps/ghost-algolia/ghost_algolia_init.patch ``` 6. Restart ghost @@ -118,6 +118,7 @@ Bulk indexing happens automatically when Ghost is started, provided your Algolia # Compatibility Tested against Ghost 1.x.x releases. +The tagged releases of this repository using the SemVer format (x.x.x) are compatible with the same tagged releases in Ghost's repository (e.g. 1.20.0 here is compatible with Ghost 1.20.0). # Roadmap diff --git a/ghost_algolia_register_events.patch b/ghost_algolia_init.patch similarity index 78% rename from ghost_algolia_register_events.patch rename to ghost_algolia_init.patch index c1dc661..c1465c8 100644 --- a/ghost_algolia_register_events.patch +++ b/ghost_algolia_init.patch @@ -1,8 +1,8 @@ diff --git a/current/core/server/models/post-orig.js b/current/core/server/models/post.js -index f4c58c5..13e401f 100644 +index f9380b8..1c8163b 100644 --- a/current/core/server/models/post-orig.js +++ b/current/core/server/models/post.js -@@ -16,6 +16,13 @@ var _ = require('lodash'), +@@ -16,6 +16,13 @@ var _ = require('lodash'), Post, Posts; @@ -10,7 +10,7 @@ index f4c58c5..13e401f 100644 +// Temporary hack added by ghost-algolia +// (https://github.com/mlbrgl/ghost-algolia) +var ghostAlgolia = require(config.getContentPath('apps') + 'ghost-algolia'); -+ghostAlgolia.init(events, config, utils); ++ghostAlgolia.init(common.events, config, urlService.utils); +// -- END ghost-algolia -- + Post = ghostBookshelf.Model.extend({ diff --git a/index.js b/index.js index 5d755c4..6502f7b 100644 --- a/index.js +++ b/index.js @@ -17,14 +17,14 @@ // // module.exports = GhostAlgolia; -const converter = require('../../../current/core/server/utils/markdown-converter'), +const converter = require('../../../current/core/server/lib/mobiledoc/converters/markdown-converter'), client = require('../../../current/core/server/models').Client, indexFactory = require('./lib/indexFactory'), parserFactory = require('./lib/parserFactory'); const GhostAlgolia = { - init: (events, config, utils) => { - bulkIndex(events, config, utils); + init: (events, config, urlUtils) => { + bulkIndex(events, config, urlUtils); registerEvents(events, config); } }; @@ -32,12 +32,12 @@ const GhostAlgolia = { /* * Index all published posts at server start if Algolia indexing activated in config */ -function bulkIndex(events, config, utils){ +function bulkIndex(events, config, urlUtils){ // Emitted in ghost-server.js events.on('server:start', function(){ client.findOne({slug: 'ghost-frontend'}, {context: {internal: true}}) - .then((client) => getContent(utils.url.urlFor('api', true) + 'posts/?formats=mobiledoc&client_id=ghost-frontend&client_secret=' + client.attributes.secret)) + .then((client) => getContent(urlUtils.urlFor('api', true) + 'posts/?formats=mobiledoc&client_id=ghost-frontend&client_secret=' + client.attributes.secret)) .then((data) => { let posts = JSON.parse(data).posts; if(posts.length > 0) {