Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”₯✨ No more availableThemes #8085

Merged
merged 6 commits into from
Mar 2, 2017

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Mar 2, 2017

I've been waiting to push up this PR for quite a while 😹

refs #7491

  • This PR completely removes the concept of "availableThemes" from both config & settings.
  • It replaces it instead with a concept of themes.list. Which has a nice API similar to our shiny new settings cache.
  • This opens the door for significant further simplification of code in the settings API/models etc.

TODO:
The last commit has a list of areas I'm still not happy with - the API for themes lib is confusing, we want to be able to hide away much more internal logic and make it easier for the themes JSON API to interact with this library.

I also need to improve test coverage around the themes lib, I have deliberately left this as I want the structure of the objects to change.

NOTE: master still has zero support for custom templates and custom error templates 😁 Will fix that after this goes in.

- this gets rid of the only places where settings.availableThemes are used
- this is no longer used anywhere
- also get rid of every related call to updateSettingsCache
- Creates a tailor-made in-memory cache for themes inside the theme module
- Add methods for getting & setting items on the cache
- Move all references to config.availableThemes to use the new cache
- This can be abstracted later to support other kinds of caches?
Still TODO: simplifying/clarifying:
- what is the structure of the internal list
- what is the difference between a package list, and a theme list?
- what is the difference between reading a theme and loading it?
- how do we update the theme list (add/remove)
- how do we refresh the theme list? (hot reload?!)
- how do we get from an internal list, to one that is sent as part of the API?
- how are we going to handle theme storage: read/write, such that the path is configurable
res;

// @TODO: remove availableThemes from settings cache and create an endpoint to fetch themes
if (settings.activeTheme && themes) {

This comment was marked as abuse.

};

module.exports = {
init: initThemes,
load: loadThemes
loadAllThemes: loadAllThemes,

This comment was marked as abuse.

This comment was marked as abuse.


if (!theme) {
throw new errors.NotFoundError({message: i18n.t('errors.api.themes.themeDoesNotExist')});
}

themeUtils.list.del(name);

This comment was marked as abuse.

This comment was marked as abuse.

delete themeListCache[key];
},

init: function init(themes) {

This comment was marked as abuse.

This comment was marked as abuse.

debug('loading themes', Object.keys(themes));
config.set('paths:availableThemes', themes);
settingsApi.updateSettingsCache();
list.init(themes);

This comment was marked as abuse.

This comment was marked as abuse.

delete themeListCache[key];
},

init: function init(themes) {

This comment was marked as abuse.

This comment was marked as abuse.

@ErisDS
Copy link
Member Author

ErisDS commented Mar 2, 2017

Done + travis has finally finished 😁

Copy link
Contributor

@kirrg001 kirrg001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM πŸ‘

@kirrg001 kirrg001 merged commit f8b498d into TryGhost:master Mar 2, 2017
@ErisDS ErisDS deleted the no-more-availablethemes branch March 2, 2017 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants