Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Commit

Permalink
Updates following Ghost latest releases:
Browse files Browse the repository at this point in the history
- Ghost 1.19.0: Moved errors,logging,i18n and events to lib/common (TryGhost/Ghost@ac2578b41), Moved utils/url.js to UrlService (TryGhost/Ghost@4265afe58)
- Ghost 1.19.1: moved markdown-converter to lib/mobiledoc (TryGhost/Ghost#9341)

Updated patch
  • Loading branch information
mlbrgl committed Jan 15, 2018
1 parent 8dc488a commit 05944b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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;

+// -- BEGIN ghost-algolia --
+// 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({
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,27 @@
//
// 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);
}
};

/*
* 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) {
Expand Down

0 comments on commit 05944b6

Please sign in to comment.