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

🎨 🐛 Improve theme lib, middleware & error handling #8145

Merged
merged 7 commits into from
Mar 13, 2017

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Mar 13, 2017

This PR is groundwork, bug fixes, improved error handling and steps towards a better API:

  • Simplify the code in the theme loader so that we can...
  • ...TEMPORARILY move init up to themes/index.js to make it easier to work with when I start changing how we activate a theme
  • Reorder theme middleware in blog/app.js, we shouldn't be calling activate theme when requesting a shared asset.
  • Simpify & clarify what is actually happening in the theme middleware so I can move this code around more easily later
  • Make some really nice improvements to our error handling / warnings around missing themes - this all should make way more sense as a flow of logic now & really improves our ability to handle errors when something goes wrong with the theme
  • 🐛 Fix a quick bug with the asset hash config!
  • Finally, remove the concept of themes.read & move all the testing to themes.loader

Next up: new concept of theme activating vs mounting

- use loadOneTheme for init
- move updateThemeList to the one place that it is used
- this just reduces the surface area of the loader
- need to figure out what stuff goes in here as well as loading themes
- will move it again later once I've got it figured out
- move the order in blog/app.js so that theme middleware isn't called for shared assets
- add comments & cleanup in the middleware itself, for clarity
- Separate out config dependent on settings changing and config dependent on request
- Move blogApp.set('views') - no reason why this isn't in the theme activation method as
  it's actually simpler if it is there, we already know the active theme exists & can remove the if-guard
- ensure we display a warning
- don't have complex logic for handling errors
- move loading of an empty hbs object into the error-handler as this will support more cases
- asset hash wasn't correctly being set on theme switch
- Previousl, we've simplified loader & improved error handling
- We are now able to completely remove theme.read as it's nothing more than a wrapper for package.read
- This also means we can change our tests from testing the theme reader to loader
@ErisDS ErisDS changed the title 🎨 Improve theme lib, middleware & error handling 🎨 🐛 Improve theme lib, middleware & error handling Mar 13, 2017
@@ -69,7 +69,7 @@ themeHandler = {
});

// reset the asset hash
config.assetHash = null;
config.set('assetHash', null);

This comment was marked as abuse.

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 👍
I made a quick test, the basic functionality works.

@kirrg001 kirrg001 merged commit e060a4f into TryGhost:master Mar 13, 2017
@ErisDS ErisDS deleted the misc-theme-cleanup branch March 13, 2017 16:37
@ErisDS ErisDS added the themes label Mar 13, 2017
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