-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Theme API Audit #7491
Comments
refs TryGhost#7491, refs TryGhost#7488
closes #4172, closes #6948, refs #7491, refs #7488, refs #7542, refs #7484 * 🎨 Co-locate all admin-related code in /admin - move all the admin related code from controllers, routes and helpers into a single location - add error handling middleware explicitly to adminApp - re-order blogApp middleware to ensure the shared middleware is mounted after the adminApp - TODO: rethink the structure of /admin, this should probably be an internal app * 💄 Group global middleware together - There are only a few pieces of middleware which are "global" - These are needed for the admin, blog and api - Everything else is only needed in one or two places * ✨ Introduce a separate blogApp - create a brand-new blogApp - mount all blog/theme only middleware etc onto blogApp - mount error handling on blogApp only * 🎨 Separate error handling for HTML & API JSON - split JSON and HTML error handling into separate functions - re-introduce a way to not output the stack for certain errors - add more tests around errors & an assertion framework for checking JSON Errors - TODO: better 404 handling for static assets Rationale: The API is very different to the blog/admin panel: - It is intended to only ever serve JSON, never HTML responses - It is intended to always serve JSON Meanwhile the blog and admin panel have no need for JSON errors, when an error happens on those pages, we should serve HTML pages which are nicely formatted with the error & using the correct template * 🐛 Fix checkSSL to work for subapps - in order to make this work on a sub app we need to use the pattern `req.originalUrl || req.url` * 🔥 Get rid of decide-is-admin (part 1/2) - delete decide-is-admin & tests - add two small functions to apiApp and adminApp to set res.isAdmin - mount checkSSL on all the apps - TODO: deduplicate the calls to checkSSL by making blogApp a subApp :D - PART 2/2: finish cleaning this up by removing it from where it's not needed and giving it a more specific name Rationale: Now that we have both an adminApp and an apiApp, we can temporarily replace this weird path-matching middleware with middleware that sets res.isAdmin for api & admin * 🎨 Wire up prettyURLs on all Apps - prettyURLs is needed for all requests - it cannot be global because it has to live after asset middleware, and before routing - this does not result in duplicate redirects, but does result in duplicate checks - TODO: resolve extra middleware in stack by making blogApp a sub app * ⏱ Add debug to API setup * 🎨 Rename blogApp -> parentApp in middleware * 🎨 Co-locate all blog-related code in /blog - Move all of the blogApp code from middleware/index.js to blog/app.js - Move routes/frontend.js to blog/routes.js - Remove the routes/index.js and routes folder, this is empty now! - @todo is blog the best name for this? 🤔 - @todo sort out the big hunk of asset-related mess - @todo also separate out the concept of theme from blog * 🎉 Replace middleware index with server/app.js - The final piece of the puzzle! 🎉 🎈 🎂 - We no longer have our horrendous middleware/index.js - Instead, we have a set of app.js files, which all use a familiar pattern * 💄 Error handling fixups
closes TryGhost#4172, closes TryGhost#6948, refs TryGhost#7491, refs TryGhost#7488, refs TryGhost#7542, refs TryGhost#7484 * 🎨 Co-locate all admin-related code in /admin - move all the admin related code from controllers, routes and helpers into a single location - add error handling middleware explicitly to adminApp - re-order blogApp middleware to ensure the shared middleware is mounted after the adminApp - TODO: rethink the structure of /admin, this should probably be an internal app * 💄 Group global middleware together - There are only a few pieces of middleware which are "global" - These are needed for the admin, blog and api - Everything else is only needed in one or two places * ✨ Introduce a separate blogApp - create a brand-new blogApp - mount all blog/theme only middleware etc onto blogApp - mount error handling on blogApp only * 🎨 Separate error handling for HTML & API JSON - split JSON and HTML error handling into separate functions - re-introduce a way to not output the stack for certain errors - add more tests around errors & an assertion framework for checking JSON Errors - TODO: better 404 handling for static assets Rationale: The API is very different to the blog/admin panel: - It is intended to only ever serve JSON, never HTML responses - It is intended to always serve JSON Meanwhile the blog and admin panel have no need for JSON errors, when an error happens on those pages, we should serve HTML pages which are nicely formatted with the error & using the correct template * 🐛 Fix checkSSL to work for subapps - in order to make this work on a sub app we need to use the pattern `req.originalUrl || req.url` * 🔥 Get rid of decide-is-admin (part 1/2) - delete decide-is-admin & tests - add two small functions to apiApp and adminApp to set res.isAdmin - mount checkSSL on all the apps - TODO: deduplicate the calls to checkSSL by making blogApp a subApp :D - PART 2/2: finish cleaning this up by removing it from where it's not needed and giving it a more specific name Rationale: Now that we have both an adminApp and an apiApp, we can temporarily replace this weird path-matching middleware with middleware that sets res.isAdmin for api & admin * 🎨 Wire up prettyURLs on all Apps - prettyURLs is needed for all requests - it cannot be global because it has to live after asset middleware, and before routing - this does not result in duplicate redirects, but does result in duplicate checks - TODO: resolve extra middleware in stack by making blogApp a sub app * ⏱ Add debug to API setup * 🎨 Rename blogApp -> parentApp in middleware * 🎨 Co-locate all blog-related code in /blog - Move all of the blogApp code from middleware/index.js to blog/app.js - Move routes/frontend.js to blog/routes.js - Remove the routes/index.js and routes folder, this is empty now! - @todo is blog the best name for this? 🤔 - @todo sort out the big hunk of asset-related mess - @todo also separate out the concept of theme from blog * 🎉 Replace middleware index with server/app.js - The final piece of the puzzle! 🎉 🎈 🎂 - We no longer have our horrendous middleware/index.js - Instead, we have a set of app.js files, which all use a familiar pattern * 💄 Error handling fixups
closes TryGhost#4172, closes TryGhost#6948, refs TryGhost#7491, refs TryGhost#7488, refs TryGhost#7542, refs TryGhost#7484 * 🎨 Co-locate all admin-related code in /admin - move all the admin related code from controllers, routes and helpers into a single location - add error handling middleware explicitly to adminApp - re-order blogApp middleware to ensure the shared middleware is mounted after the adminApp - TODO: rethink the structure of /admin, this should probably be an internal app * 💄 Group global middleware together - There are only a few pieces of middleware which are "global" - These are needed for the admin, blog and api - Everything else is only needed in one or two places * ✨ Introduce a separate blogApp - create a brand-new blogApp - mount all blog/theme only middleware etc onto blogApp - mount error handling on blogApp only * 🎨 Separate error handling for HTML & API JSON - split JSON and HTML error handling into separate functions - re-introduce a way to not output the stack for certain errors - add more tests around errors & an assertion framework for checking JSON Errors - TODO: better 404 handling for static assets Rationale: The API is very different to the blog/admin panel: - It is intended to only ever serve JSON, never HTML responses - It is intended to always serve JSON Meanwhile the blog and admin panel have no need for JSON errors, when an error happens on those pages, we should serve HTML pages which are nicely formatted with the error & using the correct template * 🐛 Fix checkSSL to work for subapps - in order to make this work on a sub app we need to use the pattern `req.originalUrl || req.url` * 🔥 Get rid of decide-is-admin (part 1/2) - delete decide-is-admin & tests - add two small functions to apiApp and adminApp to set res.isAdmin - mount checkSSL on all the apps - TODO: deduplicate the calls to checkSSL by making blogApp a subApp :D - PART 2/2: finish cleaning this up by removing it from where it's not needed and giving it a more specific name Rationale: Now that we have both an adminApp and an apiApp, we can temporarily replace this weird path-matching middleware with middleware that sets res.isAdmin for api & admin * 🎨 Wire up prettyURLs on all Apps - prettyURLs is needed for all requests - it cannot be global because it has to live after asset middleware, and before routing - this does not result in duplicate redirects, but does result in duplicate checks - TODO: resolve extra middleware in stack by making blogApp a sub app * ⏱ Add debug to API setup * 🎨 Rename blogApp -> parentApp in middleware * 🎨 Co-locate all blog-related code in /blog - Move all of the blogApp code from middleware/index.js to blog/app.js - Move routes/frontend.js to blog/routes.js - Remove the routes/index.js and routes folder, this is empty now! - @todo is blog the best name for this? 🤔 - @todo sort out the big hunk of asset-related mess - @todo also separate out the concept of theme from blog * 🎉 Replace middleware index with server/app.js - The final piece of the puzzle! 🎉 🎈 🎂 - We no longer have our horrendous middleware/index.js - Instead, we have a set of app.js files, which all use a familiar pattern * 💄 Error handling fixups
Some things in this issue are a little unclear to me, but let me write down tasks and questions. Questions:
Required Tasks (not backward compatible)
Optional Tasks:
|
The work for this issue expanded a bit, because all of the code that currently makes themes work is split across config & settings in awkward ways. It was time to solve these problems so that we can move forward cleanly.
Two other new items:
|
refs TryGhost#7488, TryGhost#7491 - At the moment, we use the same asset helper function for both admin and theme - Both functions are (rightly or wrongly) a wrapper around meta.getAssetUrl() - The usecases in these contexts are v. different: - asset for the admin is used only in the generated index.html file - ghost="true" is always true in this case, except for the favicon which is ALREADY a separate case - minifyInProduction is only used to the admin panel, not documented or supposed to be used for themes - For themes, the helper doesn't take any arguments, it should just call to getAssetUrl() If we do want to introduce some sort of .min path adjuster we should give it a better name! - For the admin panel, minifyInProduction means exactly what it says - minify if env === production, it makes no sense IMO to move this to config because we control it and also plus "minifyAssets" made it sound like we had an asset pipeline when all this did was change the output from .js to .min.js or .css to .min.css
I have an open PR for everything now except for
As I forgot about these 😞 they are small at least. Notes:
I would also have liked to have made more progress with the asset helper, at least we have a plan for not sharing it between themes and admin again. More improvements can come in future without breaking changes, I think. |
refs TryGhost#7491 - this hack is so legacy I almost forgot about it 😈 - in the beginning of Ghost there were no post images - someone figured out you could do {{content words="0"}} and it would pull out the first image in your post - this was never documented, but enough theme developers found it that when we upgraded downsize to get rid of the bug - we needed to add a hack to keep compatibility. - This has to die in 🔥 for Ghost 1.0
refs #7491 - this hack is so legacy I almost forgot about it 😈 - in the beginning of Ghost there were no post images - someone figured out you could do {{content words="0"}} and it would pull out the first image in your post - this was never documented, but enough theme developers found it that when we upgraded downsize to get rid of the bug - we needed to add a hack to keep compatibility. - This has to die in 🔥 for Ghost 1.0
Further update - this is mostly as done as it will be for 1.0. Some cleanup work to do around the asset helper now that the admin-server split is done and lots of documentation to do along with updates to gscan. |
@ErisDS Could we raise one or two separate issues with the missing pieces and close this big issue? |
refs TryGhost#7491 - split themes_spec up into several files - clean up the code for configuration - ensure its tested
refs #7491 - split themes_spec up into several files - clean up the code for configuration - ensure its tested
I'm currently working through, reviewing all the open (and many closed) issues & PRs with the
themes
label. In doing this, I'm collecting together a set of quick wins & bigger changes I want to make as part of the alpha process.This should feed into a set of subtasks/issues, and ultimately into a blog post about what's changing.
Known things which need extended reviews:
Other tasks:
The plan is that, with the exception of features that have been deprecated for over a year, like some of the body classes and
page_url
, although some changes may be required for a theme to work with Ghost 1.0.0, themes that work with 1.0.0 should also work on the 0.11 LTS branch. E.g, themes can be prepared in advance of the release of Ghost 1.0.0.Error handling:
The text was updated successfully, but these errors were encountered: