nanek / ghost-s3-compat

Read and write images from S3 in the Ghost blogging platfrom
Other
56 stars 18 forks source link

Update storage adapter for ghost 0.10 compatability #11

Closed acburdine closed 8 years ago

acburdine commented 8 years ago

closes #10

I'm not sure how this works with older versions of ghost, so my recommendation is to release a new major version after this is merged.

This has been tested and ghost 0.10 boots up with these changes 😄

JuanCaicedo commented 8 years ago

My apologies for the delay on this, I just want to test this on ghost 0.7 to know if it's compatible. We're going to continue with that version at SpanishDict, but we can lock our dependency on a certain version of this module as opposed to holding up development for others :)

JuanCaicedo commented 8 years ago

Again, sorry for the delay. I can verify this works on ghost 0.7, so i think we'll roll out a minor version following this PR.

@acburdine what do you think of the two changes suggested by @aorcsik? They seem reasonable to me, but I'm not familiar with the ghost internals to know

acburdine commented 8 years ago

@JuanCaicedo sorry for the delay on this. The changes sound good, will implement and push them hopefully tonight or tomorrow.

aorcsik commented 8 years ago

FYI: In the meantime, I forked and added my changes to the adapter and implemented the missing functions too: https://github.com/aorcsik/ghost-s3-storage-adapter

pascalandy commented 8 years ago

Hey guys!

I'm having this issue:

npm info it worked if it ends with ok
npm info using npm@2.15.9
npm info using node@v4.6.0
npm info prestart ghost@0.11.0
npm info start ghost@0.11.0

> ghost@0.11.0 start /usr/src/ghost
> node index

ERROR: Your storage adapter does not inherit from the Storage Base.

 Error
    at Error.IncorrectUsage (/usr/src/ghost/core/server/errors/incorrect-usage.js:3:18)
    at Object.getStorage (/usr/src/ghost/core/server/storage/index.js:54:15)
    at setupMiddleware (/usr/src/ghost/core/server/middleware/index.js:126:44)
    at /usr/src/ghost/core/server/index.js:142:9
    at tryCatcher (/usr/src/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromise0 (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:685:18)
    at Promise._fulfill (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:630:18)
    at PromiseArray._resolve (/usr/src/ghost/node_modules/bluebird/js/release/promise_array.js:125:19)
    at PromiseArray._promiseFulfilled (/usr/src/ghost/node_modules/bluebird/js/release/promise_array.js:143:14)
    at Promise._settlePromise (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:566:26)
    at Promise._settlePromise0 (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/usr/src/ghost/node_modules/bluebird/js/release/promise.js:685:18)
    at Async._drainQueue (/usr/src/ghost/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/usr/src/ghost/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/usr/src/ghost/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

Any ideas?

acburdine commented 8 years ago

@pascalandy that's because this adapter hasn't been updated yet to be compatible with > ghost 0.10

Speaking of.... @JuanCaicedo I meant to get the fixes implemented, but then my computer died. Am on a backup laptop and will get the fixes added :)

JuanCaicedo commented 8 years ago

@acburdine Sounds good, if you have trouble let me know and I can either cherry pick from @aorcsik's branch or branch off yours

pascalandy commented 8 years ago

Cool @acburdine. We need this badly :)

///

P.S. I know John have a working version of this on Ghost 0.11.0 - https://github.com/jwasham/docker-ghost-template/tree/master/ghost . When cloning his repo, I'm still getting the same issue.

aorcsik commented 8 years ago

@pascalandy you can try using my fork while waiting for the update: https://www.npmjs.com/package/ghost-s3-storage-adapter I have a working 0.11.0 ghost blog that uses it.

pascalandy commented 8 years ago

@aorcsik Just tried many time ghost still refuse to start.

I'm also trying via docker and I get the same result - https://github.com/jwasham/docker-ghost-template/blob/master/ghost/Dockerfile

pascalandy commented 8 years ago

@aorcsik can you show me your tree under path /usr/src/ghost/content/storage/ ?

