Commit Graph

2165 Commits

Author SHA1 Message Date
Fabien "egg" O'Carroll
322dda10ab Removed flag check for running the collection service
This ensures that collections are updated in the background regardless of
whether or not the labs flag is enabled, which is important for the stability
of the collections database tables. In order to make sure we don't add a tonne
of event listeners during the tests we have to add a flag to make sure that the
service is treated as a singleton and only instanciated once. This should only
affect code running in tests, as we don't initialise services multiple times
2023-07-25 17:35:43 +02:00
Fabien "egg" O'Carroll
3d0825ea2f Supported ?include=count.posts for Collections API
Unfortuantely our framework is bookshelf centric so we have to refer to the
`withRelated` property rather than a more generic `include` property.

The collection entity already contains the list of post ids, so we can just
return the length of that array.
2023-07-25 16:56:22 +02:00
Fabien "egg" O'Carroll
431f0ed842 Fixed the "Can add a Collection" test
The test was addign an extra collection, but not cleaning it up - which makes it
hard to reason about other tests, especially when running them in isolation and
the state is different. This just cleans up the test and updates the browse test
to match the right snapshot.
2023-07-25 16:56:22 +02:00
Fabien "egg" O'Carroll
517c406e17 Added Collections Content API
The only usecases we need to support at the moment are reading individual
collections by ID and by Slug. We can extend this API as we get more usescases
in future.
2023-07-25 16:14:02 +02:00
Fabien 'egg' O'Carroll
63ab254e33
Removed posts from Collections API
The correct mechanism for fetching posts from a collection is via the Posts API.
This removes all functionality of getting posts from the Collections API.

Co-authored-by: Naz <hi@nazavo.com>
2023-07-25 13:19:19 +00:00
Naz
694ab1d32d Added support for expansions in collection filters
refs https://github.com/TryGhost/Arch/issues/46

- Similarly to post filters, collection filters now support both 'tag' and 'tags' nql filter keys when defining a filter for related tag slugs. For example, both `tag:avocado` and `tags:avocado` would both be valid collection filters that would filter by the same 'slug' property of the tags assigned to a post.
- Along with these changes had to rework the tags property of the collection posts to match the shape used in post resources. Moved from:
`tags: ['bacon', 'broc']`
to
`tags:[{slug: 'bacon'}, {slug: 'broc'}]`
2023-07-25 19:01:56 +08:00
Naz
8fa36916d7 Migrated admin and core modules to use nql-filter-expansions
refs https://github.com/TryGhost/Arch/issues/46

- Reused posts expansions from nql-filter-expansions module
2023-07-25 19:01:56 +08:00
Naz
c4351456c6 Made tag snapshots more accurate in collections test suite
refs https://github.com/TryGhost/Arch/issues/46

