Ghost/core/server
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
..
admin grunt dev admin livereload (#8176) 2017-03-30 13:27:07 +01:00
api 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
apps Helper Proxy & single express-hbs instance (#8225) 2017-04-04 18:07:35 +02:00
auth 🐛 fix owner user slug (#8263) 2017-04-04 14:56:04 +01:00
blog Split css server templates (#8234) 2017-04-04 10:06:38 +01:00
config 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
controllers/frontend Posts per page as theme-config (#8149) 2017-03-14 18:03:36 +01:00
data 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
events post-scheduling 2016-06-14 10:52:13 +02:00
helpers Helper Proxy & single express-hbs instance (#8225) 2017-04-04 18:07:35 +02:00
mail 🎨 Ghost bootstrap: optimise requires (#8121) 2017-03-13 20:07:12 +00:00
middleware 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
models Removed ghost editor dependency (#8137) 2017-03-14 18:07:33 +00:00
permissions 🐛 fix invite permissions for editor (#7889) 2017-01-25 12:07:31 +00:00
scheduling Shows help message for broken require in scheduler adapter (#7706) 2017-01-16 21:49:41 +01:00
settings 🔥 🎨 No more updateSettingsCache (#8090) 2017-03-02 23:00:01 +01:00
storage 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
themes 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
translations 🔥 🎨 Cleanup & simplify theme helpers (#8223) 2017-03-23 20:00:58 +01:00
utils Helper Proxy & single express-hbs instance (#8225) 2017-04-04 18:07:35 +02:00
views Split css server templates (#8234) 2017-04-04 10:06:38 +01:00
app.js 🐛 Fix the config for compression (#8226) 2017-04-03 10:58:07 +02:00
errors.js 🛠 use Ignition for logging/errors (#7869) 2017-01-23 11:04:01 +00:00
filters.js Misc grunt /dev updates 2015-05-28 20:25:14 +01:00
ghost-server.js Theme loading part 1 (#7989) 2017-02-22 00:26:19 +01:00
i18n.js improvement: general fixes 2016-06-01 07:07:20 +02:00
index.js 🎨 deny auto switch (#8086) 2017-03-02 19:50:58 +00:00
logging.js 🐛 forward missing logging config: rotation 2017-02-17 18:24:14 +01:00
overrides.js 🛠 update lodash,knex and bookshelf to latest versions 2016-09-26 10:20:55 +02:00
update-check.js 🎨 send LTS parameter if requesting the update check service (#7954) 2017-02-07 19:51:19 +01:00