0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Rename blog -> site

- We're going to be moving towards this naming convention more
- Doing this now makes it easier to name other things
This commit is contained in:
Hannah Wolfe 2017-10-26 17:24:08 +01:00
parent 8edc960c16
commit b5228f5c43
13 changed files with 53 additions and 54 deletions

View file

@ -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');

View file

@ -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);
}
};

View file

@ -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')}));
}

View file

@ -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);
}
};

View file

@ -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);
}

View file

@ -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);

View file

@ -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'

View file

@ -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);
});
};

View file

@ -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.
//

View file

@ -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;
};

View file

@ -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');

View file

@ -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;
}