mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
e277c6bad3
no issue - The helper allows generating HTML needed to cancel or continue the member's subscription depending on subscription state. - Added public members endpoint to allow updating subscription's `cancel_at_period_end` attribute available at: `PUT /api/canary/members/subscriptions/:id/` - Added client-side hook to allow calling subscription cancellation. Allows to create elements with `data-members-cancel-subscription` / `data-members-continue-subscription` attributes which would call subscription update. - Updated schema and added migration for `current_period_end` column - As discussed we only add a single column to subscriptions table to avoid preoptimizing for future cases - Added {{cancel_link}} helper - Added error handling for {{cancel_link}} when members are disabled - Added test coverage for {{cancel_link}} helper - Bumped @tryghost/members-api version to 0.10.2. Needed to use `updateSubscription` middleware - Bumped gscan to 3.2.0. Needed to recognize new {{cancel_link}} helper
104 lines
4.4 KiB
JavaScript
104 lines
4.4 KiB
JavaScript
const proxy = require('./proxy');
|
|
const register = require('./register');
|
|
|
|
const coreHelpers = {};
|
|
const registerThemeHelper = register.registerThemeHelper;
|
|
const registerAsyncThemeHelper = register.registerAsyncThemeHelper;
|
|
|
|
let registerAllCoreHelpers;
|
|
|
|
coreHelpers.asset = require('./asset');
|
|
coreHelpers.author = require('./author');
|
|
coreHelpers.authors = require('./authors');
|
|
coreHelpers.body_class = require('./body_class');
|
|
coreHelpers.cancel_link = require('./cancel_link');
|
|
coreHelpers.concat = require('./concat');
|
|
coreHelpers.content = require('./content');
|
|
coreHelpers.date = require('./date');
|
|
coreHelpers.encode = require('./encode');
|
|
coreHelpers.excerpt = require('./excerpt');
|
|
coreHelpers.facebook_url = require('./facebook_url');
|
|
coreHelpers.foreach = require('./foreach');
|
|
coreHelpers.get = require('./get');
|
|
coreHelpers.ghost_foot = require('./ghost_foot');
|
|
coreHelpers.ghost_head = require('./ghost_head');
|
|
coreHelpers.img_url = require('./img_url');
|
|
coreHelpers.is = require('./is');
|
|
coreHelpers.has = require('./has');
|
|
coreHelpers.lang = require('./lang');
|
|
coreHelpers.link = require('./link');
|
|
coreHelpers.link_class = require('./link_class');
|
|
coreHelpers.meta_description = require('./meta_description');
|
|
coreHelpers.meta_title = require('./meta_title');
|
|
coreHelpers.navigation = require('./navigation');
|
|
coreHelpers.page_url = require('./page_url');
|
|
coreHelpers.pagination = require('./pagination');
|
|
coreHelpers.plural = require('./plural');
|
|
coreHelpers.post_class = require('./post_class');
|
|
coreHelpers.prev_post = require('./prev_next');
|
|
coreHelpers.next_post = require('./prev_next');
|
|
coreHelpers.reading_time = require('./reading_time');
|
|
coreHelpers.t = require('./t');
|
|
coreHelpers.tags = require('./tags');
|
|
coreHelpers.title = require('./title');
|
|
coreHelpers.twitter_url = require('./twitter_url');
|
|
coreHelpers.url = require('./url');
|
|
|
|
function labsEnabledMembers() {
|
|
let self = this, args = arguments;
|
|
|
|
return proxy.labs.enabledHelper({
|
|
flagKey: 'members',
|
|
flagName: 'Members',
|
|
helperName: 'cancel_link',
|
|
helpUrl: 'https://ghost.org/faq/members/'
|
|
}, () => {
|
|
return coreHelpers.cancel_link.apply(self, args);
|
|
});
|
|
}
|
|
|
|
registerAllCoreHelpers = function registerAllCoreHelpers() {
|
|
// Register theme helpers
|
|
registerThemeHelper('asset', coreHelpers.asset);
|
|
registerThemeHelper('author', coreHelpers.author);
|
|
registerThemeHelper('authors', coreHelpers.authors);
|
|
registerThemeHelper('body_class', coreHelpers.body_class);
|
|
registerThemeHelper('cancel_link', labsEnabledMembers);
|
|
registerThemeHelper('concat', coreHelpers.concat);
|
|
registerThemeHelper('content', coreHelpers.content);
|
|
registerThemeHelper('date', coreHelpers.date);
|
|
registerThemeHelper('encode', coreHelpers.encode);
|
|
registerThemeHelper('excerpt', coreHelpers.excerpt);
|
|
registerThemeHelper('foreach', coreHelpers.foreach);
|
|
registerThemeHelper('ghost_foot', coreHelpers.ghost_foot);
|
|
registerThemeHelper('has', coreHelpers.has);
|
|
registerThemeHelper('is', coreHelpers.is);
|
|
registerThemeHelper('img_url', coreHelpers.img_url);
|
|
registerThemeHelper('lang', coreHelpers.lang);
|
|
registerThemeHelper('link', coreHelpers.link);
|
|
registerThemeHelper('link_class', coreHelpers.link_class);
|
|
registerThemeHelper('meta_description', coreHelpers.meta_description);
|
|
registerThemeHelper('meta_title', coreHelpers.meta_title);
|
|
registerThemeHelper('navigation', coreHelpers.navigation);
|
|
registerThemeHelper('page_url', coreHelpers.page_url);
|
|
registerThemeHelper('pagination', coreHelpers.pagination);
|
|
registerThemeHelper('plural', coreHelpers.plural);
|
|
registerThemeHelper('post_class', coreHelpers.post_class);
|
|
registerThemeHelper('reading_time', coreHelpers.reading_time);
|
|
registerThemeHelper('t', coreHelpers.t);
|
|
registerThemeHelper('tags', coreHelpers.tags);
|
|
registerThemeHelper('title', coreHelpers.title);
|
|
registerThemeHelper('twitter_url', coreHelpers.twitter_url);
|
|
registerThemeHelper('facebook_url', coreHelpers.facebook_url);
|
|
registerThemeHelper('url', coreHelpers.url);
|
|
|
|
// Async theme helpers
|
|
registerAsyncThemeHelper('ghost_head', coreHelpers.ghost_head);
|
|
registerAsyncThemeHelper('next_post', coreHelpers.next_post);
|
|
registerAsyncThemeHelper('prev_post', coreHelpers.prev_post);
|
|
registerAsyncThemeHelper('get', coreHelpers.get);
|
|
};
|
|
|
|
module.exports = coreHelpers;
|
|
module.exports.loadCoreHelpers = registerAllCoreHelpers;
|