Commit Graph

9936 Commits

Author SHA1 Message Date
Naz
23ba543abd Removed forceStart in theme e2e tests
refs https://github.com/TryGhost/Toolbox/issues/135

- The reason the test **settings** test was failing when the force start flag was removed in the **custom themes** was the bridge! The bridge was trying to execute function on the frontend when the boot was done without initializing the frontend. The setting test was changing locale and the timezone which triggered events calling up on frontend components - we clearly don't want to do this when the instance is booted without the frontend
- To make event initialization conditional moved it to the "init". This way the event listeners are only set up when we boot with the "frontend" flag set to true
2021-11-22 14:51:23 +04:00
Thibaut Patel
3a6efc73b3 Added productCard labs flag
refs https://github.com/TryGhost/Team/issues/1233

- flag for the product card development
2021-11-22 11:46:28 +01:00
Sanne de Vries
9e513f334a Fixed callout card emoji alignment
Refs https://github.com/TryGhost/Team/issues/1206
2021-11-22 10:52:21 +01:00
Sanne de Vries
969921f444 Fixed accent color background in email callout cards
Refs https://github.com/TryGhost/Team/issues/1206
2021-11-22 10:45:03 +01:00
Naz
917641be4f Removed no backend optimization in boot
refs https://github.com/TryGhost/Toolbox/issues/135

- The expectation is to only skip monting the backend API routes instead of skipping creation of whole GhostServer
2021-11-22 21:56:32 +13:00
Naz
bbc93ff996 Renamed withBackend/withFrotned to backend/frontend
refs https://github.com/TryGhost/Toolbox/issues/135

- Shorter name still makes sense and the "with" might be causing confusion understanding what's gonig on during the boot time
2021-11-22 21:56:32 +13:00
Naz
149c100b4c Fixed frontend initialization in "mock-express" tests
refs https://github.com/TryGhost/Toolbox/issues/135

- Without sensible defaults the web app was not initializing either the backend nor the frontned parts of the application. Fixed the defaults so the problem doesn't happen again and optimized mock-express-style initialization to only initialize the frontend routing
2021-11-22 21:56:32 +13:00
Naz
d0dfac438d Changed /^testing/ regexp use to startsWith method
no issue

- `startsWith` method is way easier to read and understand. also, **probably** has better performance comparing to building up a regexp and then matching
2021-11-22 21:56:32 +13:00
Naz
ae397eecdf Fixed UrlService initialization
refs https://github.com/TryGhost/Toolbox/issues/135

- When there's no instance of cache available the code to retreive it should not execut. Duh!
2021-11-22 21:56:32 +13:00
Naz
ae5dd8ad30 Fixed event listener pileup
refs https://github.com/TryGhost/Toolbox/issues/135

- When instantiating new Urls/Resources object in the UrlService's init on every test suite start it was loosing track of past events (softReset wasn't doing the cleanup properly). Not initializing new classes "fixes" the problem partially, by not loosing track of those event listeners. The real fix should be proper even listener cleanup on every soft reset!
2021-11-22 21:56:32 +13:00
Naz
34b0196c0f Added writeDisabled flag to URL file cache
refs https://github.com/TryGhost/Toolbox/issues/135

- Allows to turn off overwriting urls/resources JSON file caches on testing environment. This is needed to have predictable state when running multiple test suites that stop the Ghost process and try to persiste URL cache.
2021-11-22 21:56:32 +13:00
Naz
ee4d2dd1a8 Extracted a local file cache class for URLs
refs https://github.com/TryGhost/Toolbox/issues/135

- This extracts the file storage knowledge out of the URL Service an allows to have optional features based on the environment - for example turning off writing cache for when running tests
2021-11-22 21:56:32 +13:00
Naz
3b390639c4 Introduced booting from fixture url cache in test environment
refs https://github.com/TryGhost/Toolbox/issues/135

- To be able to reliably start ghost instance without a frontend the process needs access to urls/resources caches
- Storing the configuration in "paths" for now as there's no better place for it untill we are able to mock the content folder in pre-boot
2021-11-22 21:56:32 +13:00
Naz
c12ae81ece Introduced "withFrontend" and "withBackend" flags in boot
refs https://github.com/TryGhost/Toolbox/issues/135

- These flags are meant to control initialization of sections of the boot sequence depending on the needs - with or without bakend (API)/frontend (public handlebars site)
- Ideally these flags should not be passed deep into the components, and if the are (like in the web/parent/app case) it's a smell that we need to move things up into the boot process!
2021-11-22 21:56:32 +13:00
Rishabh
b59330c392 Added labs flag for file upload cards
refs https://github.com/TryGhost/Team/issues/1229
refs https://github.com/TryGhost/Team/issues/1230
refs https://github.com/TryGhost/Team/issues/1231
2021-11-22 13:25:34 +05:30
djordje vlaisavljevic
c77059f645 Updated accordion frontend styles 2021-11-19 19:00:59 +01:00
djordje vlaisavljevic
8fa2a45dd8 Removed flex from accordion content 2021-11-19 18:40:53 +01:00
djordje vlaisavljevic
d562166d26 Updated accordion frontend styles 2021-11-19 18:35:11 +01:00
djordje vlaisavljevic
b2f7b00875 Updated accordion frontend styles 2021-11-19 18:35:11 +01:00
Daniel Lockyer
85d0ee3568 Updated Admin to v4.22.4 2021-11-19 16:00:31 +00:00
Hannah Wolfe
592d02fd23 🐛 Fixed perms error when building public assets
closes: https://github.com/TryGhost/Ghost/issues/13739

- Ghost cannot write to the core folder in correctly configured production installations
- Built assets therefore need to be written to the content directory
- Ghost does not overwrite anything in the content folder as part of an upgrade, therefore static files that are provided by Ghost
  must still live inside /core
