Commit Graph

9570 Commits

Author SHA1 Message Date
Daniel Lockyer
f4fb0fcbaa Improved Ghost boot time and memory usage by lazy loading routes
no issue

- right now, we mount all API endpoints (v2, v3 and canary), alongside some
  other routes, when Ghost is booting. This is wasteful because we don't
  necessarily need any of the endpoints to get Ghost up and running
- even when Admin is used, it uses `canary` so `v2` and `v3` sit in memory
- the better approach here is to lazy load these endpoints, so they only
  get mounted when needed
- this commit adds the `lazyUse` function into our Express lib,
  which takes a mount path and a module function to execute down the
  line. This gets passed to the wonderful `express-lazy-router` lib which
  detects when we're calling an unmounted module and will mount it for
  us
- from local testing, this speeds up boot time by about 18% and reduces
  initial memory usage by about 6% 🚀
2021-10-15 17:52:07 +02:00
Daniel Lockyer
40023438a6 Updated Admin to v4.19.0 2021-10-15 16:23:19 +01:00
Fabien O'Carroll
0210b329cb Passed OfferRedemption to members
refs https://github.com/TryGhost/Team/issues/1132

In order for the members module to create redemptions for members, it
needs access to the OfferRedemption model.
2021-10-15 16:56:04 +02:00
Fabien O'Carroll
a41c3cae1f Passed OfferRedemptionModel to offers
refs https://github.com/TryGhost/Team/issues/1132

In order for the offers modules to read the redemption count it needs
access to the OfferRedemption model.
2021-10-15 16:56:04 +02:00
Fabien O'Carroll
e2b243040e Added OfferRedemption model
refs https://github.com/TryGhost/Team/issues/1132

A model is needed for reading and writing Offer Redemptions to the
database.
2021-10-15 16:56:04 +02:00
Hannah Wolfe
67821a7bc7
Removed remaining usage of i18n & translation file
refs https://github.com/TryGhost/Ghost/issues/13380

- Now that i18n.t has been removed everywhere, we can cleanup the final usages
- Still TODO: merge the i18n logic into themeI18n, and get rid of shared/i18n entirely
2021-10-15 11:39:07 +01:00
Rishabh
4ba93a33fd Added offers UI in Portal
refs https://github.com/TryGhost/Team/issues/1138
refs https://github.com/TryGhost/Team/issues/1139

- adds new offers screen on Portal for offer URLs
- wires new offers screen to offer data via API
- handles offer url for paid members
2021-10-15 11:50:27 +05:30
Rishabh Garg
7270baa99c
Added new offers endpoint on members API
refs https://github.com/TryGhost/Team/issues/1138

Portal offer urls use offer id to load offer details UI and stripe checkout in frontend. This endpoint allows portal to fetch offer details from offer id to create Portal UI with relevant details for potential members.
2021-10-15 11:46:27 +05:30
Hannah Wolfe
b286142a6b
Removed errant console.log
refs: d7ae6e0138

- removed a debugging console log accidentally committed to main
2021-10-14 20:38:02 +01:00
Hannah Wolfe
981f11da95
Added basic {{match}} helper
refs: https://github.com/TryGhost/Team/issues/759

- The match helper allows for basic equals and not equals comparisons,
Example:
  {{match title "=" "Getting Started"}}
  {{match slug "!=" "welcome"}}
- There's a lot more functionality we want to add here, so that it ends up being a replacement for {{#has}}
- However, this first iteration is already useful, especially in the context of custom theme settings
- Therefore we are adding it early, and will document it along with custom theme settings when that goes GA very soon
2021-10-14 19:36:56 +01:00
Kevin Ansfield
d7ae6e0138 Added image as an allowed custom theme setting type
refs https://github.com/TryGhost/Team/issues/1107

- updated schema validation to allow `'image'` through as a known setting type now that Admin has support
- added transformation of setting values for `'image'` types because they will be URLs and should be stored with `__GHOST_URL__`
2021-10-14 18:41:54 +01:00
Hannah Wolfe
cd765e2393
Added implicit equals support to match helper
refs: https://github.com/TryGhost/Team/issues/759

- This allows for {{match x y}} to work without having to supply an "=" sign explicitly
2021-10-14 16:29:42 +01:00
Hannah Wolfe
fbc23459fc
Added full SafeString handling to match helper
refs: https://github.com/TryGhost/Team/issues/759

- No matter what, a handlebars helper outputs a string. So if you return true, you'll always get 'true'.
- SafeStrings are handlebars's way of passing around a string whilst also maintaining a record of the original value e.g. new SafeString(true) results in {string: true}
- We need this for the match helper, so that we know when doing a comparison that we're meant to be comparing against a boolean true, not a string true
- Therefore, we need to putput SafeStrings, but also process them when passed in

