Skip to content

Commit

Permalink
Upgrade Ghost to v1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
chadly committed Oct 29, 2017
1 parent b9fce9c commit 8e1717e
Show file tree
Hide file tree
Showing 26 changed files with 924 additions and 524 deletions.
6 changes: 5 additions & 1 deletion content/themes/casper/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ gulp.task('zip', ['css'], function() {
var themeName = require('./package.json').name;
var filename = themeName + '.zip';

return gulp.src(['**', '!node_modules', '!node_modules/**'])
return gulp.src([
'**',
'!node_modules', '!node_modules/**',
'!dist', '!dist/**'
])
.pipe(zip(filename))
.pipe(gulp.dest(targetDir));
});
Expand Down
2 changes: 1 addition & 1 deletion content/themes/casper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "casper",
"description": "The default personal blogging theme for Ghost. Beautiful, minimal and responsive.",
"demo": "https://demo.ghost.io",
"version": "2.1.4",
"version": "2.1.6",
"engines": {
"ghost": ">=1.2.0"
},
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/server/admin/views/default-prod.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Ghost Admin</title>


<meta name="ghost-admin/config/environment" content="%7B%22modulePrefix%22%3A%22ghost-admin%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22trailing-hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3A%7B%22Date%22%3Afalse%2C%22Array%22%3Atrue%2C%22String%22%3Atrue%2C%22Function%22%3Atrue%7D%2C%22ENABLE_DS_FILTER%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%221.15%22%2C%22name%22%3A%22ghost-admin%22%7D%2C%22ember-simple-auth%22%3A%7B%7D%2C%22moment%22%3A%7B%22includeTimezone%22%3A%22all%22%7D%2C%22ember-cli-mirage%22%3A%7B%22usingProxy%22%3Afalse%2C%22useDefaultPassthroughs%22%3Atrue%7D%2C%22exportApplicationGlobal%22%3Afalse%2C%22ember-load%22%3A%7B%22loadingIndicatorClass%22%3A%22ember-load-indicator%22%7D%7D" />
<meta name="ghost-admin/config/environment" content="%7B%22modulePrefix%22%3A%22ghost-admin%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22trailing-hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3A%7B%22Date%22%3Afalse%2C%22Array%22%3Atrue%2C%22String%22%3Atrue%2C%22Function%22%3Atrue%7D%2C%22ENABLE_DS_FILTER%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%221.16%22%2C%22name%22%3A%22ghost-admin%22%7D%2C%22ember-simple-auth%22%3A%7B%7D%2C%22moment%22%3A%7B%22includeTimezone%22%3A%22all%22%7D%2C%22ember-cli-mirage%22%3A%7B%22usingProxy%22%3Afalse%2C%22useDefaultPassthroughs%22%3Atrue%7D%2C%22exportApplicationGlobal%22%3Afalse%2C%22ember-load%22%3A%7B%22loadingIndicatorClass%22%3A%22ember-load-indicator%22%7D%7D" />

<meta name="HandheldFriendly" content="True" />
<meta name="MobileOptimized" content="320" />
Expand Down Expand Up @@ -53,7 +53,7 @@


<script src="assets/vendor.min-87477a1d2baf934c445571d66b0baed9.js"></script>
<script src="assets/ghost.min-03d5cec363f763ce07937ee6b695d25f.js"></script>
<script src="assets/ghost.min-a22b5fd2d0d6d3e497fd7bda45a1f87b.js"></script>

</body>
</html>
4 changes: 2 additions & 2 deletions core/server/admin/views/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Ghost Admin</title>