- So as a result, we now have core/frontend/public and content/public
2021-11-19 11:36:45 +00:00
Peter Zimon
f0a5c32411 Updated NFT card markup 2021-11-19 11:59:45 +01:00
Hannah Wolfe
80358266b2 Added perf-improving PRAGMAs in testing mode
- These two things are meant to improve performance at the cost of reliability.
- Perfect for testing, however I think they make a minimal impact on modern SSDs :(
- Still worth a shot to see if it helps with CI
2021-11-19 10:47:21 +00:00
Peter Zimon
b417489664 Fixed default alignment for NFT cards 2021-11-19 11:02:17 +01:00
Sodbileg Gansukh
e7c810caf6 Removed callout text specific CSS, and fixed the vertical alignment 2021-11-19 16:00:39 +08:00
Rishabh
36b4c7de78 Refined frontend and email styles for toggle card
refs https://github.com/TryGhost/Team/issues/1209
2021-11-19 09:55:19 +05:30
djordje vlaisavljevic
aa00428e1f Updated accordion frontend styles 2021-11-18 21:49:06 +01:00
Sanne de Vries
53c22e5c08 Updated callout card rendering
Refs https://github.com/TryGhost/Team/issues/1206
2021-11-18 20:43:44 +01:00
Peter Zimon
7892bc9dfe Added button AMP styles 2021-11-18 17:54:36 +01:00
Daniel Lockyer
80d5f89382 Lazy loaded cheerio dependency
refs https://github.com/TryGhost/Toolbox/issues/136

- `cheerio` isn't needed during the boot but it takes time and memory to
  load the library
- this commit moves `cheerio` requires later into the code to when they
  are needed
2021-11-18 17:31:04 +01:00
Peter Zimon
bf18b89a45 NFT card refinements
- Added AMP support
- Refined default frontend styles
2021-11-18 17:29:18 +01:00
Peter Zimon
45a814f596 Added Opensea logo to NFT cards 2021-11-18 17:29:18 +01:00
djordje vlaisavljevic
bc457e206f Updated Accordion card styles on frontend 2021-11-18 09:58:14 +01:00
Kevin Ansfield
ca26c3ab0a Added logging of unexpected errors in oembed service
no issue

- if we encounter an unexpected error whilst fetching embed details we return a generic validation error so we're not leaking any details about the URL that is being hit, however that meant the error logs were only showing validation errors making debugging difficult
- added explicit logging of the unexpected error before throwing the generic validation error
2021-11-17 13:31:20 +00:00
Peter Zimon
bbceace31c Implemented table based NFT email styles 2021-11-17 14:05:39 +01:00
Sam Lord
0692ddf57d Revert "Replace update user last seen middleware with package version"
This reverts commit 07f8c6efbb.

Revert "Remove unused unit test file"

This reverts commit f1798119d3.
2021-11-17 11:00:55 +00:00
Sodbileg Gansukh
43ec108f75 Updated bookmark card CSS 2021-11-17 18:24:18 +08:00
Sodbileg Gansukh
dad9dba872 Updated gallery card CSS 2021-11-17 18:24:18 +08:00
Hannah Wolfe
332beaaf90
Moved "vhost-utils" to config helpers
- These are simple functions that get data from config in a specific format
- They are also used by the topmost part of the application
- Config helpers seems like a reasonable fit to get them out of the web folder
- Functions have also been renamed to try to get them to make more sense
2021-11-17 08:37:08 +00:00
Fabien O'Carroll
e6773d00e6 Updated NFT Embed custom provider
refs https://github.com/TryGhost/Team/issues/1211

Added ?format=json to the URL in an attempt to mitigate any issues with
weird caching and receiving HTML rather than JSON.

Used `type` in place of `card_type` to closer follow how the bookmark
card/embed works.

Removed the html & width/heihgt properties which are not needed at all.
2021-11-16 21:28:36 +02:00
Sanne de Vries
b6b024b132 Fixed missing bottom spacing on email callout cards 2021-11-16 19:19:49 +01:00
Kevin Ansfield
63b7ef7dc6 Added Tenor contentFilter setting to config
refs https://github.com/TryGhost/Team/issues/1217

- moved top-level `tenorApiKey` to `tenor:apiKey` and added `tenor:contentFilter`
- added base config to `defaults.json`
- updated `public-config.js` and API output serializer to use the new top-level `tenor` key
2021-11-16 17:42:26 +00:00
Sanne de Vries
9fba3d6661 Updated callout card for dark mode themes
Refs https://github.com/TryGhost/Team/issues/1206

- Switched to semi-transparent background colors so that it works out of the box with dark mode themes
2021-11-16 18:35:34 +01:00
Sam Lord
a5484a0fe1 Fixed transaction logic in data importer
https://github.com/TryGhost/Toolbox/issues/130

The transaction no longer commits in the promise chain, which wasn't
valid logic for a transaction, since it is commited automatically when
the promise chain resolves, and rollsback automatically when the
promise chain rejects.

This makes code which fails during the transaction error in the right
place, instead of getting stuck here. (Especially good for writing
tests).

The tests for this code can now live in the integration folder.
2021-11-16 17:09:55 +00:00
Sam Lord
07f8c6efbb Replace update user last seen middleware with package version
no issue

Part of the goal to move these middleware packages to remove untested code from the codebase
2021-11-16 15:58:45 +00:00
Hannah Wolfe
4f9b72ff43
Renamed middlewares to middleware consistently
- This is a minor bugbare, but it will affect some configuration I'm about to do for c8
- I've been wanting to do it for ages, middleware is plural all on it's own so it's an odd affectation in our codebase
- This also only exists in 2 places, everywhere else we use "middleware"
- Sadly it did result in a lot of churn as I did a full find and replace, but consistency is king!
2021-11-16 15:51:47 +00:00
Hannah Wolfe
9a8b18a473
Swapped boot order for version util
- The version util is now required in logging as well as sentry and migrations
- I can see us needing it in config too, so put it straight to the first item
- we do this so that the debug statements can tell us how long each step took as we look to optimise everything
2021-11-16 14:44:14 +00:00
Hannah Wolfe
b781e47cb9
Changed to use different fixtures during testing
- this keeps production and test fixtures separate, so that changing the prod fixtures doesn't change the shape of our tests.
- we may still want to test that the production fixtures do what we expect, but that can be handled in a separate integration test, by specifically setting the fixture path
2021-11-16 14:03:42 +00:00
Sanne de Vries
5ccc1914f5 Updated rendering of callout card to override theme dark mode 2021-11-16 13:55:06 +01:00
Hannah Wolfe
426c8bf918
Refactored fixtures to be loaded by fixture manager
refs: https://github.com/TryGhost/Toolbox/issues/133

- instead of just a collection of utils, we now have a class that manages fixtures
- this should allow us to change the path to fixtures, e.g. between prod/dev and test, so that different fixtures can be loaded by default
- also makes it easier to test the fixture manager code itself
2021-11-16 11:17:03 +00:00
Naz
458f5b894b Moved Urls and Rexources reinitialization
refs https://github.com/TryGhost/Toolbox/issues/127

- New instances or Urls and Resources during init were messing up test suites without an obvious solution. Moved them to only be triggered when the cache is present.
- Note the e2e-frontend tests are failing if thie initialization happens every time when init is called. There seems to be some reliance on Resources being the same intsance between "softReset" which seems wrong, but wasn't able to track it down definitevely
2021-11-17 00:00:23 +13:00
Naz
1a3a80cacc Added resource cache handling to UrlService
refs https://github.com/TryGhost/Toolbox/issues/127

- The resource cache is needed to have quick and reproducible state of the resouces tied to the urls instead of waiting for the db queries to finish.
- Allows to use UrlService without any database connection at all - useful for unit testing
2021-11-17 00:00:23 +13:00
Naz
9b309cf4e7 Refactored URL cache persistance
refs https://github.com/TryGhost/Toolbox/issues/127

- This refactor is needed to accomodate incoming "resource cache" which shares a lot of common logic with how url cache is operated
2021-11-17 00:00:23 +13:00
Hannah Wolfe
88311381ef Added a URL Service boot log
- At the moment there's no way to see in the logs when the URL Service finally finishes
- This is the moment when Ghost stops serving 503s
- Adding this log line so it's clear to see, which migh be useful whilst were refactorising
2021-11-16 19:13:36 +13:00
Sanne de Vries
632e15affc Added callout card email styles
Refs https://github.com/TryGhost/Team/issues/1206
2021-11-15 19:45:33 +01:00
Naz
83a54eeb99 Fixed UrlService's getPermalinkByUrl method
refs https://github.com/TryGhost/Toolbox/issues/127

- The "withUrlOptions" is used internally in the constructor by the frontend's routers. To avoid passing around a whole function from the frontend routers duplicated the functionality from there.
2021-11-15 19:40:44 +04:00
Naz
e1ebbff3b5 Removed unused field
refs https://github.com/TryGhost/Toolbox/issues/127

- Wasn't able to find any references to the "originalValue" field in permalinks, so removed it to keep the code clean and readable
2021-11-15 19:38:41 +04:00
Naz
042618fe93 Fixed failing tests
refs 5a62253466

- The UrlService was relying on a "hidden" identifier field that was passed along with a router object. Now it's passed as an explicit parameter from the "frontend" to the backend's UrlService
2021-11-15 19:37:49 +04:00
Naz
5a62253466 Removed "router" dependency from UrlGenerator
refs https://github.com/TryGhost/Toolbox/issues/127

- Passing around whole instance of a frontend router was an overkill when there are only 3 static pieces of information that needed to be loaded. Extracting the router out makes the UrlGenerator way more readable, tests slimer, and the memory footpring of the process should be slightly lighter
- The toString overloading didn't make sense at the time of this refactor, maybe if there's a concrete usecase we could resurect it in a form of passing in a router's name or something.
2021-11-15 18:32:34 +04:00
Naz
6e205a3f05 Extracted an explicit "permalink" parameter in UrlGenerator constructor
refs https://github.com/TryGhost/Toolbox/issues/127

- This is an effor t to define a precise set of data needed for the UrlGenerator to function, which should help with decoupling it from the frontend routes
- This is almost the last piece to free us up from the massive "router" object that has been passed around
2021-11-15 18:32:34 +04:00
Naz
677ea1073d Extracted an explicit "resourceType" parameter in UrlGenerator constructor
refs https://github.com/TryGhost/Toolbox/issues/127

- This is an effor t to define a precise set of data needed for the UrlGenerator to function, which should help with decoupling it from the frontend routes
2021-11-15 18:32:34 +04:00
Naz
ca2809d432 Extracted an explicit "filter" parameter in UrlGenerator constructor
refs https://github.com/TryGhost/Toolbox/issues/127

- This is an effor t to define a precise set of data needed for the UrlGenerator to function, which should help with decoupling it from the frontend routes
2021-11-15 18:32:34 +04:00
Naz
176c369620 Refactored UrlGenerator to use DI constructor pattern
refs https://github.com/TryGhost/Toolbox/issues/127

- This is a standard across the codebase which is good to follow for better testability
2021-11-15 18:32:34 +04:00
Daniel Lockyer
6fd5139372
Merged v4.22.3 into main
v4.22.3
2021-11-15 13:44:09 +00:00
Daniel Lockyer
c960a4bdeb Updated Admin to v4.22.3 2021-11-15 13:43:15 +00:00
Hannah Wolfe
bb47b9e327
🐛 Fixed EACCES error from card assets on boot
refs: https://github.com/TryGhost/Ghost/issues/13739

- This is a short term fix to prevent this new feature causing boot errors
- This will allow development to continue uninterrupted this week & also allow us to do a rollout
- The proper fix will be to move where these files live, which will be done before we go live
2021-11-15 12:12:22 +00:00
Rishabh
c3b6e21617 Refined frontend style for toggle cards
refs https://github.com/TryGhost/Team/issues/1209

- adds open/close behavior to toggle cards
- updates styling
2021-11-15 16:43:23 +05:30
Sanne de Vries
158285bfff Added variable background color to callout on frontend
Refs https://github.com/TryGhost/Team/issues/1206
2021-11-15 11:37:23 +01:00
Naz
33d02cddfe Added JSDocs to the UrlGenerator class
refs https://github.com/TryGhost/Toolbox/issues/127

- Before refactoring the URL Generator constructor to have a smaller construcotr, documented current state for future reference
2021-11-15 12:41:52 +04:00
Fabien O'Carroll
31e103be9d Updated NFT OEmbed provider to return metadata
refs https://github.com/TryGhost/Team/issues/1211

Instead of rendering the HTML as an embed - we will send back the
necessary data. This will allow us to keep all the knowledge of HTML
structure in the Koenig repository.
2021-11-15 10:31:35 +02:00
Daniel Lockyer
6a3429ed00 Updated Admin to v4.22.2 2021-11-12 16:00:24 +00:00
Peter Zimon
a68854c3bd Added NFT card email styles
- added email styles for NFT cards
- fixed buttons having capitalized text
2021-11-12 16:39:35 +01:00
Peter Zimon
661bde3892 NFT card frontend style refinements 2021-11-12 15:55:19 +01:00
Peter Zimon
19f74ff0f7 Added NFT card frontend styles 2021-11-12 13:57:01 +01:00
Naz
cb652aed3f Added url cache persistance on instance shutdown
refs https://github.com/TryGhost/Toolbox/issues/125

- The in-memory url objects would be persisted in the contents folder allowing to take advantage of the cache during the next instance start
2021-11-13 01:01:28 +13:00
Naz
04c6716171 Moved url cache loading logic behind the flag
refs https://github.com/TryGhost/Toolbox/issues/125

- The url loader is not fully working and is in very experimental mode. The aim is to ship this version to allow other team members to play with the feature in limited use-cases like testing evnironment
2021-11-13 01:01:28 +13:00
Naz
5b2009a268 Removed unuseful comment
no issue

- The file has been moved to the frontend and we have linting rules to remind moving "server" requires
2021-11-13 01:01:28 +13:00
Naz
4582fd48b5 Parameterized url cache storage path
refs https://github.com/TryGhost/Toolbox/issues/116

- This should allow testing in a bit easier manner and would place the file into a more suitable directory
- ideally we'd put an alfa flag bahind this new "cached routes" feature to have less consequences to deal with if we have to back out
2021-11-13 01:01:28 +13:00
Naz
36bc05447c Booting instance with persisted urls
refs https://github.com/TryGhost/Toolbox/issues/116

- This is a PoC to check out how viable this approach is and if it's worth merging into main as a very quick win
- The `urls.json` is in a bad place right now should probably live in a data folder
2021-11-13 01:01:28 +13:00
Peter Zimon
8714b4e2b7 Updated frontend styles for buttons 2021-11-12 11:50:20 +01:00
Fabien O'Carroll
39f01f4925 Removed SVG from NFT OEmbed
refs https://github.com/TryGhost/Team/issues/1211

The SVG is causing issues with copy/paste in Firefox, we're going to
remove it and later replace it with a PNG.
2021-11-12 12:43:25 +02:00
Naz
6023b78688 Added "urlCache" labs alpha flag
refs https://github.com/TryGhost/Toolbox/issues/126

- A flag go control the experimental URL Cache alpha feature
2021-11-12 12:24:27 +04:00
Naz
b707f325c8 Exposed config initialization from Resources
refs https://github.com/TryGhost/Toolbox/issues/125

- Config initialization for the URL Resouces is a separate stage which doesn't have to be bundled along with resouce fetching method
- It gives even more flexibility when composing different ways to get the "resources" loaded into memory: right now it's from the DB but could come from a cache
2021-11-12 12:18:17 +04:00
Naz
963df37aaa Reworded UrlService's init documentation
refs https://github.com/TryGhost/Toolbox/issues/125

- The "init" method pattern is not used across the codebase and it's pretty standard to start the service in this way. Previous description was outdated and misguiding
2021-11-12 12:16:08 +04:00
Naz
39b480682f Fixed UrlService initialization
refs https://github.com/TryGhost/Toolbox/issues/125

- The await was missing from the "fetchResources" call which made the queue pick up less information than it should've
2021-11-12 12:15:01 +04:00
Naz
376e2f4cf3 Separated event listeners from resource fetching
refs https://github.com/TryGhost/Toolbox/issues/125

- The "fetchResources" method did way to many things extracted event listener setup logic to a separate method
- This allows to call out these stages as needed if we retreive resources separately from a cache of some sort and don't need to wait for the database response
2021-11-12 11:56:16 +04:00
Naz
46c3b53979 Moved queue start into UrlServices init block
refs https://github.com/TryGhost/Toolbox/issues/125

- The "fetchResources" is only used from one place and does way to many things at once:
- Fetches resources from the DB-
- Hooks up event listeners
- Starts the queue

- These are three different things, and should be three different methods ideally
2021-11-12 11:56:16 +04:00
Kevin Ansfield
6431e1a01c
Exposed tenorApiKey via config endpoint if set (#13734)
refs https://github.com/TryGhost/Team/issues/1217

- add `tenorApiKey` to `publicConfig.config()
- update canary config endpoint output serializer to include `tenorApiKey` when the `gifsCard` labs flag is enabled
2021-11-11 18:07:19 +00:00
Fabien O'Carroll
dda8e0249b Wired up NFT custom provider to canary API
refs https://github.com/TryGhost/Team/issues/1211

This registers the NFT custom OEmbed provider to the OEmbed service for
the canary API. This should probably be done in a centralised place -
but we do not have a single instance of the OEmbed service.

When we have more information about why the OEmbed service is
instantiated like this, we can think about moving it into a singleton
service with an `init` method - which is where we can register custom
providers.
2021-11-11 17:16:03 +02:00
Fabien O'Carroll
3b7284b62f Initial OpenSea NFT OEmbed customer provider
refs https://github.com/TryGhost/Team/issues/1211

This adds the initial custom OEmbed provider for OpenSea NFT's - we're
using the new custom provider functionality so that we can easily change
the logic here without affecting the core functionality.
2021-11-11 17:16:03 +02:00
Fabien O'Carroll
e69d112c77 Added support for custom OEmbed providers
refs https://github.com/TryGhost/Team/issues/1211

In order to override the default OEmbeds for OpenSea NFT's we need a way
to provide out own OEmbed data. We will want this in future too for
custom Twitter embeds, so this has been built in a way which allows
extension.
2021-11-11 17:16:03 +02:00
Kevin Ansfield
4b78586ad1 Added gifsCard labs flag
refs https://github.com/TryGhost/Team/issues/1217

- labs flag for adding a gif selector in a similar fashion to our Unsplash image selector
2021-11-11 15:07:35 +00:00
Naz
a64c186179 Fixed typo
no issue
2021-11-11 16:52:11 +04:00
Daniel Lockyer
2f57e0ab6b
Merged v4.22.1 into main
v4.22.1
2021-11-10 12:58:49 +00:00
Daniel Lockyer
8d958fc167 Updated Admin to v4.22.1 2021-11-10 12:56:23 +00:00
Fabien 'egg' O'Carroll
7fae5b8341
🐛 Fixed setting Tier prices after changing Stripe accounts
refs https://github.com/TryGhost/Team/issues/1212

This now emits the event when the service is reconfigured, rather than
when we issue the reconfigure command, which causes the event and the
action to be run in the wrong order. This would then cause knock on effects
of having the database in an undefined state - with stripe data in not linked
to the current Stripe account.
2021-11-10 14:03:03 +02:00
Naz
975750afe9 Added ".ogg" audio support to Media API
refs https://github.com/TryGhost/Toolbox/issues/95
refs 9edd299905

- A follow up to the original audio support. ".ogg" format is widely supported by the most popular browsers (ref. https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers), so makes sense to support it out of the box too
2021-11-10 10:46:26 +04:00
Thibaut Patel
0b85068900 Added first pass of injected css for callout card
refs https://github.com/TryGhost/Team/issues/1205

- basic css for callout card display
2021-11-09 21:14:33 +01:00
Rishabh
ac61ac3d53 Added alpha flag for accordion card
refs https://github.com/TryGhost/Team/issues/1209

- adds alpha flag for editor accordion card
2021-11-09 19:07:50 +05:30
Naz
9edd299905 Added audio upload support to Media API
refs https://github.com/TryGhost/Toolbox/issues/95
refs 4907b7bf1e

- We need support for audio media uploads to be able to used them in cards. The new supported formats are .mp4 and .wav
- Example source files downloaded from https://filesamples.com/
2021-11-09 16:39:33 +04:00
Naz
4721b75463 Moved `/media/thumbnail/ Admin API endpoint to /media/thumbnail/upload
refs  https://github.com/TryGhost/Toolbox/issues/120

- Changed endpoint name as it suits way better to the `/upload` postfix convention we use along with all other endpoints that support file uploads
2021-11-09 16:39:33 +04:00
Kevin Ansfield
7aa8d9df5c Removed need for !important in button card css
refs https://github.com/TryGhost/Team/issues/1210

- `a.kg-btn` has higher specificity than the `.gh-content a` in Casper we were previously working around with `!important`
- dropping `!important` makes it easier for themes to override
2021-11-09 12:30:34 +00:00
Peter Zimon
a789528a56 Added NFT card alpha flag 2021-11-09 13:27:36 +01:00
Naz
61b82e3ae2 Added thumbnail upload endpoint to Media API
closes https://github.com/TryGhost/Toolbox/issues/120

- Allows to update and upload brand new thumbnail images for previusly uploaded media resources
- The endpoint is available udner alpa flag as part of Admin API at `PUT /media/thumbnail/`
- As an input accepts following parameters:
- *required* `file` field containing an image file
- *required* `url` field containing parent media file URL
- *optional* `ref` as a field to put in an ID to reference the resource on the client side

- The response has following format:
```
{
  media: [{
    url: 'http://127.0.0.1:2369/content/images/1991/11/nicevideo_thumb.png'
    ref: 'unique-id-420'
  }]
}
```
2021-11-09 16:07:23 +04:00
Naz
2a7ef77a7b Added ability to delete existing files through storage adapters
refs https://github.com/TryGhost/Toolbox/issues/120

- When editing an uploaded media thumbnail  file there'a need to remove existing thumbnail to keep media files:thumbnails 1:1. - Because the API client only has a public URL under which the resource is served it can only provide that as an API input, the `urlToPath` was also added to the base class of LocalStorageAdapter (it might be moved up to the BaseAdapter in the future if we see a need)
2021-11-09 16:07:23 +04:00
Naz
3f59c1893b Renamed variables to better fit the context
no issue

- Slightly less code without compromising readability
2021-11-09 16:07:23 +04:00
Kevin Ansfield
40c4342786 Added first pass of injected css for button card
refs https://github.com/TryGhost/Team/issues/1207

- basic CSS for button card display
  - accent color for button background
  - left/center alignment
2021-11-09 11:10:18 +00:00
Thibaut Patel
aebd042d1a Added calloutCard labs flag
refs https://github.com/TryGhost/Team/issues/1205

- flag for editor callout card development
2021-11-08 17:11:35 +01:00
Kevin Ansfield
4d54337a65 Added buttonCard labs flag
no issue

- flag for editor button card development
2021-11-08 15:42:02 +00:00
Naz
92986b77e3 Renamed whitelist -> allowlist
no issue

- Renames to follow the naming convention from https://mysqlhighavailability.com/mysql-terminology-updates/
2021-11-08 16:09:30 +04:00
Naz
f0242baf9f Added static file limit handling in Files API
refs https://github.com/TryGhost/Toolbox/issues/114

- Just like with media files same limits apply and can be configured through the usual limit service's config
2021-11-08 16:09:30 +04:00
Naz
be748f2f6d Added static file handling to the frontend
refs https://github.com/TryGhost/Toolbox/issues/114

- Static files uploaded through the Admin Files API should be accessible throught the world under `/content/files/`
- Note the feature is behind an alpha "filesAPI" flag, which has to be enabled in the labs first
2021-11-08 16:09:30 +04:00
Naz
a099073fde Added Files API behind an alpha flag
refs https://github.com/TryGhost/Toolbox/issues/114

- Files API is meant to be used for non-executable file uploads of all sorts
- The files are stored and retrieved for download as-is
2021-11-08 11:40:17 +04:00
Naz
c6e1e95c26 Added "filesAPI" labs alpha flag
refs https://github.com/TryGhost/Toolbox/issues/114

- A flag go control the Files API alpha feature
2021-11-08 11:33:06 +04:00
Naz
151ab6968c Added local file storage adapter
refs https://github.com/TryGhost/Toolbox/issues/114

- This adapter is meant to power Files API
- The files will be stored under `/files/` in the configured content path and under `/content/files/` URL.
2021-11-08 11:29:33 +04:00
Daniel Lockyer
dc69c839ae Updated Admin to v4.22.0 2021-11-05 16:00:29 +00:00
Hannah Wolfe
95d4111d58
Removed completed TODO for helper init
refs: 9d7049cd3f

- The helper service refactor I did  a little while back moved this to a better location:
9d7049cd3f (diff-81327b09890d6df7b87046cfdfa924f5f03c51221bf29980a015a30bee6d1884R134)
- But I forgot to clean up. Removing the commented block and now completed TODO
2021-11-05 14:00:47 +00:00
Naz
f43eeacfd0 Changed thumbnail to be an optional parameter
refs https://github.com/TryGhost/Toolbox/issues/95

- With incoming support of audio media files thumbnail would not be a required parameter
2021-11-05 17:17:18 +04:00
Naz
ad2583530a Renamed getLocalFileStoragePath
refs https://github.com/TryGhost/Toolbox/issues/95

- getLocalImagesStoragePath makes a lot more sense in context of what the method really does
2021-11-05 17:17:18 +04:00
Naz
12cad62a53 Fixed up JSDoc
no issue

- The method description was a complete tautology
2021-11-05 17:17:18 +04:00
Naz
22ac28b250 Fixed ThemeStorage inheritance
refs https://github.com/TryGhost/Toolbox/issues/95

- The ThemeStorage was never supposed to inherit image specific mehods. The LocalStorageBase is all it needs, might be even too much
- Look mum no saveRaw!
2021-11-05 17:17:18 +04:00
Naz
c802097b72 Renamed LocalFileStorage to LocalImages store
refs https://github.com/TryGhost/Toolbox/issues/95

- This naming corresponds way better to what the actual adapter does
2021-11-05 17:17:18 +04:00
Naz
f3fc1bd5d4 Extracted local storage adapters' into a base class
refs https://github.com/TryGhost/Toolbox/issues/95

- The MediaStorage adapter and LocalFileStorage were almost identical, having a common base class makes sense here.
- Having a distinct class for the "LocalFileStorage" makes it easy to spot the implementation difference from the StorageBase - the "saveRaw" method, which is not present in the StorageBase
- The LocalFileStorage will become an LocalImageStorage in next commit as that name corresponds way better to what it does!
- Test files need a good cleanup
2021-11-05 17:17:18 +04:00
Hannah Wolfe
e25f1df0ae
Added card-asset config with sensible default
- This comment removes the block on themes controlling card assets via config
- It also changes the default behaviour from "false" config (doing nothing) to excluding bookmark and gallery card assets
- This is essentially the same thing, as only bookmark and gallery card assets exist at the moment, but it's being done because it makes this feature future-proof for all theme developers.
- As we add new cards, all themes will automatically get the assets to make them work
- As theme developers want to, they can create their own custom assets and disble assets for any cards they support by adding them to the exclude list
- They can also remove any custom code they currently have to support bookmark and gallery cards, and set card_assets: true in package.json to use the defaults instead
2021-11-05 12:20:02 +00:00
Hannah Wolfe
e4c1e0d938
Added middleware for serving minified card assets
- Wired up the forntend to include and serve the minified css and js card assets if they exist
- This is a very naive implementation - ideally we wouldn't have to inject this in multiple places
- This allows us to add files to src/cards and have them included in themes
- The system is currently disabled due to an override in the theme config setting assets to false
2021-11-05 11:41:03 +00:00
Hannah Wolfe
d9bdc444a3
Ensured nonexistant public files fallback to 404
- If we register the serve public file middleware for a file that doesn't exist, this will currently throw an ENOENT error
- Instead, we want to fall back to a standard 404 so that this behaves normally
- This will be useful for the card asset service, where the cards.min.css and cards.min.js files may or may not exist
2021-11-05 09:13:23 +00:00
Naz
6435dec938 Added media file handling to the frontend
refs https://github.com/TryGhost/Toolbox/issues/95

- Media files uploaded through the Admin Media API should be accessible throught the frontend under `/content/media/`
- Note the feature is behind an alpha "mediaAPI" flag that has to be enabled in the labs first
2021-11-04 21:22:06 +04:00
Naz
142eff22ee Fixed thumbnail file name
refs https://github.com/TryGhost/Toolbox/issues/95

- The uploaded media thumbnail name should have a "_thumb" postfix to be able to distinguish thumbnails from other files. This can be handy if we decide to store them in a different location in the future.
2021-11-04 19:03:45 +04:00
Rishabh Garg
3b90b1f335
Moved launchComplete user setting as global editor setting (#13703)
refs https://github.com/TryGhost/Team/issues/807

The launch wizard completed flag was previously stored at per user level in accessibility column of user table, so an administrator still got the option to complete the launch wizard even if the owner had completed it previously, which is not expected pattern. This change moves the launch complete flag for Admin to common settings from per user level so a site only needs to complete the launch wizard once irrespective of which user completes it

- adds new `editor_is_launch_complete` setting to track if a site launch steps are completed in Admin
- adds new migration util to easily allow adding new setting 
- adds migration to introduce new `editor_is_launch_complete` setting
- adds migration to update launch complete flag for a site if any of the users have already completed the launch steps
2021-11-04 18:03:51 +05:30
Hannah Wolfe
fdf38ba8c6
Initial card asset service implementation
- Requires the new @tryghost/minifier package
- Adds a new service that will handle taking config from the theme and optionally including assets for Koenig editor cards
- It supports both css and js as cards may need one or both
- For any given config, the tool can find the matching files to include and concat and minify them into one file per type
- Currently has an override in place so that this is not yet customisable in the theme - will remove this override when we're ready for the feature
2021-11-04 11:34:40 +00:00
Naz
df5c87fae3 🐛 Fixed a 500 error when uploading invalid routes.yaml
closes https://github.com/TryGhost/Toolbox/issues/111

- Just like with invalid JSON redirects files we should return a BadRequestError instead of throwing a generic 500 when the redirects.yaml file fails parsing
2021-11-04 11:52:52 +04:00
Naz
2dac3d489f Added "mediaAPI" labs flag
refs https://github.com/TryGhost/Toolbox/issues/95

- A flag go control the Media API alpha feature
2021-11-04 10:48:53 +04:00
Naz
091240db48 Added thumbnail upload support to Media API
refs https://github.com/TryGhost/Toolbox/issues/95

- Each media file quires a thumbnail and these changes provide a capability to upload them along with media files.
- The thumbnail file is always required and has to be the format of already supported image formats
- The thumbnail should be uploaded as a part of "thumbnail" attachment in the request
- The regression tests added with this changeset will be claened up and moved to unit-tests (this is a dirty-but-working version!)
- The thumbnail always gets a name of the uploaded media file and keeps it's own extension.
- The thumbnails is accessible under the url present in the "thumbnail_url" reponse field
2021-11-04 10:23:29 +04:00
Fabien O'Carroll
6e53527666 Fixed init method for Offers service
refs https://github.com/TryGhost/Ghost/commit/da152a0a1

The cleanup of the Offers labs flag inadvertently removed this logic.
2021-11-03 17:17:33 +02:00
Fabien 'egg' O'Carroll
da152a0a13
Removed references to Offers labs flag (#13709)
refs https://github.com/TryGhost/Team/issues/1115

This feature is now GA, and the flag has been hardcoded to `true`, here we clean up the
remaining references as they're no longer needed.
2021-11-03 17:11:48 +02:00
Thibaut Patel
c32cc3e48b 🐛 Fixed broken assets for theme/design preview
refs https://github.com/TryGhost/Team/issues/1190

- The assets were broken in Admin when the frontend and admin urls were different
- Fixed the issue by changing the `asset` helper to output absolute URLs when the frontend/admin urls are differents
2021-11-03 11:20:04 +01:00
Sanne de Vries
6c487ca2c9 Fixed links overflowing in mobile email preview in Chrome 2021-11-03 11:12:32 +01:00
Naz
0ccf31cdb5 Fixed error message when booting with no redirects
refs 91efa4605c

- When the instance is booted without any redirects files configured it's not supposed to error but rather default to an "empty" [] redirects configuration.
- Ideally the logic shoudl not contain try/catch block at all and fail as soon as there's any error during the initialization. This wasn't changed at this time due to possible break of existing Ghost instances
2021-11-03 13:50:24 +04:00
Fabien O'Carroll
1386d6ca5c Added membersAutoLogin labs flag
refs https://github.com/TryGhost/Team/issues/1067

- To be used whilst developing the auto-login functionality so we can
  test this on production sites.
2021-11-03 11:17:02 +02:00
Naz
e1d16a55e1 Fixed DynamicRedirectManager initialization
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- After a bump of the '@tryghost/express-dynamic-redirects' the constructor has changed it's signature, so this needed an adjustment
2021-11-03 07:41:55 +13:00
Naz
c3edd4b3d4 Fixed redirects regression tests
refs https://linear.app/tryghost/issue/CORE-84/have-a-look-at-the-eggs-redirects-refactor-branch

- The problem this change is addressing is inability to override config values once the code is extracted into a class+DI pattern
- The work around is restarting the instance with the configuration testing expected behavior - in this case missing or existing types of redirects files
2021-11-03 07:41:55 +13:00
Fabien O'Carroll
91efa4605c Used DynamicRedirectManager for Custom Redirects
refs https://github.com/TryGhost/Members/commit/9e59f5a9

Since we have a DynamicRedirectManager for handling adding/removing
redirects at runtime, we no longer need the custom-redirects middleware.
The redirects service does however need an init method now to add the
custom redirects at Ghost boot, so it's been refactored into our Class &
DI pattern.
2021-11-03 07:41:55 +13:00
Naz
d657432531 Cleaned up use of 'content/media' magic string
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- `content/media` path is now a part of the constants package and should've been used instead of a magic-string.
2021-11-03 00:33:28 +13:00
Naz
d20732ce34 Imroved media validation middleware
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Error messages are now more specific when uploaded media files fail the validation check
2021-11-03 00:33:28 +13:00
Naz
02da62ee48 Added limit service check for uploaded media filesize
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Uploading large files is costly and might cause DDoS. Limits would allow fair use of the site instance.
- The configureation in hostSettings to enable an "uploads" limit would look like following:
```
"hostSettings": {
    "limits": {
            "uploads": {
                "max": 5,
                "error": "Your plan supports uploads of max size up to {{max}}MB. Please upgrade to reenable uploading."
            }
    }
}
```
- Read more at ba37890be4/packages/limit-service (usage)
2021-11-03 00:33:28 +13:00
Naz
d5b1552dc9 Simlified limit service initialization
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Init function for the limits service initialization is never called with parameters, so it doesn't make sense to keep that option around and have unnecessary logic handling it
2021-11-03 00:33:28 +13:00
Naz
f9a8edb1a0 Refactored upload middleware
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- Using a wrapping object to store enableClear/multer instances didn't make any sense
2021-11-03 00:33:28 +13:00
Naz
4a551661d9 Implemented '/media/upload' API endpoint
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- This is an experimental implementation of video file upload support
- Also the output serializer skipped use of url utils in favor of inline implementatoin - this should almost certainly be it's own package
2021-11-03 00:33:28 +13:00
Naz
5242566252 Added local media storage adapter
refs https://linear.app/tryghost/issue/CORE-121/create-a-video-storage-adapter

- This is an experimental implementation of video file upload support (audio is yet to follow)
- The storage adapter still needs more thinking as it's almost the same as the "LocalStorgeAdapter" that stores images.
- Also the output serializer skipped use of url utils in favor of inline implementatoin - this should almost certainly be it's own package
2021-11-03 00:33:28 +13:00
Fabien O'Carroll
c45afc7f26 🐛 Fixed email type when creating Members via API
refs https://github.com/TryGhost/Team/issues/1197

We were always sending the 'signin' email, rather than respecting the
email_type param passed to the API. This updates our email sending when
creating members to force the requested type if it's present.
2021-11-02 12:56:00 +02:00
Kevin Ansfield
b690fce219 Added cardSettingsPanel labs flag
no issue

- used to toggle editor UI experiments/exploration for cards with settings
2021-11-02 09:55:55 +00:00
Rishabh
1a9705b824 🐛 Fixed error in setting page access to tiers
closes https://github.com/TryGhost/Ghost/issues/13704
closes https://github.com/TryGhost/Team/issues/1186

- updates page serializer to handle new `visibility_filter` property for filtering access on specific tier
- this change was already added for `posts` but was missed on `pages`, so parsing filter on `visibility` filter was failing
2021-11-02 13:36:32 +05:30
Fabien 'egg' O'Carroll
b36d0cc1c4
🐛 Fixed idempotentcy of addPermissionToRole util (#13685)
refs https://github.com/TryGhost/Team/issues/1178

The "up" migration that this util generates correctly throws if the
pre-requisite data cannot be found in the database. The "down" migration
however was incorrectly mirroring this behaviour of throwing - which
meant that it wasn't idempotent, as it does not require a permission or
role to existing if it wants to move relations between them.
2021-11-01 09:27:50 +00:00
Daniel Lockyer
5b5240cab8 Updated Admin to v4.21.0 2021-10-29 16:00:28 +01:00
Enrique Benitez
7f001a4758
Replaced moment with luxon in amp helper (#13683)
refs: #13648

- We are replacing moment with luxon as it is now recommended.
2021-10-28 20:10:53 +01:00
Thibaut Patel
d0933c51ad Revert "Switched AMP to be 'off' by default in all new Ghost instances"
This reverts commit 98fd48cb32.
2021-10-28 18:52:31 +02:00
Thibaut Patel
98fd48cb32 Switched AMP to be 'off' by default in all new Ghost instances
refs https://github.com/TryGhost/Team/issues/1189

- The world & internet is slowly moving away from AMP
2021-10-28 18:13:25 +02:00
Naz
d89b8448ab Added a not to the Images API ref field
refs https://github.com/TryGhost/Ghost/pull/10534

- The original PR has no explanation around the purpose of the ref field and it's easy to forget without knowing a wider context. Documented it to remember next time we come around working on this part of the codebase!
2021-10-28 16:05:54 +04:00
Thibaut Patel
6e0bd7e7b5 Added fallbacks when the site title is undefined
refs https://github.com/TryGhost/Team/issues/1180

- An undefined site title was causing the `null` string to show in the html title tag on tag and author pages
2021-10-27 12:18:57 +02:00
John O'Nolan
297e173544 Updated member signup email copy 2021-10-26 17:53:35 -04:00
Daniel Lockyer
6802a61307
Merged v4.20.4 into main
v4.20.4
2021-10-26 13:21:41 +01:00
Daniel Lockyer
3c4419f717 Updated Admin to v4.20.4 2021-10-26 13:20:31 +01:00
Naz
f6c81033d7
🐛 Fixed 500 error when visiting an email-only post link
refs 74280cfbea

- We allow to send email-only posts when using v4 Admin API, but it's possible to configure a v3 Theme with a site instance which resulta in an unsupported behavior throwing a 500.
- With this fix a 404 will be returned when an email-only post is viewed through the public email-only post URL
2021-10-26 13:04:09 +01:00
Naz
6e6f427149 🐛 Fixed 500 error when visiting an email-only post link
refs 74280cfbea

- We allow to send email-only posts when using v4 Admin API, but it's possible to configure a v3 Theme with a site instance which resulta in an unsupported behavior throwing a 500.
- With this fix a 404 will be returned when an email-only post is viewed through the public email-only post URL
2021-10-26 16:01:10 +04:00
Fabien O'Carroll
bccc8790f0 Fixed max-complexity-warnings for stripe_connect API
no-issue

This removes the logic to check if stripe connect is allowed into the
stripe connect service, which makes the feature easier to maintain, as
well as fixes the v3 API - which previously did not have this check.
2021-10-25 14:06:28 +02:00
Fabien O'Carroll
a68b96001c Fixed max-complexity-warnings for members API
no-issue

This removes logic from the Members API controller, and into the Members
BREAD service, this allows our controllers to be simpler and easier to
maintain, as well as keeping the important logic all together.
2021-10-25 14:06:12 +02:00
Daniel Lockyer
df51c757a1 Updated Admin to v4.20.3 2021-10-25 10:28:23 +01:00
Daniel Lockyer
6d9ee79ad8 Updated Admin to v4.20.2 2021-10-25 08:19:06 +01:00
Daniel Lockyer
85911658b3 Updated Admin to v4.20.1 2021-10-22 20:08:55 +01:00
Kevin Ansfield
a485509a2f
🐛 Fixed GA labs flags not appearing enabled in settings API (#13681)
no issue

The way GA flags were introduced means that they stop existing in the `'labs'` setting in the db and are instead forced to always return `true` when checking the flag in the labs service. However, Admin which uses the flags fetches them via the `/settings/` API endpoint which was only returning the raw labs setting db value meaning GA flags appeared to be disabled unless the flag had previously been enabled and no settings save had occured.

- updated the settings bread service to replace the labs setting value with the JSON stringified output of `labs.getAll()` which is the ultimate source-of-truth for a feature being enabled/disabled
  - extracted `browse()` behaviour to an internal `_formatBrowse()` method so we can apply the same filtering/modification for output of `browse()` and `edit()`

Co-authored-by: Fabien O'Carroll <fabien@allou.is>
2021-10-22 19:59:13 +01:00
Daniel Lockyer
0e844989f1 Updated Admin to v4.20.0 2021-10-22 17:19:47 +01:00
Fabien O'Carroll
f3bb6b43a5 Added Offers feature to Ghost
refs https://github.com/TryGhost/Team/issues/1115

This allows users to create Offers for Tier/Cadence pairs in order to
provide discounted subscriptions to Members! We have support for
percentage based discounts & fixed price discounts, either for the first
payment, all payments, or a number of monthly payments.

Offers also have a code, which can be used as an easy way to share them,
as visiting https://site.com/offer-code will automatically open Portal
with the Offer prepopulated.
2021-10-22 17:55:34 +02:00
Fabien O'Carroll
696d8e3c49 Added 404 handling for edit Offer
no-issue

This was also missing as part of the Offers API.
2021-10-22 16:16:39 +02:00
Kevin Ansfield
a6982d5606
Added ability for themes to define custom settings (#13661)
closes https://github.com/TryGhost/Team/issues/1164

Themes can now define custom settings via their `package.json` file, and use them in templates via `@custom.{setting}`. Values for custom settings can be changed by site owners through a redesigned "Design settings" area in the admin interface.

Full announcement, documentation, and examples will be made available soon.

Co-authored-by:
- Sanne de Vries (@sanne-san)
- Thibaut Patel (@tpatel)
2021-10-22 15:02:16 +01:00
Kevin Ansfield
0c6cd37679 Fixed missing space between authors in emails
no issue

- author line was appearing as "Author One,Author Two,..." with no space
- fixed the generation of `post.authors` when serializing a post before it's rendered for email
2021-10-22 14:41:15 +01:00
Daniel Lockyer
e834904125
Fixed verification threshold when set to 0
no issue

- if the verification threshold is 0, `_.get(..)` becomes falsy so we
  fallback to Infinity
- this is not correct - we only want to default to Infinity if the value
  is not set
- this commit explicitly compares the config value to `undefined` and sets
  the fallback accordingly
2021-10-22 15:33:59 +02:00
Kevin Ansfield
d7fbf94d91
Fixed ETag header for admin templates not changing between versions (#13680)
refs https://github.com/TryGhost/Team/issues/1175

We found the ETag header sent when serving the Admin template for /ghost/ was not changing between versions which after an upgrade could result in out of date cached content being served containing links to JS/CSS files that no longer existed.

The culprit is weak etags served by Node's `send` package, coupled with Admin template filesize not changing between versions and `npm pack` setting a fixed modification date for every file. See https://github.com/pillarjs/send/issues/176 for more details.

- updated the Admin app's controller to read the template and generate an md5 hash of the contents so we can serve a strong ETag header value when serving the `/ghost/` html
2021-10-22 14:25:58 +01:00
Fabien O'Carroll
363eb94aee Handled 404 for Offer not found
no-issue

This was missing handling! We need to throw a NotFoundError so we
return with the correct response.
2021-10-22 14:22:33 +02:00
Fabien 'egg' O'Carroll
d962f0e18e
Removed NOT NULL constraint from portal_title (#13659)
refs https://github.com/TryGhost/Team/issues/1163

We want to make the title for Offers optional, our nullable validation
means that we cannot store an empty string, so we must remove the NOT
NULL constraint from the column if we want to store either an empty
value or null.

There is a bug with editing columns in SQLite with `knex` which strips all
the indexes, so we have to manually add them afterwards.
2021-10-22 14:14:49 +02:00
Daniel Lockyer
ed6a8dca76 Inlined package requires to save boot time and memory
no issue

- following on from f4fb0fcbaa,
  this commit moves around some package requires in Ghost
- these are often niche packages that do something in a subsystem of
  Ghost, and are not necessarily be needed to boot the application
- these packages use non-negligible CPU and memory when they are
  required, so it makes sense to lazy-require them
- the concern here is that we obscure the code too much by moving
  random requires further into code, but the changes are small and the
  improvements big
- this commit bring the boot time since 4.19.0 down ~31% and initial
  memory usage down by a total of ~12%
2021-10-22 09:57:59 +02:00
Hannah Wolfe
2d0b5c872f
Renamed frontend/web/app to site
- This leaves us room to bring the frontend app in as app.js
2021-10-21 19:54:50 +01:00
Hannah Wolfe
faea2da596
Moved server/web/site to frontend/web
- we're slowly trying to draw the lines between the backend and the frontend correctly
- these files deal only with serving the frontend so they should live there
- there are lots of mixed requires in these files, so having them in the right place makes that clear
2021-10-21 19:28:18 +01:00
Fabien O'Carroll
8c9b4d18bf Fixed error when enabling Offers via labs
no-issue

The listOffers method requires an options object. This was missed during
the update.
2021-10-21 20:05:42 +02:00
Hannah Wolfe
2777093c76
Refactored model init to be implicit
- no more need to explictly add a model file to be loaded!
- this makes building Ghost just the tiniest smidge easier
2021-10-21 17:01:26 +01:00
Hannah Wolfe
99fde5154f
Fixed dependency on the order of models
- this has been a niggle for ages, we shouldn't need to care what order our models are loaded in
- this is stopping us from having a built-in model loader and "frameworkizing" models
2021-10-21 16:57:36 +01:00
Kevin Ansfield
1708f0c3a4 Fixed custom theme settings not being available when expected
closes https://github.com/TryGhost/Team/issues/1172

Custom theme settings sync and cache population had been left to complete in the background as it wasn't essential for it to be complete for the front-end to start. However that was causing problems for the API where theme activation and custom theme settings list requests happen very close together, with the latter often not containing the theme settings data when it is expected to.

- changed `activationBridge.*` methods to `async` so they can `await` the completion of custom theme settings sync before activating a theme
2021-10-21 15:02:52 +01:00
Fabien O'Carroll
39160fc794 Passed Offer model to MembersAPI
refs https://github.com/TryGhost/Team/issues/1166

The MembersAPI needs access to the Offer model so that we can remove all
the Stripe related data when Stripe is disconnected.
2021-10-21 15:39:26 +02:00
Fabien O'Carroll
03d4561a5f Added relation between Member & OfferRedemption
refs https://github.com/TryGhost/Team/issues/1135

This will allow us to fetch the OfferRedemptions for a Member so that we
can display them on the Member details page.
2021-10-21 15:39:26 +02:00
Iuri Mendes
7debc28832
Removed "The team at X" from member emails (#13615)
closes: https://github.com/TryGhost/Ghost/issues/13613

- The language "The team at X" didn't suit all Ghost users. The language is more appropriate without it.
2021-10-21 13:58:34 +01:00
Hannah Wolfe
a1ad9f2870
Reworked init migrations to use async/await (#13635)
- use async/await and fat arrow syntax
- makes it easier to refactor later as "this" context is then reliable
2021-10-21 11:19:59 +01:00
Naz
07afb08875 Made storage calls related to images use "images" feature
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- Having this preemptive change allows to separate implementation of "image" storage from future usecases like "videos", "audios" etc. Even if the "image" adapter is not configured the default behavior will fallback to use the "active" storage adapter. If there's a need to handle "images" differently through a custom apapter that'll work out of the box ;)
2021-10-21 20:22:45 +13:00
Naz
f890d8d4cd Enabled passing through a feature name to utilize with a storage adapter
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- When the storage is requested the caller can now specify a "feature" they want to use the storage for. For example there could be different configurations for "images" or "vidoes" storages and the caller would not necessarily have to know about the details of how the feature is implemented.
2021-10-21 20:22:45 +13:00
Naz
98c27b5555 Added multiple adapters capability to adapter manager
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- There's a need to support multiple adapter variations per given adapter type (storage, sso, etc.)
- With the introduced changes we can specify a version of an adapter that should be fetched based on `:feature` postfix. For example:

`adapterManager.getAdapter('storage')` -  would return the default adapter listed under "active" configuration
`adapterManager.getAdapter('storage:videos') - would return an adapter configured for videos *feature*

- Here's an example configuration for a custom video storage:
```
"storage": {
    "active": "LocalFileStorage",
    "videos": "ghost-storage-custom-video",
    "ghost-storage-custom-video": {
        "custom": "configHere"
    }
}
```
2021-10-21 20:22:45 +13:00
Naz
e90c4217e5 Added a doc to adapter service coinfig mapper 2021-10-21 20:22:45 +13:00
Hannah Wolfe
360f7490dd
Refactored fixture utils scout style
- This is a minor refactor to reorder functions, use async/await & fat arrows
- It will make the coming bigger refactor slightly easier to read :D
- This should not make any functional changes
2021-10-20 19:54:14 +01:00
Kevin Ansfield
256f16a01f
🐛 Fixed URLs not being correctly transformed during insert operations (#13618)
closes https://github.com/TryGhost/Team/issues/1150

Our override of the base Bookshelf `insert` operation so that our own `formatOnWrite()` method is called on attributes was working on a false assumption that an `attrs` attribute is passed in as it is for the `update` operation. Instead Bookshelf's base update uses the `model.attributes` values to create an `attrs` object that is then passed through the usual `.format()` method meaning that our `insert` override was not actually doing anything.

- added a failing regression test for the `formatOnWrite()` override behaviour
- adjusted our insert/update overrides to set an internal `_isWriting` property on the model, then if that property is true our `.format()` override (which is called by Bookshelf on a generated `attrs` object during inserts) we manually call our `.formatOnWrite()` method
  - updated both overrides even though `update` was working for consistency and less cognitive overhead for reasoning between two different approaches
2021-10-20 15:22:46 +01:00
Kevin Ansfield
59a6f040d2 Fixed custom theme settings being clobbered with duplicate-named themes
refs https://github.com/TryGhost/Team/issues/1149

Ghost allows different themes to have the same `name` value in `package.json` but gives them a custom name based on the zip file used to upload it. The custom theme settings service however was always using the package.json name meaning that when syncing a theme with a duplicate name it was overwriting the settings for all other themes.

- bumped `@tryghost/custom-theme-settings-service` which changes the `.activateTheme()` signature to accept a theme name as the first argument
- updated our calls to `.activateTheme()` to pass Ghost's known theme name as the first argument so we're always syncing with the correct `theme` field value in the `custom_theme_settings` table
2021-10-20 13:25:02 +01:00
Fabien 'egg' O'Carroll
4e326123d3
Updated Offers related tables (#13609)
no-issue

* Removed NOT_NULL constraint from stripe_coupon_id

When handling disconnecting from Stripe - we remove all Stripe data from
our database to ensure we do not have bad/invalid data stored. Removing
this constraint will allow us to set the value to NULL.

* Added created_at column to offer_redemptions

Offer Redemptions are not just a joining table, but an event. A created_at
date allows them to be ordered

Because this is in alpha it is simpler to just drop the tables and
re-add them, due to offer_redemptions depending on offers, we also drop
this table and re-add it.
2021-10-20 14:22:37 +02:00
Daniel Lockyer
1fd980ee9b Set global Luxon timezone override to UTC
refs https://linear.app/tryghost/issue/CORE-113/start-off-luxon-refactor

- we're planning on switching to Luxon for our date/timezone library,
  eventually replacing `moment` and `moment-timezone`
- the first step is to set the global timezone override to UTC, which is
  done in `core/server/overrides.js`
- also adds a test to ensure we're setting the timezone correctly
- this was mostly pulled from https://moment.github.io/luxon/#/zones?id=changing-the-default-zone
2021-10-20 09:19:29 +02:00
Naz
393280b6ae Reworked LocalFileStore methods to use async syntax
refs https://linear.app/tryghost/issue/CORE-1/multiple-adapters-per-type

- While digging around this area refactored the code to use more readable async/await syntax instead of chaining then's
- Dropped unneeded "catch" block in save method as all it was doing was rethrowing an error with out additional handling
2021-10-20 10:29:46 +04:00