diff --git a/core/server/app.js b/core/server/app.js index c60bd9353b..9366b3b647 100644 --- a/core/server/app.js +++ b/core/server/app.js @@ -51,7 +51,7 @@ module.exports = function setupParentApp() { parentApp.use('/ghost', require('./admin')()); // BLOG - parentApp.use(require('./blog')()); + parentApp.use(require('./site')()); debug('ParentApp setup end'); diff --git a/core/server/apps/amp/index.js b/core/server/apps/amp/index.js index 6bc8e3e094..9dad7c5787 100644 --- a/core/server/apps/amp/index.js +++ b/core/server/apps/amp/index.js @@ -7,7 +7,7 @@ module.exports = { registerHelpers(ghost); }, - setupRoutes: function setupRoutes(blogRouter) { - blogRouter.use('*/' + config.get('routeKeywords').amp + '/', router); + setupRoutes: function setupRoutes(siteRouter) { + siteRouter.use('*/' + config.get('routeKeywords').amp + '/', router); } }; diff --git a/core/server/apps/amp/lib/router.js b/core/server/apps/amp/lib/router.js index d9e4184c44..67330ef945 100644 --- a/core/server/apps/amp/lib/router.js +++ b/core/server/apps/amp/lib/router.js @@ -68,7 +68,7 @@ function checkIfAMPIsEnabled(req, res, next) { * * If we would call `next()`, express jumps to the frontend controller (server/controllers/frontend/index.js fn single) * and tries to lookup the post (again) and checks whether the post url equals the requested url (post.url !== req.path). - * This check would fail if the blog is setup on a subdirectory. + * This check would fail if the site is setup on a subdirectory. */ return next(new errors.NotFoundError({message: i18n.t('errors.errors.pageNotFound')})); } diff --git a/core/server/apps/private-blogging/index.js b/core/server/apps/private-blogging/index.js index d206580783..dac5ba57cf 100644 --- a/core/server/apps/private-blogging/index.js +++ b/core/server/apps/private-blogging/index.js @@ -29,12 +29,12 @@ module.exports = { registerHelpers(ghost); }, - setupMiddleware: function setupMiddleware(blogApp) { - blogApp.use(middleware.checkIsPrivate); - blogApp.use(middleware.filterPrivateRoutes); + setupMiddleware: function setupMiddleware(siteApp) { + siteApp.use(middleware.checkIsPrivate); + siteApp.use(middleware.filterPrivateRoutes); }, - setupRoutes: function setupRoutes(blogRouter) { - blogRouter.use('/' + config.get('routeKeywords').private + '/', router); + setupRoutes: function setupRoutes(siteRouter) { + siteRouter.use('/' + config.get('routeKeywords').private + '/', router); } }; diff --git a/core/server/apps/subscribers/index.js b/core/server/apps/subscribers/index.js index 7d004bbcfc..453e3b749d 100644 --- a/core/server/apps/subscribers/index.js +++ b/core/server/apps/subscribers/index.js @@ -10,8 +10,8 @@ module.exports = { registerHelpers(ghost); }, - setupRoutes: function setupRoutes(blogRouter) { - blogRouter.use('/' + config.get('routeKeywords').subscribe + '/', function labsEnabledRouter(req, res, next) { + setupRoutes: function setupRoutes(siteRouter) { + siteRouter.use('/' + config.get('routeKeywords').subscribe + '/', function labsEnabledRouter(req, res, next) { if (labs.isSet('subscribers') === true) { return router.apply(this, arguments); } diff --git a/core/server/data/xml/sitemap/handler.js b/core/server/data/xml/sitemap/handler.js index aa416e5152..ce7073ec0b 100644 --- a/core/server/data/xml/sitemap/handler.js +++ b/core/server/data/xml/sitemap/handler.js @@ -3,7 +3,7 @@ var _ = require('lodash'), sitemap = require('./index'); // Responsible for handling requests for sitemap files -module.exports = function handler(blogApp) { +module.exports = function handler(siteApp) { var resourceTypes = ['posts', 'authors', 'tags', 'pages'], verifyResourceType = function verifyResourceType(req, res, next) { if (!_.includes(resourceTypes, req.params.resource)) { @@ -16,7 +16,7 @@ module.exports = function handler(blogApp) { return sitemap.getSiteMapXml(type, page); }; - blogApp.get('/sitemap.xml', function sitemapXML(req, res, next) { + siteApp.get('/sitemap.xml', function sitemapXML(req, res, next) { var siteMapXml = sitemap.getIndexXml(); res.set({ @@ -39,7 +39,7 @@ module.exports = function handler(blogApp) { } }); - blogApp.get('/sitemap-:resource.xml', verifyResourceType, function sitemapResourceXML(req, res, next) { + siteApp.get('/sitemap-:resource.xml', verifyResourceType, function sitemapResourceXML(req, res, next) { var type = req.params.resource, page = 1, siteMapXml = getResourceSiteMapXml(type, page); diff --git a/core/server/middleware/cache-control.js b/core/server/middleware/cache-control.js index 9159a45d58..7a253eff79 100644 --- a/core/server/middleware/cache-control.js +++ b/core/server/middleware/cache-control.js @@ -2,7 +2,7 @@ // Usage: cacheControl(profile), where profile is one of 'public' or 'private' // After: checkIsPrivate // Before: routes -// App: Admin|Blog|API +// App: Admin|Site|API // // Allows each app to declare its own default caching rules @@ -11,7 +11,6 @@ var _ = require('lodash'), cacheControl; cacheControl = function cacheControl(options) { - /*jslint unparam:true*/ var profiles = { public: 'public, max-age=' + config.get('caching:frontend:maxAge'), private: 'no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0' diff --git a/core/server/middleware/custom-redirects.js b/core/server/middleware/custom-redirects.js index fc5c3ce859..84f0e1f70d 100644 --- a/core/server/middleware/custom-redirects.js +++ b/core/server/middleware/custom-redirects.js @@ -72,12 +72,12 @@ _private.registerRoutes = function registerRoutes() { * - see https://github.com/TryGhost/Ghost/issues/7707 and https://docs.ghost.org/v1/docs/redirects * - file loads synchronously, because we need to register the routes before anything else */ -exports.use = function use(blogApp) { +exports.use = function use(siteApp) { _private.registerRoutes(); // Recommended approach by express, see https://github.com/expressjs/express/issues/2596#issuecomment-81353034. // As soon as the express router get's re-instantiated, the old router instance is not used anymore. - blogApp.use(function (req, res, next) { + siteApp.use(function (req, res, next) { customRedirectsRouter(req, res, next); }); }; diff --git a/core/server/middleware/uncapitalise.js b/core/server/middleware/uncapitalise.js index a31fffced8..c7673425c1 100644 --- a/core/server/middleware/uncapitalise.js +++ b/core/server/middleware/uncapitalise.js @@ -2,7 +2,7 @@ // Usage: uncapitalise(req, res, next) // After: // Before: -// App: Admin|Blog|API +// App: Admin|Site|API // // Detect upper case in req.path. // diff --git a/core/server/blog/app.js b/core/server/site/app.js similarity index 73% rename from core/server/blog/app.js rename to core/server/site/app.js index 828d893cff..1510d39f84 100644 --- a/core/server/blog/app.js +++ b/core/server/site/app.js @@ -30,39 +30,39 @@ var debug = require('ghost-ignition').debug('blog'), // middleware for themes themeMiddleware = require('../themes').middleware; -module.exports = function setupBlogApp() { - debug('Blog setup start'); +module.exports = function setupSiteApp() { + debug('Site setup start'); - var blogApp = express(); + var siteApp = express(); // ## App - specific code // set the view engine - blogApp.set('view engine', 'hbs'); + siteApp.set('view engine', 'hbs'); // you can extend Ghost with a custom redirects file // see https://github.com/TryGhost/Ghost/issues/7707 - customRedirects.use(blogApp); + customRedirects.use(siteApp); // Static content/assets // @TODO make sure all of these have a local 404 error handler // Favicon - blogApp.use(serveFavicon()); + siteApp.use(serveFavicon()); // /public/ghost-sdk.js - blogApp.use(servePublicFile('public/ghost-sdk.js', 'application/javascript', utils.ONE_HOUR_S)); - blogApp.use(servePublicFile('public/ghost-sdk.min.js', 'application/javascript', utils.ONE_HOUR_S)); + siteApp.use(servePublicFile('public/ghost-sdk.js', 'application/javascript', utils.ONE_HOUR_S)); + siteApp.use(servePublicFile('public/ghost-sdk.min.js', 'application/javascript', utils.ONE_HOUR_S)); // Serve sitemap.xsl file - blogApp.use(servePublicFile('sitemap.xsl', 'text/xsl', utils.ONE_DAY_S)); + siteApp.use(servePublicFile('sitemap.xsl', 'text/xsl', utils.ONE_DAY_S)); // Serve stylesheets for default templates - blogApp.use(servePublicFile('public/ghost.css', 'text/css', utils.ONE_HOUR_S)); - blogApp.use(servePublicFile('public/ghost.min.css', 'text/css', utils.ONE_HOUR_S)); + siteApp.use(servePublicFile('public/ghost.css', 'text/css', utils.ONE_HOUR_S)); + siteApp.use(servePublicFile('public/ghost.min.css', 'text/css', utils.ONE_HOUR_S)); // Serve images for default templates - blogApp.use(servePublicFile('public/404-ghost@2x.png', 'png', utils.ONE_HOUR_S)); - blogApp.use(servePublicFile('public/404-ghost.png', 'png', utils.ONE_HOUR_S)); + siteApp.use(servePublicFile('public/404-ghost@2x.png', 'png', utils.ONE_HOUR_S)); + siteApp.use(servePublicFile('public/404-ghost.png', 'png', utils.ONE_HOUR_S)); // Serve blog images using the storage adapter - blogApp.use('/' + utils.url.STATIC_IMAGE_URL_PREFIX, storage.getStorage().serve()); + siteApp.use('/' + utils.url.STATIC_IMAGE_URL_PREFIX, storage.getStorage().serve()); // @TODO find this a better home // We do this here, at the top level, because helpers require so much stuff. @@ -75,57 +75,57 @@ module.exports = function setupBlogApp() { // This should happen AFTER any shared assets are served, as it only changes things to do with templates // At this point the active theme object is already updated, so we have the right path, so it can probably // go after staticTheme() as well, however I would really like to simplify this and be certain - blogApp.use(themeMiddleware); + siteApp.use(themeMiddleware); debug('Themes done'); // Theme static assets/files - blogApp.use(staticTheme()); + siteApp.use(staticTheme()); debug('Static content done'); // Serve robots.txt if not found in theme - blogApp.use(servePublicFile('robots.txt', 'text/plain', utils.ONE_HOUR_S)); + siteApp.use(servePublicFile('robots.txt', 'text/plain', utils.ONE_HOUR_S)); // setup middleware for internal apps // @TODO: refactor this to be a proper app middleware hook for internal & external apps config.get('apps:internal').forEach(function (appName) { var app = require(path.join(config.get('paths').internalAppPath, appName)); if (app.hasOwnProperty('setupMiddleware')) { - app.setupMiddleware(blogApp); + app.setupMiddleware(siteApp); } }); // site map - this should probably be refactored to be an internal app - sitemapHandler(blogApp); + sitemapHandler(siteApp); debug('Internal apps done'); // send 503 error page in case of maintenance - blogApp.use(maintenance); + siteApp.use(maintenance); // Force SSL if required // must happen AFTER asset loading and BEFORE routing - blogApp.use(urlRedirects); + siteApp.use(urlRedirects); // Add in all trailing slashes & remove uppercase // must happen AFTER asset loading and BEFORE routing - blogApp.use(prettyURLs); + siteApp.use(prettyURLs); // ### Caching - // Blog frontend is cacheable - blogApp.use(cacheControl('public')); + // Site frontend is cacheable + siteApp.use(cacheControl('public')); // Fetch the frontend client into res.locals - blogApp.use(frontendClient); + siteApp.use(frontendClient); debug('General middleware done'); // Set up Frontend routes (including private blogging routes) - blogApp.use(routes()); + siteApp.use(routes()); // ### Error handlers - blogApp.use(errorHandler.pageNotFound); - blogApp.use(errorHandler.handleHTMLResponse); + siteApp.use(errorHandler.pageNotFound); + siteApp.use(errorHandler.handleHTMLResponse); - debug('Blog setup end'); + debug('Site setup end'); - return blogApp; + return siteApp; }; diff --git a/core/server/blog/index.js b/core/server/site/index.js similarity index 100% rename from core/server/blog/index.js rename to core/server/site/index.js diff --git a/core/server/blog/routes.js b/core/server/site/routes.js similarity index 97% rename from core/server/blog/routes.js rename to core/server/site/routes.js index 918af53f4c..22721a677f 100644 --- a/core/server/blog/routes.js +++ b/core/server/site/routes.js @@ -5,7 +5,7 @@ var express = require('express'), channels = require('../controllers/channels'), utils = require('../utils'); -module.exports = function frontendRoutes() { +module.exports = function siteRouter() { var router = express.Router(), routeKeywords = config.get('routeKeywords'); diff --git a/core/server/themes/active.js b/core/server/themes/active.js index dd85c28e13..b725769594 100644 --- a/core/server/themes/active.js +++ b/core/server/themes/active.js @@ -83,15 +83,15 @@ class ActiveTheme { return this._config[key]; } - mount(blogApp) { + mount(siteApp) { // reset the asset hash // @TODO: set this on the theme instead of globally, or use proper file-based hash config.set('assetHash', null); // clear the view cache - blogApp.cache = {}; + siteApp.cache = {}; // Set the views and engine - blogApp.set('views', this.path); - blogApp.engine('hbs', engine.configure(this.partialsPath)); + siteApp.set('views', this.path); + siteApp.engine('hbs', engine.configure(this.partialsPath)); this._mounted = true; }