The logic
- Figuring out the correct logic here has been a little tricky but essentially:
  - {{match safestring}} with a single arg, will return true for any truthy value
  - {{match safestring "=" true}} does a direct comparison with the original value of the safe string, so if it was a boolean true, the match will be true else false
  - {{match (match something) "=" true}} will therefore work for any level of nesting
  - this can result in slightly inconsistent results, but feels correct and documentable

This is documented extensively through the test cases
2021-10-14 16:29:41 +01:00
Kevin Ansfield
41c21f501d Added text as an allowed setting type
refs https://github.com/TryGhost/Team/issues/1107

- updated schema validation to allow `'color'` through as a known setting type now that Admin has support
2021-10-14 15:45:47 +01:00
Kevin Ansfield
adb176f5b2 Added color as an allowed setting type
refs https://github.com/TryGhost/Team/issues/1107

- updated schema validation to allow `'color'` through as a known setting type now
2021-10-14 10:37:28 +01:00
Naz
715da3e01f Added JSDocs to bootstrap's init method
refs https://linear.app/tryghost/issue/CORE-103/decouple-internal-frontend-code-from-url-module

- Little type check and docs never hurt nobody
2021-10-14 05:55:49 +13:00
Naz
fead0e3dcf Decoupled frontend rss service from the url service
refs https://linear.app/tryghost/issue/CORE-103/decouple-internal-frontend-code-from-url-module

- We need to decouple all frontend services from URL service as much as possible. "bootstrap" module is now a central point to substitute (proxy really) function previously done by the URL service and this move changes direct usage of URL service to "bootstraps" internal proxy function
2021-10-14 05:55:49 +13:00
Naz
add30f3d5b Decoupled frontend routing from url service
refs https://linear.app/tryghost/issue/CORE-103/decouple-internal-frontend-code-from-url-module

- By becoming a parameter in the routing bootstrap process URL is Service no longer a "require" inside the frontend controllers but rather becomes a part of the "internal API" of the bootstrapper. This is not the end form of it, rather a step closer to decouplint routing from the URL serivce.
- The bootstrap module needs a facelift to have cleaner distinction between init/start methods. This is left for another time
2021-10-14 05:55:49 +13:00
Naz
0a9837ebcf Made bootstrap module's API slightly more readable
refs https://linear.app/tryghost/issue/CORE-103/decouple-internal-frontend-code-from-url-module

- It was hard to see straight away what methods the module exposes
2021-10-14 05:55:49 +13:00
Kevin Ansfield
7cb93be60b Added boolean as allowed custom theme setting type
refs https://github.com/TryGhost/Team/issues/1106

- updated schema validation to add `'boolean'` as an allowed `type` value
- added `format()` and `parse()` methods to `CustomThemeSetting` model to match `Settings` model behaviour for boolean-type settings
2021-10-13 17:25:32 +01:00
Fabien O'Carroll
f3dcf578a9 Prefixed migration with 01
refs https://github.com/TryGhost/Ghost/commit/b48c16c1

This was missed in the initial commit. We require numbers so that we can
easily see the order in which migrations will run.
2021-10-13 17:37:39 +02:00
Fabien O'Carroll
b93e7d7f7c Added offer_redemptions table to database
refs https://github.com/TryGhost/Team/issues/1132

This will be used to store Offer Redemptions, which will be used to list
the Offers which a Member has redeemed, as well as the number of times
an Offer has been redeemed.
2021-10-13 17:37:39 +02:00
Fabien O'Carroll
a441825c3f Passed MembersAPI the OffersAPI over OfferRepository
no-issue

The MembersAPI using the OfferRepository coupled it to the internals of
the Offers Module - instead we pass the "external" API - so that we can
change the internals, and not have to update the MembersAPI's usage.
2021-10-13 11:17:32 +02:00
Hannah Wolfe
00bcaeeb8c
Fixed duplicate message due to bad merge
- sadly git is not always detecting conflicts properly
2021-10-13 09:17:01 +01:00
PJ
4943c97ecb
Replace i18n with tpl in api/v2/utils/validators/input/users.js (#13589)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:08:57 +01:00
PJ
d362d8c8bd
Replace i18n with tpl in core/server/api/v3/invites.js (#13587)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:07:57 +01:00
PJ
09a9a9844f
Replace i18n with tpl in api/v3/pages-public.js (#13586)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:07:42 +01:00
PJ
f8033596c0
Replace i18n with tpl in api/v3/pages.js (#13585)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:06:53 +01:00
PJ
6e14047a2a
Replace i18n with tpl in core/server/api/v3/memberSigninUrls.js (#13584)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:05:38 +01:00
Naz
dbdf7160bf Simplified DynamicRedirectManager's constructor
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- This simplification allows to make the test for dependent services a lot more readable without a need to stub urlUtils
2021-10-13 10:04:55 +02:00
PJ
57ce743d98
Replace i18n with tpl in output/authentication.js (#13581)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 09:00:19 +01:00
Tomás Castillo
2c659ea447
Replaced i18n.t w/ tpl helper in v3/posts.js file (#13580)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:58:34 +01:00
IncredibleZuess
dd5a96d37c
Replaced i18n.t w/ tpl in api/v2/utils/validators/input/setup.js (#13579)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:54:22 +01:00
IncredibleZuess
b2e4145bd9
Replaced i18n.t w/ tpl in api/v2/utils/validators/input/settings.js (#13578)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:53:57 +01:00
IncredibleZuess
0cbc813f28
Replaced i18n.t w/ tpl in core/server/api/v2/utils/validators/input/passwordreset.js (#13577)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package
2021-10-13 08:52:39 +01:00
IncredibleZuess
e0c0022cb7
Replaced i18n.t w/ tpl in core/server/api/v2/utils/validators/input/invites.js (#13576)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:52:19 +01:00
IncredibleZuess
6d4b682b95
Replaced i18n.t w/ tpl in api/v2/utils/validators/input/images.js (#13575)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-13 08:50:15 +01:00
Levi Richardson
6421f60852
Switch i18n.t to tpl in users.js (#13574)
refs: #13380

- i18n is deprecated and is being replaced with tpl
2021-10-13 08:44:04 +01:00
Fabien O'Carroll
b1914758b8 Added support for filter Offers by status
refs https://github.com/TryGhost/Team/issues/1131

This will allow Ghost Admin to display separate lists of active and
archived Offers! We must pass the options through so that the
OffersService is able to handle the filter passed in the request.
2021-10-12 18:39:25 +02:00
Sam Lord
a535cfdf16 Added metric-shipping to monitor boot-time
no issue
Boot-time metrics are really valuable for understanding how releases affect the performance of Ghost. The new @tryghost/metrics package lets us ship these metrics to different sources using the same configuration framework as @tryghost/logging introduced.
2021-10-12 15:01:50 +01:00
ItsMeSatan
af7fe99127
Replaced i18n.t with tpl in memberSigninUrls.js and oembed.js (#13564)
refs: #13380

- i18n is deprecated and is being replaced with tpl
2021-10-12 14:47:53 +01:00
PakkuDon
0fe62e3aee
Replaced i18n.t with tpl in core/server/services/bulk-email and core/server/services/permissions (#13562)
refs: #13380

- i18n is deprecated and is being replaced with tpl
2021-10-12 14:46:35 +01:00
Fabien 'egg' O'Carroll
b48c16c118
Added active column to offers table (#13592)
refs https://github.com/TryGhost/Team/issues/1131

This will be used as a flag to determine whether or not an Offer is
archived or active.
2021-10-12 15:20:45 +02:00
Fabien O'Carroll
1bb9c3a9ac Invalidated site cache when adding & editing Offers
no-issue

Because adding and editing Offers can update the redirects for Ghost, we
should ensure that any site cache is cleared so as to not conflict with
Offer redirects.
2021-10-12 15:20:31 +02:00
Fabien O'Carroll
37deda3587 Fixed handling of labs flag for Offers
no-issue

Because we only called `init` if the labs flag is enabled, when starting
up a site without the flag enabled - the listener for adding redirects
wasn't active. So new Offers would not have their redirects setup.
2021-10-12 15:20:31 +02:00
Marco F
ed6045d82c
Replaced i18n.t() with tpl() in v2/utils/validators/input/invitations.js (#13560)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 09:12:04 +01:00
PJ
9ccf590ddc
Replaced i18n with tpl in GhostMailer.js (#13555)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 09:10:50 +01:00
Indrakant Dana
e2aeca56e9
Replaced i18n.t w/ tpl in v3/utils/serializers (#13552)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 08:39:15 +01:00
Indrakant Dana
8029d1ce6a
Replaced i18n.t w/ tpl in v3/settings.js (#13551)
refs: TryGhost#13380

- The i18n package is deprecated. It is being replaced with the tpl package.
2021-10-12 08:36:11 +01:00
Shadman Ahmed Khan
c1789a3a03
Replaced i18n with tpl in core/server/api/v3 (#13548)
refs: #13380

- The i18n package is deprecated. It is being replaced with the tpl package.

Co-authored-by: Shadman Khan <shadmankhan@ShadmanMac.local>
2021-10-12 08:33:33 +01:00