Skip to content

Commit 9a3485b

Browse files
committed
Add an all_keywords parameter to the search route
Pass along any specified value for the all_keywords parameter to the API request to search crates. This lets us manually construct URLs in the browser like: - /search?all_keywords=foo+bar - /search?all_keywords=foo+bar&q=test but there is no form field in the search form as yet; eventually, we'll need an "advanced search" form or similar.
1 parent 547339a commit 9a3485b

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

app/controllers/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default Controller.extend(EKMixin, {
2828
queryParams: {
2929
q: this.searchQuery,
3030
page: 1,
31+
all_keywords: null,
3132
},
3233
});
3334
},

app/controllers/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import PaginationMixin from '../mixins/pagination';
99

1010
export default Controller.extend(PaginationMixin, {
1111
search: service(),
12-
queryParams: ['q', 'page', 'per_page', 'sort'],
12+
queryParams: ['all_keywords', 'page', 'per_page', 'q', 'sort'],
1313
q: alias('search.q'),
1414
page: '1',
1515
per_page: 10,

app/routes/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import Route from '@ember/routing/route';
22

33
export default Route.extend({
44
queryParams: {
5-
q: { refreshModel: true },
5+
all_keywords: { refreshModel: true },
66
page: { refreshModel: true },
7+
q: { refreshModel: true },
78
sort: { refreshModel: true },
89
},
910

src/controllers/krate/search.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ pub fn search(req: &mut dyn Request) -> CargoResult<Response> {
9999
use diesel::sql_types::Array;
100100
sql_function!(#[aggregate] fn array_agg<T>(x: T) -> Array<T>);
101101

102-
let names: Vec<_> = kws.split_whitespace().map(|name| name.to_lowercase()).collect();
102+
let names: Vec<_> = kws
103+
.split_whitespace()
104+
.map(|name| name.to_lowercase())
105+
.collect();
103106

104107
query = query.filter(
105108
// FIXME: Just use `.contains` in Diesel 2.0

0 commit comments

Comments
 (0)