- Allows to actually verify in the snapshot itself if the tag filter is working correctly or not.
2023-07-25 19:01:56 +08:00
renovate[bot]
3830401d55 Update dependency @playwright/test to v1.36.2 2023-07-25 12:26:15 +02:00
Michael Barrett
8095843939
Added feature flag for import tier functionality (#17480)
refs https://github.com/TryGhost/Product/issues/3629
2023-07-25 10:52:52 +01:00
Sodbileg Gansukh
0b00c653cc Added margin override to the signup card input
no issues

- some themes have global styles applied to inputs and it breaks the card input layout because of the style conflict
- this adds some default margin values to fix the issue
2023-07-25 14:22:44 +08:00
Ghost CI
fc50d1e92c Merged v5.55.1 into main 2023-07-25 02:46:04 +00:00
Ghost CI
95d343a786 v5.55.1 2023-07-25 02:46:02 +00:00
Aileen Booker
eb303ec221 Fixed Segment event named wrong 2023-07-24 15:49:33 +01:00
Daniel Lockyer
d0f9c8cf0c Deduplicated eslint and eslint-plugin-ghost to top-level package.json
refs https://github.com/TryGhost/DevOps/issues/50

- this deduplicates where we define the version of `eslint` and
  `eslint-plugin-ghost` so it's easier to maintain
2023-07-24 16:21:47 +02:00
renovate[bot]
b5453e740e Update dependency yjs to v13.6.7 2023-07-24 10:38:06 +00:00
renovate[bot]
3b9b8009e1 Update dependency mysql2 to v3.5.2 2023-07-24 10:29:26 +00:00
Michael Barrett
184c6ae951
Retain newsletter subscriptions on suppression (#17373)
refs https://github.com/TryGhost/Product/issues/2610
2023-07-24 10:47:57 +01:00
Naz
baf0f4b692 Added /collections/slug/:slug Admin API endpoint
closes https://github.com/TryGhost/Arch/issues/45

- This endpoint is here to keep the convention of being able to fetch the resource by it's slug through a `GET /{resource_name}/slug/:slug`. It has identical output as the `GET /collections/:id` endpoint
- The alternative would be having an alias and try fetching by :id and then by slug if the result for id was null, but that would be a completely new pattern we have not used anywhere else yet.
2023-07-24 14:27:17 +08:00
Ghost CI
1b884a49ac v5.55.0 2023-07-21 15:03:14 +00:00
Fabien "egg" O'Carroll
66f7dcafab Fixed the {{#collection}} helper
We were not passing the `slug` to the `apiOptions` so the posts were not
correctly filtered, and on top of that the `collection` option had not been
added to the allow list of the Posts Content API. With these two fixes the
collection helper works as expected.
2023-07-21 16:23:31 +02:00
renovate[bot]
401c1a0d10 Update dependency postcss to v8.4.27 2023-07-21 14:42:30 +02:00
Naz
08c06129d3 Removed /collections/:id/posts endpoint
refs https://github.com/TryGhost/Arch/issues/16

- We made a decision to limit the API for fetching posts belonging to a certain collection to only the Posts API. The endpoint on the collections was an experiment that only brings unnecessary maintenance at this point of time.
2023-07-21 19:46:22 +08:00
Naz
6361423ff7 Fixed ability to remove post from an automatic collection
refs https://github.com/TryGhost/Arch/issues/16

- Post can be removed from a manual collection, but never from an automatic collection.
2023-07-21 19:46:22 +08:00
Naz
d7bbb0b935 Reworked PostsRepository to use model layer
refs https://github.com/TryGhost/Arch/issues/16

- Using the API directly on the repository level prevented us from ensuring collection consistency through transactions.
- This change migrates the PostsRepository to use Bookshelf model layer directly, which also allows to put queries into transactions.
- Additional optimization here was removing the `getAllPosts` method from CollectionService. This is an attempt to reduce the API surface of the  of the service before calling it a GA.
2023-07-21 19:46:22 +08:00
Naz
ef41fd86c2 Enabled all collection tests
refs https://github.com/TryGhost/Arch/issues/16
refs 97f24338bf

- With introduction of transactional post_collections updates the test flakiness should go away.
2023-07-21 19:46:22 +08:00
Naz
3dc27f505c Wrapped collection's creation in transaction
refs https://github.com/TryGhost/Arch/issues/16

- This is needed to avoid stale data/race conditions when processing collection post updates
2023-07-21 19:46:22 +08:00
Naz
0880770d50 Wrapped collection's post adding logic in transaction
refs https://github.com/TryGhost/Arch/issues/16

- Having transactional collection post updates makes sure there are no race conditions when updating collection_posts relations. Without the transactions collection was prone to update relations based on a stale state causing problems like described in the linked issue
2023-07-21 19:46:22 +08:00
renovate[bot]
3a751e6f84 Update sentry-javascript monorepo to v7.60.0 2023-07-21 12:36:13 +02:00
Steve Larson
22441fe730
Made lexical rendering async (#17438)
-moved lexical rendering to async
-includes rendering for front end and email
-necessary to pull dynamic data into render method, e.g. collections
2023-07-20 17:48:48 -05:00
Sanne de Vries
9e61f26586
Fixed visual bug on signup card frontend html (#17430)
No ref
2023-07-20 10:07:54 +00:00
renovate[bot]
dd328f39f7 Update sentry-javascript monorepo to v7.59.3 2023-07-20 07:27:24 +02:00
Ghost CI
a17b2f024e Merged v5.54.4 into main 2023-07-19 13:18:09 +00:00
Ghost CI
a715b8f3ed v5.54.4 2023-07-19 13:18:06 +00:00
Daniel Lockyer
b7aac3e360
🐛 Fixed ghost.min.css asset compilation
refs https://github.com/TryGhost/DevOps/issues/48

- due to changes in the build workflow, we no longer depended on
  `ghost`'s own `build` before producing the tarball
- as a result, the minified css was not produced and private pages were
  unstyled
- this adds our own `build` step to the list of dependencies for
  `archive`
2023-07-19 14:51:17 +02:00
Ronald Langeveld
5b7bca1f1e
Bumped Koenig Packages (#17418)
no issue

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at bfc259e</samp>

Updated content rendering packages to fix bugs and improve performance.
This affects how Ghost outputs HTML and AMP pages from the
`@tryghost/kg-default-nodes` and `@tryghost/kg-lexical-html-renderer`
modules.
2023-07-19 11:11:15 +00:00
renovate[bot]
b82cbeec04 Update sentry-javascript monorepo to v7.59.2 2023-07-19 07:53:05 +02:00
Naz
53f9f954c1 Added tag filter support to collections
refs https://github.com/TryGhost/Arch/issues/41

- When an new collection is created the relational "tags" filter is now picked up properly and appropriate posts matching the tag filter are assigned and stored in the collection. Example collection filter that is now supported: `tags:['bacon']`
- Additionally cleaned up returned collection post DTOs, so we return as little data as possible and add only the fields that are needed
2023-07-18 20:18:54 +08:00
Ghost CI
367ff21ed6 Merged v5.54.3 into main 2023-07-17 14:18:35 +00:00
Ghost CI
b74e29aa70 v5.54.3 2023-07-17 14:18:33 +00:00
Kevin Ansfield
53096e214c
🐛 Fixed poor performance when rendering beta editor posts (#17388)
no issue

- bumps `@tryghost/kg-lexical-html-renderer` which includes a change to drastically reduce the number of `jsdom` instantiations made when rendering text content
2023-07-17 14:21:37 +01:00
Kevin Ansfield
636b1e67b2
Fixed pages API test snapshot having a flaky cache string (#17391)
no issue

- `x-cache-invalidate` will vary across different runs as the post's preview uuid will be different each time the post is created
2023-07-17 13:21:00 +00:00
Kevin Ansfield
135f5fa287
🐛 Fixed poor performance when rendering beta editor posts (#17388)
no issue

- bumps `@tryghost/kg-lexical-html-renderer` which includes a change to drastically reduce the number of `jsdom` instantiations made when rendering text content
2023-07-17 13:42:55 +01:00
Naz
97f24338bf Commented out flaky collections tests
refs https://github.com/TryGhost/Arch/issues/16

- There's a race condition happening when processing multiple collection updates at the same time. It causes the state to be inconsistent between the runs.
- Once the event handling is improved these tests should be put back into action
2023-07-17 20:02:54 +08:00
Ronald Langeveld
baa84f4765
Added base styles for Header Card v2 (#17387)
refs https://github.com/TryGhost/Product/issues/3508

- copied over styles from the signup card, which is what the new header
card is loosely based on.
- this is meant to be hacked till we have the new header card look
pretty.

---

<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 150aa92</samp>

This change introduces a new header card v2 component that allows users
to create custom headers for their Ghost site. It adds a new CSS file
`header_v2.css` that defines the styles and responsive behavior for the
component. The file uses modern CSS features to achieve a flexible and
consistent design. The file is part of the frontend module of the Ghost
core repository.
2023-07-17 10:49:48 +00:00
Naz
ea2defb76c Updated collection descriptions
refs https://github.com/TryGhost/Arch/issues/25

- Updated collection descriptions to be less wordy and avoid a redundant "Collection" in them.
2023-07-17 18:43:21 +08:00
Naz
c733424cc5 Fixed collections ordering
refs https://github.com/TryGhost/Arch/issues/25

- When run against different DB Engines the returned order of collections belonging to a post is not consistent (SQLite vs MySQL). Having a primitive ordering by slug allows to keep the order compatible
2023-07-17 18:43:21 +08:00
Naz
9bfb197a85 Added fixtures for collection posts
refs https://github.com/TryGhost/Arch/issues/25

- Adds collection_posts fixtures
2023-07-17 18:43:21 +08:00
Naz
b5d1245be1 Added posts_collections table population
refs https://github.com/TryGhost/Ghost/pull/17247

- When the instance is started the posts_collections records should be pre-filled for built-in collections. This is to avoid expensive processing during every instance startup.
2023-07-17 18:43:21 +08:00
Naz
ed91412cd5 Changed "index" collection name to "latest"
https://github.com/TryGhost/Arch/issues/25

- This naming matches how the collection will be visible in the cards and how it's marketed. Naming it "index" even for internal purposes will get confusing.
2023-07-17 18:43:21 +08:00