Turn your audience into a business. Publishing, memberships, subscriptions and newsletters.
Go to file
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
.github Fix broken troubleshooting link in contributing.md (#7481) 2016-10-04 18:04:18 +01:00
content Upgrading Casper to ghost-1.0 2017-03-14 18:13:39 +01:00
core 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
.editorconfig Various post-repo-split cleanup (#6910) 2016-07-12 11:55:46 -06:00
.gitignore 🔥 Remove handlebars from serving admin (#8184) 2017-03-20 12:00:18 +00:00
.gitmodules Add Admin-Client as submodule at core/client 2016-05-19 14:20:18 +01:00
.jscsrc Various post-repo-split cleanup (#6910) 2016-07-12 11:55:46 -06:00
.jshintrc 🎨 jsHint: support ES6 features (#7920) 2017-01-31 13:13:23 +00:00
.npmignore 🐛 Ensure that admin templates are on npm 2017-03-23 11:05:50 -05:00
.travis.yml 🎨 Updates for Gruntfile (#8158) 2017-03-14 13:51:32 +00:00
Gruntfile.js 🛠 switch to using yarn in our Grunt tasks (#8261) 2017-04-04 11:47:12 +01:00
index.js ⏱ Boot time visibility amends (#7984) 2017-02-17 16:27:02 +01:00
LICENSE 2017 (#7819) 2017-01-04 10:05:57 +00:00
MigratorConfig.js 🎨 optimise requires for MigratorConfig (#8088) 2017-03-02 16:02:23 +00:00
package.json 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00
PRIVACY.md Switch to new native system font stack (#7219) 2016-08-18 20:29:46 +01:00
README.md 🛠 switch to using yarn in our Grunt tasks (#8261) 2017-04-04 11:47:12 +01:00
SECURITY.md Update SECURITY.md 2016-01-13 18:22:09 +02:00
yarn.lock 😱 🎨 Refactor storage adapter (#8229) 2017-04-05 15:10:34 +01:00

Ghost Build status

Warning: Major release in progress. Expect things to be broken in master.

The project is maintained by a non-profit organisation called the Ghost Foundation, along with an amazing group of independent contributors. We're trying to make publishing software that changes the shape of online journalism.

NOTE: If youre stuck, cant get something working or need some help, please head on over and join our Slack community rather than opening an issue.

 

Ghost 1.0-alpha Developer Install

Please note: These are the install instructions for Ghost 1.0-alpha, which is not stable. If you're looking for the latest release of Ghost, check out the stable branch or the latest release. If you get stuck, come say hi over on slack!

Important: Ghost uses yarn rather than npm to manage it's dependencies. Ensure that you have it installed and you have configured your PATH environment variable for it to work correctly. We recommend the "Installation Script" instructions because it works better with nvm but choose the best option for your development setup.

Install and run Ghost.

git clone git@github.com:TryGhost/Ghost.git ghost
    Download the Ghost code base
npm run init
    Short command for: yarn global add knex-migrator ember-cli grunt-cli && yarn install && grunt init
knex-migrator init
    Creates and initialises your database
grunt dev
    Starts the express server and ember build

Run server tests

grunt test-all

Run client tests

cd core/client
ember test

Read more about the development workflows.

Deploying Ghost

Ghost(Pro)

The easiest way to deploy Ghost is with our official Ghost(Pro) managed service. You can have a fresh instance up and running in a couple of clicks with a worldwide CDN, backups, security and maintenance all done for you.

Not only will it save you many hours per month, but all revenue goes to the Ghost Foundation, which funds the maintenance and further development of Ghost itself. So youll be supporting open source software and getting a great service at the same time! Talk about win/win. 🏆

Other options are also available if you prefer playing around with servers by yourself, of course. The freedom of choice is in your hands.

 

Staying Up to Date

When a new version of Ghost comes out, you'll want to look over these upgrade instructions for what to do next.

You can talk to other Ghost users and developers in our public Slack team (it's pretty awesome). We have a public meeting every Tuesday at 5:30pm UK time.

New releases are announced on the dev blog. You can subscribe by email or follow @TryGhost_Dev on Twitter, if you prefer your updates bite-sized and facetious. 🎷🐢

 

Copyright & License

Copyright (c) 2013-2017 Ghost Foundation - Released under the MIT license.