Ghost/core/server/api
Katharina Irrgang 817b8d09ca 😱 🎨 Refactor storage adapter (#8229)
refs #7687

There are four main changes in this PR:

we have outsourced the base storage adapter to npm, because for storage developers it's annoying to inherit from a script within Ghost
we hacked theme storage handling into the default local storage adapter - this was reverted, instead we have added a static theme storage here
use classes instead of prototyping
optimise the storage adapter in general - everything is explained in each commit

----

* rename local-file-store to LocalFileStorage

I would like to keep the name pattern i have used for scheduling.
If a file is a class, the file name reflects the class name.
We can discuss this, if concerns are raised.

* Transform LocalFileStorage to class and inherit from new base

- inherit from npm ghost-storage-base
- rewrite to class
- no further refactoring, happens later

* Rename core/test/unit/storage/local-file-store_spec.js -> core/test/unit/storage/LocalFileStorage_spec.js

* Fix wrong require in core/test/unit/storage/LocalFileStorage_spec.js

* remove base storage and test

- see https://github.com/kirrg001/Ghost-Storage-Base
- the test has moved to this repo as well

* Use npm ghost-storage-base in storage/index.js

* remove the concept of getStorage('themes')

This concept was added when we added themes as a feature.
Back then, we have changed the local storage adapter to support images and themes.
This has added some hacks into the local storage adapters.
We want to revert this change and add a simple static theme storage.

Will adapt the api/themes layer in the next commits.

* Revert LocalFileStorage

- revert serve
- revert delete

* add storagePath as property to LocalFileStorage

- define one property which holds the storage path
- could be considered to pass from outside, but found that not helpful, as other storage adapters do not need this property
- IMPORTANT: save has no longer a targetDir option, because this was used to pass the alternative theme storage path
- IMPORTANT: exists has now an alternative targetDir, this makes sense, because
  - you can either ask the storage exists('my-file') and it will look in the base storage path
  - or you pass a specific path where to look exists('my-file', /path/to/dir)

* LocalFileStorage: get rid of store pattern

- getUniqueFileName(THIS)
- this doesn't make sense, instances always have access to this by default

* Add static theme storage

- inherits from the local file storage, because they both operate on the file system
- IMPORTANT: added a TODO to consider a merge of themes/loader and themes/storage
- but will be definitely not part of this PR

* Use new static theme storage in api/themes

- storage functions are simplified!

* Add https://github.com/kirrg001/Ghost-Storage-Base as dependency

- tarball for now, as i am still testing
- will release if PR review get's accepted

* Adapt tests and jscs/jshint

* 🐛  fix storage.read in favicon utility

- wrong implementation of error handling

* 🎨  optimise error messages for custom storage adapter errors

* little renaming in the storage utlity

- purpose is to have access to the custom storage instance and to the custom storage class
- see next commit why

* optimise instanceof base storage

- instanceof is always tricky in javascript
- if multiple modules exist, it can happen that instanceof is false

* fix getTargetDir

- the importer uses the `targetDir` option to ensure that images land in the correct folder

* ghost-storage-base@0.0.1 package.json dependency
2017-04-05 15:10:34 +01:00
..
app.js Move activation to themes endpoint (#8093) 2017-03-08 10:46:03 +00:00
authentication.js 🎨 Ghost bootstrap: optimise requires (#8121) 2017-03-13 20:07:12 +00:00
clients.js Error creation (#7477) 2016-10-06 13:27:35 +01:00
configuration.js 🔥 remove fileStorage option (#8144) 2017-03-14 10:31:33 +00:00
db.js 🔥 🎨 No more updateSettingsCache (#8090) 2017-03-02 23:00:01 +01:00
index.js Use "mounting" concept for active theme (#8193) 2017-03-21 10:03:09 +01:00
invites.js 🎨 add urlFor('admin') and increase usage of urlFor helper (#7935) 2017-02-02 18:51:35 +00:00
mail.js 🎨 😎 config env usages (#7929) 2017-02-03 18:25:39 +00:00
notifications.js replace auto increment id's by object id (#7495) 2016-11-17 09:09:11 +00:00
posts.js Error creation (#7477) 2016-10-06 13:27:35 +01:00
roles.js Refactor handlePermissions 2015-08-11 16:03:57 +02:00
schedules.js Error creation (#7477) 2016-10-06 13:27:35 +01:00
settings.js Themes API activation permissions & validation (#8104) 2017-03-13 12:44:44 +01:00
slack.js Slack integration 2016-05-08 12:49:15 +02:00
slugs.js Error creation (#7477) 2016-10-06 13:27:35 +01:00
subscribers.js Fixed issue where all only a few subscribers where exported via CSV. (#7925) 2017-02-08 11:37:09 +01:00
tags.js Error creation (#7477) 2016-10-06 13:27:35 +01:00
themes.js 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
upload.js feature: upload validation middleware (#7208) 2016-08-18 20:25:51 +01:00
users.js suspend user feature (#8114) 2017-03-13 12:03:26 +00:00
utils.js replace auto increment id's by object id (#7495) 2016-11-17 09:09:11 +00:00