Here is what I got

cd /usr/src/ghost/content/storage/ghost-s3 && ls -lh total 4.0K drwxr-xr-x 3 root root 4.0K Oct 8 03:20 ghost-s3-storage-adapter check11

cd /usr/src/ghost/content/storage/ghost-s3/ghost-s3-storage-adapter && ls -lh total 28K -rw-r--r-- 1 root root 1.5K Oct 8 03:20 CHANGELOG.md -rw-r--r-- 1 root root 1.2K Oct 8 03:20 LICENSE -rw-r--r-- 1 root root 2.4K Oct 8 03:20 README.md -rw-r--r-- 1 root root 5.6K Oct 8 03:20 index.js drwxr-xr-x 4 root root 4.0K Oct 8 03:20 node_modules -rw-r--r-- 1 root root 1.8K Oct 8 03:20 package.json check12

cd /usr/src/ghost && ls -lh -rw-r--r-- 1 root root 35K Sep 30 22:21 Gruntfile.js -rw-r--r-- 1 root root 1.1K Sep 30 22:21 LICENSE -rw-r--r-- 1 root root 2.9K Sep 30 22:21 PRIVACY.md -rw-r--r-- 1 root root 4.6K Sep 30 22:21 README.md -rw-r--r-- 1 root root 4.5K Sep 30 22:21 config.example.js drwxr-xr-x 7 root root 4.0K Oct 8 03:20 content drwxr-xr-x 5 root root 4.0K Sep 30 22:31 core -rw-r--r-- 1 root root 725 Sep 30 22:21 index.js drwxr-xr-x 104 root root 4.0K Oct 8 03:20 node_modules -rw-r--r-- 1 root root 148K Sep 30 22:30 npm-shrinkwrap.json -rw-r--r-- 1 root root 3.1K Sep 30 22:21 package.json check13

COPY ./copy/index.js content/storage/ghost-s3

cd /usr/src/ghost/content/storage/ghost-s3 && ls -lh total 8.0K drwxr-xr-x 3 root root 4.0K Oct 8 03:20 ghost-s3-storage-adapter -rwxr-xr-x 1 root root 67 Oct 8 02:33 index.js check14

cat index.js 'use strict'; module.exports = require('ghost-s3-storage-adapter')

Thanks for you help :)

aorcsik commented 8 years ago

@pascalandy there are two ways to use the adapter and you try to use both at the same time.

First install the adapter with npm:

$ npm install ghost-s3-storage-adapter

Now either move it from node modules to the storage folder renaming it to ghost-s3:

$ mv [PROJECT]/node-modules/ghost-s3-storage-adapter [PROJECT]/content/storage/ghost-s3

Or simply create the ghost-s3 folder with and index.js, then require and export the installed ghost-s3-storage-adapter:

$ mkdir [PROJECT]/content/storage/ghost-s3
$ touch [PROJECT]/content/storage/ghost-s3/index.js

Add this line to index.js:

module.exports = require('ghost-s3-storage-adapter')

I use the latter, because it's cleaner and I use ghost as a dependency for my blog.

My tree for [PROJECT]/content/storage:

.
└── ghost-s3
    └── index.js

1 directory, 1 file
pascalandy commented 8 years ago

@aorcsik Thanks for clarifying!

JuanCaicedo commented 8 years ago

@acburdine any luck? If you find yourself pretty busy, I could make a follow up PR off this one with the changes suggested

pascalandy commented 8 years ago

This might help everyone as well - https://github.com/kelyvin/ghost-s3-service/issues/1#issuecomment-254424540

Cheers!

acburdine commented 8 years ago

@JuanCaicedo sorry for the delay - will pull this and do a quick test to make sure it works

acburdine commented 8 years ago

@JuanCaicedo this should be good to go now 😄 You might do a quick check with your own setup just to make sure this didn't break anything

JuanCaicedo commented 8 years ago

@acburdine Works great, thank you! I'll release a minor version