mirror of
https://github.com/flarum/core.git
synced 2025-08-09 18:07:02 +02:00
feat: revamp search (#3893)
* refactor: move gambits to frontend (#3885) * refactor: move gambits to frontend * test: GambitManager * refactor: merge filterer and searcher concepts (#3892) * chore: drop remaining backend regex gambits * refactor: merge filterer & searcher concept * refactor: adapt extenders * refactor: no longer need to push gambits to `q` * refactor: filters to gambits * refactor: drop shred `Query` namespace * chore: cleanup * chore: leftover gambit references on the backend (#3894) * chore: leftover gambit references on the backend * chore: namespace * feat: search driver backend extension API (#3902) * feat: first iteration of search drivers * feat: indexer API & tweaks * feat: changes after POC driver * fix: properly fire custom observables * chore: remove debugging code * fix: phpstan * fix: custom eloquent events * chore: drop POC usage * test: indexer extender API * fix: extension searcher fails without filters * fix: phpstan * fix: frontend created gambit * feat: advanced page and localized driver settings (#3905) * feat: allow getting total search results and replacing filters (#3906) * feat: allow accessing total search results * feat: allow replacing filters * chore: phpstan
This commit is contained in:
1
extensions/subscriptions/js/admin.ts
Normal file
1
extensions/subscriptions/js/admin.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from './src/admin';
|
1
extensions/subscriptions/js/src/admin/extend.ts
Normal file
1
extensions/subscriptions/js/src/admin/extend.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as default } from '../common/extend';
|
1
extensions/subscriptions/js/src/admin/index.ts
Normal file
1
extensions/subscriptions/js/src/admin/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default as extend } from './extend';
|
7
extensions/subscriptions/js/src/common/extend.ts
Normal file
7
extensions/subscriptions/js/src/common/extend.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import Extend from 'flarum/common/extenders';
|
||||
import SubscriptionGambit from './query/discussions/SubscriptionGambit';
|
||||
|
||||
export default [
|
||||
new Extend.Search() //
|
||||
.gambit('discussions', SubscriptionGambit),
|
||||
];
|
@@ -0,0 +1,23 @@
|
||||
import IGambit from 'flarum/common/query/IGambit';
|
||||
|
||||
export default class SubscriptionGambit implements IGambit {
|
||||
pattern(): string {
|
||||
return 'is:(follow|ignor)(?:ing|ed)';
|
||||
}
|
||||
|
||||
toFilter(matches: string[], negate: boolean): Record<string, any> {
|
||||
const type = matches[1] === 'follow' ? 'following' : 'ignoring';
|
||||
|
||||
return {
|
||||
subscription: type,
|
||||
};
|
||||
}
|
||||
|
||||
filterKey(): string {
|
||||
return 'subscription';
|
||||
}
|
||||
|
||||
fromFilter(value: string, negate: boolean): string {
|
||||
return `${negate ? '-' : ''}is:${value}`;
|
||||
}
|
||||
}
|
@@ -36,12 +36,7 @@ export default function addSubscriptionFilter() {
|
||||
extend(DiscussionListState.prototype, 'requestParams', function (params) {
|
||||
if (this.params.onFollowing) {
|
||||
params.filter ||= {};
|
||||
|
||||
if (params.filter.q) {
|
||||
params.filter.q += ' is:following';
|
||||
} else {
|
||||
params.filter.subscription = 'following';
|
||||
}
|
||||
params.filter.subscription = 'following';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -2,7 +2,11 @@ import Extend from 'flarum/common/extenders';
|
||||
import IndexPage from 'flarum/forum/components/IndexPage';
|
||||
import Discussion from 'flarum/common/models/Discussion';
|
||||
|
||||
import commonExtend from '../common/extend';
|
||||
|
||||
export default [
|
||||
...commonExtend,
|
||||
|
||||
new Extend.Routes() //
|
||||
.add('following', '/following', IndexPage),
|
||||
|
||||
|
Reference in New Issue
Block a user