<meta name="ghost-admin/config/environment" content="%7B%22modulePrefix%22%3A%22ghost-admin%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22trailing-hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3A%7B%22Date%22%3Afalse%2C%22Array%22%3Atrue%2C%22String%22%3Atrue%2C%22Function%22%3Atrue%7D%2C%22ENABLE_DS_FILTER%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%221.15%22%2C%22name%22%3A%22ghost-admin%22%7D%2C%22ember-simple-auth%22%3A%7B%7D%2C%22moment%22%3A%7B%22includeTimezone%22%3A%22all%22%7D%2C%22ember-cli-mirage%22%3A%7B%22usingProxy%22%3Afalse%2C%22useDefaultPassthroughs%22%3Atrue%7D%2C%22exportApplicationGlobal%22%3Afalse%2C%22ember-load%22%3A%7B%22loadingIndicatorClass%22%3A%22ember-load-indicator%22%7D%7D" />
<meta name="ghost-admin/config/environment" content="%7B%22modulePrefix%22%3A%22ghost-admin%22%2C%22environment%22%3A%22production%22%2C%22rootURL%22%3A%22/%22%2C%22locationType%22%3A%22trailing-hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%2C%22EXTEND_PROTOTYPES%22%3A%7B%22Date%22%3Afalse%2C%22Array%22%3Atrue%2C%22String%22%3Atrue%2C%22Function%22%3Atrue%7D%2C%22ENABLE_DS_FILTER%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%221.16%22%2C%22name%22%3A%22ghost-admin%22%7D%2C%22ember-simple-auth%22%3A%7B%7D%2C%22moment%22%3A%7B%22includeTimezone%22%3A%22all%22%7D%2C%22ember-cli-mirage%22%3A%7B%22usingProxy%22%3Afalse%2C%22useDefaultPassthroughs%22%3Atrue%7D%2C%22exportApplicationGlobal%22%3Afalse%2C%22ember-load%22%3A%7B%22loadingIndicatorClass%22%3A%22ember-load-indicator%22%7D%7D" />

<meta name="HandheldFriendly" content="True" />
<meta name="MobileOptimized" content="320" />
Expand Down Expand Up @@ -53,7 +53,7 @@


<script src="assets/vendor.min-87477a1d2baf934c445571d66b0baed9.js"></script>
<script src="assets/ghost.min-03d5cec363f763ce07937ee6b695d25f.js"></script>
<script src="assets/ghost.min-a22b5fd2d0d6d3e497fd7bda45a1f87b.js"></script>

</body>
</html>
8 changes: 7 additions & 1 deletion core/server/api/authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,14 @@ authentication = {
updatedUser.set('status', 'active');
return updatedUser.save(options);
})
.catch(errors.ValidationError, function (err) {
return Promise.reject(err);
})
.catch(function (err) {
throw new errors.UnauthorizedError({err: err});
if (errors.utils.isIgnitionError(err)) {
return Promise.reject(err);
}
return Promise.reject(new errors.UnauthorizedError({err: err}));
});
}

Expand Down
6 changes: 5 additions & 1 deletion core/server/blog/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ var debug = require('ghost-ignition').debug('blog'),

// Global/shared middleware
cacheControl = require('../middleware/cache-control'),
urlRedirects = require('../middleware/url-redirects'),
errorHandler = require('../middleware/error-handler'),
frontendClient = require('../middleware/frontend-client'),
maintenance = require('../middleware/maintenance'),
prettyURLs = require('../middleware/pretty-urls'),
urlRedirects = require('../middleware/url-redirects'),

