Compare commits
2 commits
62217c30f6
...
6935ad35bc
Author | SHA1 | Date | |
---|---|---|---|
6935ad35bc | |||
d4801653ca |
3 changed files with 137 additions and 29 deletions
|
@ -1,10 +1,89 @@
|
||||||
{ lib
|
{ stdenv
|
||||||
, stdenv
|
, fetchFromGitHub
|
||||||
}: stdenv.mkDerivation {
|
, fetchYarnDeps
|
||||||
|
, fixup-yarn-lock
|
||||||
|
, nodejs
|
||||||
|
, yarn
|
||||||
|
}: let
|
||||||
|
buildJS = { pname, version, src, yarnHash, packagePath, buildCmd ? "build" }: stdenv.mkDerivation {
|
||||||
|
inherit pname version src;
|
||||||
|
|
||||||
|
offlineCache = fetchYarnDeps {
|
||||||
|
yarnLock = "${src}/yarn.lock";
|
||||||
|
hash = yarnHash;
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [ fixup-yarn-lock nodejs yarn ];
|
||||||
|
|
||||||
|
configurePhase = ''
|
||||||
|
runHook preConfigure
|
||||||
|
|
||||||
|
export HOME=$NIX_BUILD_TOP/fake_home
|
||||||
|
yarn config --offline set yarn-offline-mirror $offlineCache
|
||||||
|
fixup-yarn-lock yarn.lock
|
||||||
|
yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
|
||||||
|
patchShebangs node_modules/
|
||||||
|
patchShebangs packages/${packagePath}/node_modules/
|
||||||
|
|
||||||
|
runHook postConfigure
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
pushd packages/${packagePath}
|
||||||
|
yarn --offline ${buildCmd}
|
||||||
|
popd
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mv packages/${packagePath}/dist $out
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
algoliaInstantsearchJS = buildJS rec {
|
||||||
|
pname = "instantsearch";
|
||||||
|
version = "4.73.2";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "algolia";
|
||||||
|
repo = "instantsearch";
|
||||||
|
rev = "instantsearch.js@${version}";
|
||||||
|
hash = "sha256-Wu4q8PPbHlb77hSYIFnRg4FemRPjqEw4p7fSBc3gzQQ=";
|
||||||
|
};
|
||||||
|
yarnHash = "sha256-B1OP8Q+QMu6EkdeVkxiTpQY2halZmE8GhsbEJp1q4TQ=";
|
||||||
|
packagePath = "instantsearch.js";
|
||||||
|
buildCmd = "build:umd";
|
||||||
|
};
|
||||||
|
meilisearchInstant = buildJS rec {
|
||||||
|
pname = "meilisearch-js-plugins";
|
||||||
|
version = "0.19.1";
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "meilisearch";
|
||||||
|
repo = "meilisearch-js-plugins";
|
||||||
|
rev = "@meilisearch/instant-meilisearch@${version}";
|
||||||
|
hash = "sha256-KJOj9ZMtN4bwEy+0PKuziq+1gqMp9volNACn1XTA7AA=";
|
||||||
|
};
|
||||||
|
yarnHash = "sha256-zODub/XZzIoxwUHQhp+6S2vIg7P9K/rw9ZT02teM0fw=";
|
||||||
|
packagePath = "instant-meilisearch";
|
||||||
|
};
|
||||||
|
in stdenv.mkDerivation {
|
||||||
pname = "frontend";
|
pname = "frontend";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
# todo
|
installPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
|
||||||
|
cp $src/index.html $out/
|
||||||
|
cp -r ${algoliaInstantsearchJS}/instantsearch.production.min.js.map $out/
|
||||||
|
cp -r ${algoliaInstantsearchJS}/instantsearch.production.min.js $out/
|
||||||
|
cp -r ${meilisearchInstant}/instant-meilisearch.umd.min.js.map $out/
|
||||||
|
cp -r ${meilisearchInstant}/instant-meilisearch.umd.min.js $out/
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -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