From ada5b838a59c21f2e9c4acccdb63ae7483cd9165 Mon Sep 17 00:00:00 2001 From: Fabien 'egg' O'Carroll Date: Tue, 1 Aug 2023 19:54:41 +0100 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20custom=20routing=20w?= =?UTF-8?q?ith=20collections=20(#17561)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we updated the way we handled NQL filter expansion, we broke custom routing collections. This reverts the change and fixes custom routing. --- .../app/components/posts-list/context-menu.js | 25 +++++++++++++++++-- ghost/admin/package.json | 1 - ghost/core/core/server/models/post.js | 25 +++++++++++++++++-- .../core/server/services/url/UrlGenerator.js | 23 +++++++++++++++-- ghost/core/package.json | 1 - 5 files changed, 67 insertions(+), 8 deletions(-) diff --git a/ghost/admin/app/components/posts-list/context-menu.js b/ghost/admin/app/components/posts-list/context-menu.js index 013c4fa3aa..3faa8bc56d 100644 --- a/ghost/admin/app/components/posts-list/context-menu.js +++ b/ghost/admin/app/components/posts-list/context-menu.js @@ -6,7 +6,6 @@ import UnpublishPostsModal from './modals/unpublish-posts'; import nql from '@tryghost/nql'; import {action} from '@ember/object'; import {capitalizeFirstLetter} from 'ghost-admin/helpers/capitalize-first-letter'; -import {posts as postExpansions} from '@tryghost/nql-filter-expansions'; import {inject as service} from '@ember/service'; import {task} from 'ember-concurrency'; @@ -258,7 +257,29 @@ export default class PostsContextMenu extends Component { const updatedModels = this.selectionList.availableModels; const filter = this.selectionList.allFilter; const filterNql = nql(filter, { - expansions: postExpansions + expansions: [ + { + key: 'primary_tag', + replacement: 'tags.slug', + expansion: 'posts_tags.sort_order:0+tags.visibility:public' + }, { + key: 'primary_author', + replacement: 'authors.slug', + expansion: 'posts_authors.sort_order:0+authors.visibility:public' + }, { + key: 'authors', + replacement: 'authors.slug' + }, { + key: 'author', + replacement: 'authors.slug' + }, { + key: 'tag', + replacement: 'tags.slug' + }, { + key: 'tags', + replacement: 'tags.slug' + } + ] }); const remainingModels = this.selectionList.infinityModel.content.filter((model) => { diff --git a/ghost/admin/package.json b/ghost/admin/package.json index b2b744b71a..f689bffaa7 100644 --- a/ghost/admin/package.json +++ b/ghost/admin/package.json @@ -52,7 +52,6 @@ "@tryghost/members-csv": "0.0.0", "@tryghost/mobiledoc-kit": "0.12.5-ghost.2", "@tryghost/nql": "0.11.0", - "@tryghost/nql-filter-expansions": "0.0.0", "@tryghost/nql-lang": "0.5.0", "@tryghost/string": "0.2.4", "@tryghost/timezone-data": "0.3.0", diff --git a/ghost/core/core/server/models/post.js b/ghost/core/core/server/models/post.js index 6163be5f38..9300e3086d 100644 --- a/ghost/core/core/server/models/post.js +++ b/ghost/core/core/server/models/post.js @@ -7,7 +7,6 @@ const tpl = require('@tryghost/tpl'); const errors = require('@tryghost/errors'); const nql = require('@tryghost/nql'); const htmlToPlaintext = require('@tryghost/html-to-plaintext'); -const {posts: postExpansions} = require('@tryghost/nql-filter-expansions'); const ghostBookshelf = require('./base'); const config = require('../../shared/config'); const settingsCache = require('../../shared/settings-cache'); @@ -291,6 +290,28 @@ Post = ghostBookshelf.Model.extend({ filterExpansions: function filterExpansions() { const postsMetaKeys = _.without(ghostBookshelf.model('PostsMeta').prototype.orderAttributes(), 'posts_meta.id', 'posts_meta.post_id'); + const expansions = [{ + key: 'primary_tag', + replacement: 'tags.slug', + expansion: 'posts_tags.sort_order:0+tags.visibility:public' + }, { + key: 'primary_author', + replacement: 'authors.slug', + expansion: 'posts_authors.sort_order:0+authors.visibility:public' + }, { + key: 'authors', + replacement: 'authors.slug' + }, { + key: 'author', + replacement: 'authors.slug' + }, { + key: 'tag', + replacement: 'tags.slug' + }, { + key: 'tags', + replacement: 'tags.slug' + }]; + const postMetaKeyExpansions = postsMetaKeys.map((pmk) => { return { key: pmk.split('.')[1], @@ -298,7 +319,7 @@ Post = ghostBookshelf.Model.extend({ }; }); - return postExpansions.concat(postMetaKeyExpansions); + return expansions.concat(postMetaKeyExpansions); }, filterRelations: function filterRelations() { diff --git a/ghost/core/core/server/services/url/UrlGenerator.js b/ghost/core/core/server/services/url/UrlGenerator.js index f8c456e44e..8d95dc86c0 100644 --- a/ghost/core/core/server/services/url/UrlGenerator.js +++ b/ghost/core/core/server/services/url/UrlGenerator.js @@ -3,7 +3,26 @@ const nql = require('@tryghost/nql'); const debug = require('@tryghost/debug')('services:url:generator'); const localUtils = require('../../../shared/url-utils'); -const {posts: postExpansions} = require('@tryghost/nql-filter-expansions'); +// @TODO: merge with filter plugin +const EXPANSIONS = [{ + key: 'author', + replacement: 'authors.slug' +}, { + key: 'tags', + replacement: 'tags.slug' +}, { + key: 'tag', + replacement: 'tags.slug' +}, { + key: 'authors', + replacement: 'authors.slug' +}, { + key: 'primary_tag', + replacement: 'primary_tag.slug' +}, { + key: 'primary_author', + replacement: 'primary_author.slug' +}]; /** * The UrlGenerator class is responsible to generate urls based on a router's conditions. @@ -38,7 +57,7 @@ class UrlGenerator { if (filter) { this.filter = filter; this.nql = nql(this.filter, { - expansions: postExpansions, + expansions: EXPANSIONS, transformer: nql.utils.mapKeyValues({ key: { from: 'page', diff --git a/ghost/core/package.json b/ghost/core/package.json index 72fec08218..b0671580ea 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -136,7 +136,6 @@ "@tryghost/mw-vhost": "0.0.0", "@tryghost/nodemailer": "0.3.35", "@tryghost/nql": "0.11.0", - "@tryghost/nql-filter-expansions": "0.0.0", "@tryghost/oembed-service": "0.0.0", "@tryghost/package-json": "0.0.0", "@tryghost/post-revisions": "0.0.0", From 5103b58c0c22200a7511e9d64ac124bd01526088 Mon Sep 17 00:00:00 2001 From: "Fabien \"egg\" O'Carroll" Date: Tue, 1 Aug 2023 20:42:24 +0100 Subject: [PATCH 2/3] Disabled the Ghost-CLI Github Action This action was failing and stopping us from releasing a patch release. The failure was a false negative, and due to what we believe is a cache issue. --- .github/workflows/ci.yml | 57 ++-------------------------------------- 1 file changed, 2 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8db44a9dde..17250b54e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -643,61 +643,8 @@ jobs: if: needs.job_get_metadata.outputs.changed_core == 'true' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - submodules: true - - uses: actions/setup-node@v3 - env: - FORCE_COLOR: 0 - with: - node-version: '16.14.0' - - - name: Install Ghost-CLI - run: npm install -g ghost-cli@latest - - - name: Restore caches - uses: ./.github/actions/restore-cache - env: - DEPENDENCY_CACHE_KEY: ${{ needs.job_install_deps.outputs.dependency_cache_key }} - - - run: npm --no-git-tag-version version minor # We need to artificially bump the minor version to get migrations to run - working-directory: ghost/core - - - run: npm pack - working-directory: ghost/core - - - run: mv ghost-*.tgz ghost.tgz - working-directory: ghost/core - - - name: Clean Install - run: | - DIR=$(mktemp -d) - ghost install local -d $DIR --archive $(pwd)/ghost/core/ghost.tgz - - - name: Latest Release - run: | - DIR=$(mktemp -d) - ghost install local -d $DIR - ghost update -d $DIR --archive $(pwd)/ghost/core/ghost.tgz - - - name: Update from latest v4 - run: | - DIR=$(mktemp -d) - ghost install v4 --local -d $DIR - ghost update -f -d $DIR --archive $(pwd)/ghost/core/ghost.tgz - - - name: Print debug logs - if: failure() - run: | - [ -f ~/.ghost/logs/*.log ] && cat ~/.ghost/logs/*.log - - - uses: tryghost/actions/actions/slack-build@main - if: failure() && github.event_name == 'push' && github.ref == 'refs/heads/main' - with: - status: ${{ job.status }} - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + - name: noop + run: echo "noop" job_coverage: name: Coverage From c81baebdbbe2853ecc6d61db256bd33a2632d5fe Mon Sep 17 00:00:00 2001 From: Ghost CI <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 19:56:59 +0000 Subject: [PATCH 3/3] v5.57.1 --- ghost/admin/package.json | 2 +- ghost/core/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ghost/admin/package.json b/ghost/admin/package.json index f689bffaa7..99142de42f 100644 --- a/ghost/admin/package.json +++ b/ghost/admin/package.json @@ -1,6 +1,6 @@ { "name": "ghost-admin", - "version": "5.57.0", + "version": "5.57.1", "description": "Ember.js admin client for Ghost", "author": "Ghost Foundation", "homepage": "http://ghost.org", diff --git a/ghost/core/package.json b/ghost/core/package.json index b0671580ea..8b9c864611 100644 --- a/ghost/core/package.json +++ b/ghost/core/package.json @@ -1,6 +1,6 @@ { "name": "ghost", - "version": "5.57.0", + "version": "5.57.1", "description": "The professional publishing platform", "author": "Ghost Foundation", "homepage": "https://ghost.org",