// local middleware
servePublicFile = require('../middleware/serve-public-file'),
Expand Down Expand Up @@ -112,6 +113,9 @@ module.exports = function setupBlogApp() {
// Blog frontend is cacheable
blogApp.use(cacheControl('public'));

// Fetch the frontend client into res.locals
blogApp.use(frontendClient);

debug('General middleware done');

// Set up Frontend routes (including private blogging routes)
Expand Down
2 changes: 1 addition & 1 deletion core/server/blog/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var express = require('express'),
path = require('path'),
config = require('../config'),
controllers = require('../controllers'),
channels = require('../controllers/frontend/channels'),
channels = require('../controllers/channels'),
utils = require('../utils');

module.exports = function frontendRoutes() {
Expand Down
41 changes: 41 additions & 0 deletions core/server/controllers/channels/config.channels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"index": {
"route": "/",
"frontPageTemplate": "home"
},
"tag": {
"route": "/:t_tag/:slug/",
"postOptions": {
"filter": "tags:'%s'+tags.visibility:public"
},
"data": {
"tag": {
"type": "read",
"resource": "tags",
"options": {
"slug": "%s",
"visibility": "public"
}
}
},
"slugTemplate": true,
"editRedirect": "#/settings/tags/:slug/"
},
"author": {
"route": "/:t_author/:slug/",
"postOptions": {
"filter": "author:'%s'"
},
"data": {
"author": {
"type": "read",
"resource": "users",
"options": {
"slug": "%s"
}
}
},
"slugTemplate": true,
"editRedirect": "#/team/:slug/"
}
}
1 change: 1 addition & 0 deletions core/server/controllers/channels/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports.router = require('./router');
27 changes: 27 additions & 0 deletions core/server/controllers/channels/loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
var _ = require('lodash'),
channels = [];

function loadConfig() {
var channelConfig = {};

// This is a very dirty temporary hack so that we can test out channels with some Beta testers
// If you are reading this code, and considering using it, best reach out to us on Slack
// Definitely don't be angry at us if the structure of the JSON changes or this goes away.
try {
channelConfig = require('../../../../config.channels.json');
} catch (err) {
channelConfig = require('./config.channels.json');
}

return channelConfig;
}

module.exports.list = function list() {
_.each(loadConfig(), function (channelConfig, channelName) {
var channel = _.cloneDeep(channelConfig);
channel.name = channelName;
channels.push(channel);
});

return channels;
};
110 changes: 110 additions & 0 deletions core/server/controllers/channels/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
var express = require('express'),
_ = require('lodash'),
config = require('../../config'),
errors = require('../../errors'),
i18n = require('../../i18n'),
rss = require('../../data/xml/rss'),
utils = require('../../utils'),
channelLoader = require('./loader'),
renderChannel = require('../frontend/render-channel'),
rssRouter,
channelsRouter;

function handlePageParam(req, res, next, page) {
var pageRegex = new RegExp('/' + config.get('routeKeywords').page + '/(.*)?/'),
rssRegex = new RegExp('/rss/(.*)?/');

page = parseInt(page, 10);

if (page === 1) {
// Page 1 is an alias, do a permanent 301 redirect
if (rssRegex.test(req.url)) {
return utils.url.redirect301(res, req.originalUrl.replace(rssRegex, '/rss/'));
} else {
return utils.url.redirect301(res, req.originalUrl.replace(pageRegex, '/'));
}
} else if (page < 1 || isNaN(page)) {
// Nothing less than 1 is a valid page number, go straight to a 404
return next(new errors.NotFoundError({message: i18n.t('errors.errors.pageNotFound')}));
} else {
// Set req.params.page to the already parsed number, and continue
req.params.page = page;
return next();
}
}

function rssConfigMiddleware(req, res, next) {
res.locals.channel.isRSS = true;
next();
}

function channelConfigMiddleware(channel) {
return function doChannelConfig(req, res, next) {
res.locals.channel = _.cloneDeep(channel);
next();
};
}

rssRouter = function rssRouter(channelMiddleware) {
// @TODO move this to an RSS module
var router = express.Router({mergeParams: true}),
baseRoute = '/rss/',
pageRoute = utils.url.urlJoin(baseRoute, ':page(\\d+)/');

// @TODO figure out how to collapse this into a single rule
router.get(baseRoute, channelMiddleware, rssConfigMiddleware, rss);
router.get(pageRoute, channelMiddleware, rssConfigMiddleware, rss);
// Extra redirect rule
router.get('/feed/', function redirectToRSS(req, res) {
return utils.url.redirect301(res, utils.url.urlJoin(utils.url.getSubdir(), req.baseUrl, baseRoute));
});

router.param('page', handlePageParam);
return router;
};

function buildChannelRouter(channel) {
var channelRouter = express.Router({mergeParams: true}),
baseRoute = '/',
pageRoute = utils.url.urlJoin('/', config.get('routeKeywords').page, ':page(\\d+)/'),
middleware = [channelConfigMiddleware(channel)];

// @TODO figure out how to collapse this into a single rule
channelRouter.get(baseRoute, middleware, renderChannel);

// @TODO improve config and add defaults to make this simpler
if (channel.paged !== false) {
channelRouter.param('page', handlePageParam);
channelRouter.get(pageRoute, middleware, renderChannel);
}

// @TODO improve config and add defaults to make this simpler
if (channel.rss !== false) {
channelRouter.use(rssRouter(middleware));
}

if (channel.editRedirect) {
channelRouter.get('/edit/', function redirect(req, res) {
utils.url.redirectToAdmin(302, res, channel.editRedirect.replace(':slug', req.params.slug));
});
}

return channelRouter;
}

channelsRouter = function router() {
var channelsRouter = express.Router({mergeParams: true});

_.each(channelLoader.list(), function (channel) {
var channelRoute = channel.route.replace(/:t_([a-zA-Z]+)/, function (fullMatch, keyword) {
return config.get('routeKeywords')[keyword];
});

// Mount this channel router on the parent channels router
channelsRouter.use(channelRoute, buildChannelRouter(channel));
});

return channelsRouter;
};

module.exports = channelsRouter;
56 changes: 0 additions & 56 deletions core/server/controllers/frontend/channel-config.js

This file was deleted.

Loading

0 comments on commit 8e1717e

Please sign in to comment.