add more packages filters
This commit is contained in:
parent
d4801653ca
commit
6935ad35bc
|
@ -17,10 +17,14 @@
|
||||||
<option value="rolling">rolling</option>
|
<option value="rolling">rolling</option>
|
||||||
<option value="stable">stable</option>
|
<option value="stable">stable</option>
|
||||||
</select>
|
</select>
|
||||||
<div id="sort-by"></div>
|
<!-- <div id="sort-by"></div> -->
|
||||||
<div id="packages_filter" class="filter">
|
<div id="packages_filter" class="filter">
|
||||||
<h2>Platform</h2>
|
<h2>Platform</h2>
|
||||||
<div id="platform"></div>
|
<div id="platform"></div>
|
||||||
|
<h2>Licenses</h2>
|
||||||
|
<div id="licenses"></div>
|
||||||
|
<h2>Maintainers</h2>
|
||||||
|
<div id="maintainers"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="modules_filter" class="filter">
|
<div id="modules_filter" class="filter">
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,8 +34,8 @@
|
||||||
<div id="hits"></div>
|
<div id="hits"></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
<script
|
<script src="./instant-meilisearch.umd.min.js"></script>
|
||||||
src="https://cdn.jsdelivr.net/npm/@meilisearch/instant-meilisearch/dist/instant-meilisearch.umd.min.js"></script>
|
<!-- fixme: https://github.com/algolia/instantsearch/issues/6301 -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4"></script>
|
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4"></script>
|
||||||
<script>
|
<script>
|
||||||
function kind() {
|
function kind() {
|
||||||
|
@ -72,33 +76,54 @@
|
||||||
instantsearch.widgets.refinementList({
|
instantsearch.widgets.refinementList({
|
||||||
container: "#platform",
|
container: "#platform",
|
||||||
attribute: "meta.platforms",
|
attribute: "meta.platforms",
|
||||||
|
// hack for working around a quirck with transformItems
|
||||||
|
limit: 200,
|
||||||
|
// this is a rather inperformant method of doing this
|
||||||
|
// because every time the search term changes, this function gets run
|
||||||
|
// it should be fine as long as the page performance isn't too bad
|
||||||
|
// but we might want to revisit this in the future
|
||||||
|
transformItems(items) {
|
||||||
|
function filterPlatform(platform) {
|
||||||
|
let platforms = [
|
||||||
|
"x86_64-linux",
|
||||||
|
"aarch64-linux",
|
||||||
|
"i686-linux",
|
||||||
|
"x86_64-darwin",
|
||||||
|
"aarch64-darwin",
|
||||||
|
];
|
||||||
|
return platforms.includes(platform.value)
|
||||||
|
};
|
||||||
|
return items.filter(filterPlatform)
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
instantsearch.widgets.sortBy({
|
instantsearch.widgets.refinementList({
|
||||||
container: '#sort-by',
|
container: "#licenses",
|
||||||
items: [
|
attribute: "meta.license.fullName",
|
||||||
{value: 'steam-video-games', label: 'Relevant'},
|
searchable: true
|
||||||
{
|
}),
|
||||||
value: 'steam-video-games:recommendationCount:desc',
|
instantsearch.widgets.refinementList({
|
||||||
label: 'Most Recommended',
|
container: "#maintainers",
|
||||||
},
|
attribute: "meta.maintainers.name",
|
||||||
{
|
searchable: true
|
||||||
value: 'steam-video-games:recommendationCount:asc',
|
}),
|
||||||
label: 'Least Recommended',
|
instantsearch.widgets.searchBox({
|
||||||
},
|
container: "#searchbox",
|
||||||
],
|
placeholder: "Search for packages",
|
||||||
|
autofocus: true,
|
||||||
}),
|
}),
|
||||||
instantsearch.widgets.searchBox({container: "#searchbox"}),
|
|
||||||
instantsearch.widgets.configure({hitsPerPage: 8}),
|
instantsearch.widgets.configure({hitsPerPage: 8}),
|
||||||
instantsearch.widgets.hits({
|
instantsearch.widgets.hits({
|
||||||
container: "#hits",
|
container: "#hits",
|
||||||
templates: {
|
templates: {
|
||||||
item: `
|
item(hit, {html, components}) {
|
||||||
<div>
|
return html`
|
||||||
<div class="hit-name">
|
<h2>
|
||||||
{{#helpers.highlight}}{"attribute": "name"}{{/helpers.highlight}}
|
${components.Highlight({attribute: 'name', hit})}
|
||||||
</div>
|
</h2>
|
||||||
</div>
|
<p>${hit.version}</p>
|
||||||
`}
|
`;
|
||||||
|
},
|
||||||
|
},
|
||||||
})]);
|
})]);
|
||||||
search.start();
|
search.start();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -47,7 +47,11 @@ with open(args.documentsJsonFile) as json_file:
|
||||||
|
|
||||||
if args.kind == "packages":
|
if args.kind == "packages":
|
||||||
documentResponse = client.index(indexName).add_documents(documents)
|
documentResponse = client.index(indexName).add_documents(documents)
|
||||||
indexResponse = client.index(indexName).update_filterable_attributes(['meta'])
|
indexResponse = client.index(indexName).update_filterable_attributes([
|
||||||
|
'meta',
|
||||||
|
'meta.maintainers.name',
|
||||||
|
'meta.license.fullName'
|
||||||
|
])
|
||||||
meiliTaskStatus(documentResponse.task_uid, args.verbose)
|
meiliTaskStatus(documentResponse.task_uid, args.verbose)
|
||||||
meiliTaskStatus(indexResponse.task_uid, args.verbose)
|
meiliTaskStatus(indexResponse.task_uid, args.verbose)
|
||||||
elif args.kind == "options":
|
elif args.kind == "options":
|
||||||
|
|
Loading…
Reference in a new issue