mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-16 20:43:01 +03:00
59e2694acf
* 💄 Combine slashes & uncapitalise middleware - these bits of middleware belong together - ideally they should be optimised * 🎨 Move ghostLocals out of themeHandler GhostLocals sets several important values which are needed for every part of the application, admin, api and theme. Therefore, it doesn't make sense for it to be bundled in the themeHandler. * 🐛 Fix the uncapitalise middleware - Updated to make correct use of req.baseUrl, req.path, req.url & req.originalUrl - Updated the tests to actually cover our weird cases * 🎨 Move ghostVersion logic out of config * 💄 Group static / asset-related middleware together * 🔥 Remove /shared/ asset handling - The 5 files which are located in `/shared/` are all handled by individual calls to `serveSharedFile` - Therefore this code is redundant
17 lines
563 B
JavaScript
17 lines
563 B
JavaScript
var ghostVersion = require('../utils/ghost-version');
|
|
|
|
// ### GhostLocals Middleware
|
|
// Expose the standard locals that every request will need to have available
|
|
module.exports = function ghostLocals(req, res, next) {
|
|
// Make sure we have a locals value.
|
|
res.locals = res.locals || {};
|
|
// The current Ghost version
|
|
res.locals.version = ghostVersion.full;
|
|
// The current Ghost version, but only major.minor
|
|
res.locals.safeVersion = ghostVersion.safe;
|
|
// relative path from the URL
|
|
res.locals.relativeUrl = req.path;
|
|
|
|
next();
|
|
};
|