Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add v3.14.0
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickRe committed Apr 27, 2020
1 parent 84fd9ba commit 61a7640
Show file tree
Hide file tree
Showing 64 changed files with 1,061 additions and 1,129 deletions.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

This file was deleted.

1 change: 1 addition & 0 deletions core/built/assets/icons/circle-ellipsis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions core/built/assets/img/amp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
1 change: 1 addition & 0 deletions core/built/assets/img/zapier.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/frontend/apps/amp/lib/views/amp.hbs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/frontend/helpers/ghost_head.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function getMembersHelper() {
const stripeSecretToken = stripePaymentProcessor.config.secret_token;
const stripePublicToken = stripePaymentProcessor.config.public_token;

let membersHelper = `<script defer src="${getAssetUrl('public/members.js/', true)}"></script>`;
let membersHelper = `<script defer src="${getAssetUrl('public/members.js', true)}"></script>`;
if (!!stripeSecretToken && stripeSecretToken !== '' && !!stripePublicToken && stripePublicToken !== '') {
membersHelper += '<script src="https://js.stripe.com/v3/"></script>';
}
Expand Down
2 changes: 1 addition & 1 deletion core/frontend/services/routing/helpers/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function setResponseContext(req, res, data) {
res.locals.context = [];

// If we don't have a relativeUrl, we can't detect the context, so return
// See shared/middlewares/ghost-locals
// See web/parent/middleware/ghost-locals
if (!res.locals.relativeUrl) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion core/server/adapters/scheduling/SchedulingDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ SchedulingDefault.prototype._pingUrl = function (object) {

const httpMethod = object.extra ? object.extra.httpMethod : 'PUT';
const tries = object.tries || 0;
const requestTimeout = object.extra ? object.extra.timeoutInMS : 1000 * 5;
const requestTimeout = (object.extra && object.extra.timeoutInMS) ? object.extra.timeoutInMS : 1000 * 5;
const maxTries = 30;

const options = {
Expand Down
6 changes: 6 additions & 0 deletions core/server/api/canary/site.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const ghostVersion = require('../../lib/ghost-version');
const settingsCache = require('../../services/settings/cache');
const urlUtils = require('../../lib/url-utils');
// const membersService = require('../../services/members');

const site = {
docName: 'site',
Expand All @@ -10,7 +11,12 @@ const site = {
query() {
return {
title: settingsCache.get('title'),
description: settingsCache.get('description'),
logo: settingsCache.get('logo'),
// brand: settingsCache.get('brand'), // this is a dev experiments feature & needs to be behind the flag
url: urlUtils.urlFor('home', true),
// plans: membersService.config.getPublicPlans(), // these are new members features that probably won't live here
// allowSelfSignup: membersService.config.getAllowSelfSignup(), // these are new members features that probably won't live here
version: ghostVersion.safe
};
}
Expand Down
2 changes: 1 addition & 1 deletion core/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const minimalRequiredSetupToStartGhost = (dbState) => {
.then(() => {
debug('Themes done');

parentApp = require('./web/parent-app')();
parentApp = require('./web/parent/app')();
debug('Express Apps done');

return new GhostServer(parentApp);
Expand Down
5 changes: 4 additions & 1 deletion core/server/services/mega/post-email-serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ const _parseReplacements = (emailTmpl) => {
const serialize = async (postModel, options = {isBrowserPreview: false}) => {
const post = await serializePostModel(postModel);

post.published_at = post.published_at ? moment(post.published_at).format('DD MMM YYYY') : moment().format('DD MMM YYYY');
const timezone = settingsCache.get('active_timezone');
const momentDate = post.published_at ? moment(post.published_at) : moment();
post.published_at = momentDate.tz(timezone).format('DD MMM YYYY');

post.authors = post.authors && post.authors.map(author => author.name).join(',');
if (post.posts_meta) {
post.email_subject = post.posts_meta.email_subject;
Expand Down
42 changes: 42 additions & 0 deletions core/server/services/members/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,47 @@ function getEmailFromAddress() {
return `${subscriptionSettings.fromAddress || 'noreply'}@${getDomain()}`;
}

/** Copied from theme middleware, remove it there after cleanup to keep this in single place */
function getPublicPlans() {
const CURRENCY_SYMBOLS = {
USD: '$',
AUD: '$',
CAD: '$',
GBP: '£',
EUR: '€'
};
const defaultPriceData = {
monthly: 0,
yearly: 0
};

try {
const membersSettings = settingsCache.get('members_subscription_settings');
const stripeProcessor = membersSettings.paymentProcessors.find(
processor => processor.adapter === 'stripe'
);

const priceData = stripeProcessor.config.plans.reduce((prices, plan) => {
const numberAmount = 0 + plan.amount;
const dollarAmount = numberAmount ? Math.round(numberAmount / 100) : 0;
return Object.assign(prices, {
[plan.name.toLowerCase()]: dollarAmount
});
}, {});

priceData.currency = String.prototype.toUpperCase.call(stripeProcessor.config.currency || 'usd');
priceData.currency_symbol = CURRENCY_SYMBOLS[priceData.currency];

if (Number.isInteger(priceData.monthly) && Number.isInteger(priceData.yearly)) {
return priceData;
}

return defaultPriceData;
} catch (err) {
return defaultPriceData;
}
}

const getApiUrl = ({version, type}) => {
const {href} = new URL(
urlUtils.getApiPath({version, type}),
Expand Down Expand Up @@ -121,6 +162,7 @@ function getSigninURL(token, type) {

module.exports = {
getEmailFromAddress,
getPublicPlans,
getStripePaymentConfig,
getAllowSelfSignup,
getAuthSecret,
Expand Down
63 changes: 33 additions & 30 deletions core/server/services/members/middleware.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const common = require('../../lib/common');
const constants = require('../../lib/constants');
const shared = require('../../web/shared');
const labsService = require('../labs');
const membersService = require('./index');

Expand Down Expand Up @@ -44,6 +42,32 @@ const getMemberDataFromSession = async function (req, res, next) {
}
};

const getMemberData = async function (req, res) {
if (!labsService.isSet('members')) {
res.json(null);
}
try {
const member = await membersService.ssr.getMemberDataFromSession(req, res);
if (member) {
res.json({
uuid: member.uuid,
email: member.email,
name: member.name,
firstname: member.name && member.name.split(' ')[0],
avatar_image: member.avatar_image,
subscriptions: member.stripe.subscriptions,
paid: member.stripe.subscriptions.length !== 0
});
} else {
res.json(null);
}
} catch (err) {
common.logging.warn(err.message);
res.writeHead(err.statusCode);
res.end(err.message);
}
};

const exchangeTokenForSession = async function (req, res, next) {
if (!labsService.isSet('members')) {
return next();
Expand All @@ -62,44 +86,23 @@ const exchangeTokenForSession = async function (req, res, next) {
};

const decorateResponse = function (req, res, next) {
if (!labsService.isSet('members')) {
return next();
}
res.locals.member = req.member;
next();
};

// @TODO only loads this stuff if members is enabled
// Set req.member & res.locals.member if a cookie is set
module.exports = {
public: [
shared.middlewares.labs.members,
shared.middlewares.servePublicFile.createPublicFileMiddleware(
'public/members.js',
'application/javascript',
constants.ONE_YEAR_S
)
],
publicMinified: [
shared.middlewares.labs.members,
shared.middlewares.servePublicFile.createPublicFileMiddleware(
'public/members.min.js',
'application/javascript',
constants.ONE_YEAR_S
)
],
createSessionFromToken: [
getMemberDataFromSession,
exchangeTokenForSession,
decorateResponse
],
getIdentityToken: [
shared.middlewares.labs.members,
getIdentityToken
],
deleteSession: [
shared.middlewares.labs.members,
deleteSession
],
stripeWebhooks: [
shared.middlewares.labs.members,
(req, res, next) => membersService.api.middleware.handleStripeWebhook(req, res, next)
]
getIdentityToken,
getMemberData,
deleteSession,
stripeWebhooks: (req, res, next) => membersService.api.middleware.handleStripeWebhook(req, res, next)
};
2 changes: 1 addition & 1 deletion core/server/web/admin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function setupAdminApp() {

// Force SSL if required
// must happen AFTER asset loading and BEFORE routing
adminApp.use(shared.middlewares.urlRedirects.adminRedirect);
adminApp.use(shared.middlewares.urlRedirects.adminSSLAndHostRedirect);

// Add in all trailing slashes & remove uppercase
// must happen AFTER asset loading and BEFORE routing
Expand Down
8 changes: 4 additions & 4 deletions core/server/web/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%2F%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%3Afalse%7D%2C%22_APPLICATION_TEMPLATE_WRAPPER%22%3Afalse%2C%22_JQUERY_INTEGRATION%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%223.13%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%2F%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%3Afalse%7D%2C%22_APPLICATION_TEMPLATE_WRAPPER%22%3Afalse%2C%22_JQUERY_INTEGRATION%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%223.14%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 All @@ -34,7 +34,7 @@


<link rel="stylesheet" href="assets/vendor.min-49fbf4f35995cdfbdde49309a1318a61.css">
<link rel="stylesheet" href="assets/ghost.min-df42db26872c1fa8760770f5ad3b4733.css" title="light">
<link rel="stylesheet" href="assets/ghost.min-4c069c168f6c5566ecb99643f4b30ac8.css" title="light">



Expand All @@ -52,8 +52,8 @@
<div id="ember-basic-dropdown-wormhole"></div>


<script src="assets/vendor.min-dd367fd71acbc2c70621e55ba07b7193.js"></script>
<script src="assets/ghost.min-7ef23448585a3e41b82d92e96136bdd0.js"></script>
<script src="assets/vendor.min-55d1fce188ef9034523f271d73ac46d9.js"></script>
<script src="assets/ghost.min-17cd3505f03cd66deaa5531f2ed33226.js"></script>

</body>
</html>
8 changes: 4 additions & 4 deletions core/server/web/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%2F%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%3Afalse%7D%2C%22_APPLICATION_TEMPLATE_WRAPPER%22%3Afalse%2C%22_JQUERY_INTEGRATION%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%223.13%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%2F%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%3Afalse%7D%2C%22_APPLICATION_TEMPLATE_WRAPPER%22%3Afalse%2C%22_JQUERY_INTEGRATION%22%3Atrue%7D%2C%22APP%22%3A%7B%22version%22%3A%223.14%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 All @@ -34,7 +34,7 @@


<link rel="stylesheet" href="assets/vendor.min-49fbf4f35995cdfbdde49309a1318a61.css">
<link rel="stylesheet" href="assets/ghost.min-df42db26872c1fa8760770f5ad3b4733.css" title="light">
<link rel="stylesheet" href="assets/ghost.min-4c069c168f6c5566ecb99643f4b30ac8.css" title="light">



Expand All @@ -52,8 +52,8 @@
<div id="ember-basic-dropdown-wormhole"></div>


<script src="assets/vendor.min-dd367fd71acbc2c70621e55ba07b7193.js"></script>
<script src="assets/ghost.min-7ef23448585a3e41b82d92e96136bdd0.js"></script>
<script src="assets/vendor.min-55d1fce188ef9034523f271d73ac46d9.js"></script>
<script src="assets/ghost.min-17cd3505f03cd66deaa5531f2ed33226.js"></script>

</body>
</html>
3 changes: 2 additions & 1 deletion core/server/web/api/canary/admin/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const boolParser = require('express-query-boolean');
const express = require('express');
const bodyParser = require('body-parser');
const shared = require('../../../shared');
const apiMw = require('../../middleware');
const routes = require('./routes');
const sentry = require('../../../../sentry');

Expand All @@ -25,7 +26,7 @@ module.exports = function setupApiApp() {

// Check version matches for API requests, depends on res.locals.safeVersion being set
// Therefore must come after themeHandler.ghostLocals, for now
apiApp.use(shared.middlewares.api.versionMatch);
apiApp.use(apiMw.versionMatch);

// Admin API shouldn't be cached
apiApp.use(shared.middlewares.cacheControl('private'));
Expand Down
17 changes: 9 additions & 8 deletions core/server/web/api/canary/admin/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const errors = require('@tryghost/errors');
const {i18n} = require('../../../../lib/common');
const auth = require('../../../../services/auth');
const shared = require('../../../shared');
const apiMw = require('../../middleware');

const notImplemented = function (req, res, next) {
// CASE: user is logged in, allow
Expand Down Expand Up @@ -52,9 +53,9 @@ const notImplemented = function (req, res, next) {
module.exports.authAdminApi = [
auth.authenticate.authenticateAdminApi,
auth.authorize.authorizeAdminApi,
shared.middlewares.updateUserLastSeen,
shared.middlewares.api.cors,
shared.middlewares.urlRedirects.adminRedirect,
apiMw.updateUserLastSeen,
apiMw.cors,
shared.middlewares.urlRedirects.adminSSLAndHostRedirect,
shared.middlewares.prettyUrls,
notImplemented
];
Expand All @@ -66,9 +67,9 @@ module.exports.authAdminApi = [
module.exports.authAdminApiWithUrl = [
auth.authenticate.authenticateAdminApiWithUrl,
auth.authorize.authorizeAdminApi,
shared.middlewares.updateUserLastSeen,
shared.middlewares.api.cors,
shared.middlewares.urlRedirects.adminRedirect,
apiMw.updateUserLastSeen,
apiMw.cors,
shared.middlewares.urlRedirects.adminSSLAndHostRedirect,
shared.middlewares.prettyUrls,
notImplemented
];
Expand All @@ -77,8 +78,8 @@ module.exports.authAdminApiWithUrl = [
* Middleware for public admin endpoints
*/
module.exports.publicAdminApi = [
shared.middlewares.api.cors,
shared.middlewares.urlRedirects.adminRedirect,
apiMw.cors,
shared.middlewares.urlRedirects.adminSSLAndHostRedirect,
shared.middlewares.prettyUrls,
notImplemented
];
Loading

0 comments on commit 61a7640

Please sign in to comment.