mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-04 02:01:58 -05:00
🐛 Fixed custom routing with collections (#17561)
When we updated the way we handled NQL filter expansion, we broke custom routing collections. This reverts the change and fixes custom routing.
This commit is contained in:
parent
b6e8208950
commit
ada5b838a5
5 changed files with 67 additions and 8 deletions
|
@ -6,7 +6,6 @@ import UnpublishPostsModal from './modals/unpublish-posts';
|
||||||
import nql from '@tryghost/nql';
|
import nql from '@tryghost/nql';
|
||||||
import {action} from '@ember/object';
|
import {action} from '@ember/object';
|
||||||
import {capitalizeFirstLetter} from 'ghost-admin/helpers/capitalize-first-letter';
|
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 {inject as service} from '@ember/service';
|
||||||
import {task} from 'ember-concurrency';
|
import {task} from 'ember-concurrency';
|
||||||
|
|
||||||
|
@ -258,7 +257,29 @@ export default class PostsContextMenu extends Component {
|
||||||
const updatedModels = this.selectionList.availableModels;
|
const updatedModels = this.selectionList.availableModels;
|
||||||
const filter = this.selectionList.allFilter;
|
const filter = this.selectionList.allFilter;
|
||||||
const filterNql = nql(filter, {
|
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) => {
|
const remainingModels = this.selectionList.infinityModel.content.filter((model) => {
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
"@tryghost/members-csv": "0.0.0",
|
"@tryghost/members-csv": "0.0.0",
|
||||||
"@tryghost/mobiledoc-kit": "0.12.5-ghost.2",
|
"@tryghost/mobiledoc-kit": "0.12.5-ghost.2",
|
||||||
"@tryghost/nql": "0.11.0",
|
"@tryghost/nql": "0.11.0",
|
||||||
"@tryghost/nql-filter-expansions": "0.0.0",
|
|
||||||
"@tryghost/nql-lang": "0.5.0",
|
"@tryghost/nql-lang": "0.5.0",
|
||||||
"@tryghost/string": "0.2.4",
|
"@tryghost/string": "0.2.4",
|
||||||
"@tryghost/timezone-data": "0.3.0",
|
"@tryghost/timezone-data": "0.3.0",
|
||||||
|
|
|
@ -7,7 +7,6 @@ const tpl = require('@tryghost/tpl');
|
||||||
const errors = require('@tryghost/errors');
|
const errors = require('@tryghost/errors');
|
||||||
const nql = require('@tryghost/nql');
|
const nql = require('@tryghost/nql');
|
||||||
const htmlToPlaintext = require('@tryghost/html-to-plaintext');
|
const htmlToPlaintext = require('@tryghost/html-to-plaintext');
|
||||||
const {posts: postExpansions} = require('@tryghost/nql-filter-expansions');
|
|
||||||
const ghostBookshelf = require('./base');
|
const ghostBookshelf = require('./base');
|
||||||
const config = require('../../shared/config');
|
const config = require('../../shared/config');
|
||||||
const settingsCache = require('../../shared/settings-cache');
|
const settingsCache = require('../../shared/settings-cache');
|
||||||
|
@ -291,6 +290,28 @@ Post = ghostBookshelf.Model.extend({
|
||||||
filterExpansions: function filterExpansions() {
|
filterExpansions: function filterExpansions() {
|
||||||
const postsMetaKeys = _.without(ghostBookshelf.model('PostsMeta').prototype.orderAttributes(), 'posts_meta.id', 'posts_meta.post_id');
|
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) => {
|
const postMetaKeyExpansions = postsMetaKeys.map((pmk) => {
|
||||||
return {
|
return {
|
||||||
key: pmk.split('.')[1],
|
key: pmk.split('.')[1],
|
||||||
|
@ -298,7 +319,7 @@ Post = ghostBookshelf.Model.extend({
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
return postExpansions.concat(postMetaKeyExpansions);
|
return expansions.concat(postMetaKeyExpansions);
|
||||||
},
|
},
|
||||||
|
|
||||||
filterRelations: function filterRelations() {
|
filterRelations: function filterRelations() {
|
||||||
|
|
|
@ -3,7 +3,26 @@ const nql = require('@tryghost/nql');
|
||||||
const debug = require('@tryghost/debug')('services:url:generator');
|
const debug = require('@tryghost/debug')('services:url:generator');
|
||||||
const localUtils = require('../../../shared/url-utils');
|
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.
|
* The UrlGenerator class is responsible to generate urls based on a router's conditions.
|
||||||
|
@ -38,7 +57,7 @@ class UrlGenerator {
|
||||||
if (filter) {
|
if (filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
this.nql = nql(this.filter, {
|
this.nql = nql(this.filter, {
|
||||||
expansions: postExpansions,
|
expansions: EXPANSIONS,
|
||||||
transformer: nql.utils.mapKeyValues({
|
transformer: nql.utils.mapKeyValues({
|
||||||
key: {
|
key: {
|
||||||
from: 'page',
|
from: 'page',
|
||||||
|
|
|
@ -136,7 +136,6 @@
|
||||||
"@tryghost/mw-vhost": "0.0.0",
|
"@tryghost/mw-vhost": "0.0.0",
|
||||||
"@tryghost/nodemailer": "0.3.35",
|
"@tryghost/nodemailer": "0.3.35",
|
||||||
"@tryghost/nql": "0.11.0",
|
"@tryghost/nql": "0.11.0",
|
||||||
"@tryghost/nql-filter-expansions": "0.0.0",
|
|
||||||
"@tryghost/oembed-service": "0.0.0",
|
"@tryghost/oembed-service": "0.0.0",
|
||||||
"@tryghost/package-json": "0.0.0",
|
"@tryghost/package-json": "0.0.0",
|
||||||
"@tryghost/post-revisions": "0.0.0",
|
"@tryghost/post-revisions": "0.0.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue