Search keywords (#677)

#555 search by keywords
This commit is contained in:
Neil 2023-06-23 20:22:58 +08:00 committed by GitHub
parent 1baa7c9ef3
commit b60a8b20d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 20 deletions

View file

@ -1,6 +1,6 @@
{
"name": "tea",
"version": "0.2.28",
"version": "0.2.29",
"private": true,
"description": "tea gui app",
"author": "tea.xyz",

View file

@ -112,7 +112,7 @@
{#if pkg.maintainer}
<span>{pkg.maintainer}</span>
{/if}
<p class="mt-4 text-sm">{pkg.desc}</p>
<p class="mt-4 text-sm">{pkg.description}</p>
<menu class="mt-4 flex h-10 gap-4 text-xs">
<div class="w-fit min-w-[160px]">
<PackageVersionSelector

View file

@ -57,7 +57,9 @@
<i class="icon-check-circle-o mb-1 ml-2 flex text-2xl text-[#00ffd0]" />
{/if}
</div>
<p class="h-[32px] text-xs font-thin lowercase line-clamp-2">{pkg.desc ?? ""}</p>
<p class="h-[32px] text-xs font-thin lowercase line-clamp-2">
{pkg.short_description ?? ""}
</p>
{:else}
<div class="mb-4 flex items-center">
<h3 class="text-bold font-mona text-3xl font-bold text-white line-clamp-1">
@ -68,7 +70,7 @@
{/if}
</div>
<p class="line-clamp-[8] h-[160px] text-[14px] font-thin lowercase leading-[20px]">
{pkg.desc ?? ""}
{pkg.short_description ?? ""}
</p>
{/if}
</article>

View file

@ -29,7 +29,7 @@
/>
<header data-testid="card-result-{pkg.slug}" class="flex-grow" on:click={() => gotoPackagePage()}>
<h1>{pkg.full_name}</h1>
<p class="text-xs line-clamp-2">{pkg.desc}</p>
<p class="text-xs line-clamp-2">{pkg.short_description}</p>
</header>
<aside>
<div>

View file

@ -14,7 +14,7 @@
onMount(async () => {
if (!packages.length) {
const matches = await packagesStore.search(pkg.desc, 4);
const matches = await packagesStore.search(pkg.short_description, 4);
packages = matches.filter((mp) => mp.full_name !== pkg.full_name).slice(0, 3);
}
});

View file

@ -5,7 +5,7 @@
* TODO:
* * make cors work with app.tea.xyz/v1
*/
import type { Package, Review, AirtablePost, Bottle } from "@tea/ui/types";
import type { Package, Review, AirtablePost } from "@tea/ui/types";
import type { GUIPackage, Session, Packages, AutoUpdateStatus } from "./types";
import { PackageStates } from "./types";
import { loremIpsum } from "lorem-ipsum";
@ -21,7 +21,9 @@ const packages: Package[] = [
full_name: "mesonbuild.com",
dl_count: 270745,
maintainer: "",
desc: "Fast and user friendly build system",
description: "Fast and user-friendly build system",
short_description: "Fast and user-friendly",
keywords: [],
installs: 0,
categories: ["foundation_essentials"],
created: "2022-10-06T15:45:08.000Z",
@ -32,13 +34,15 @@ const packages: Package[] = [
{
slug: "pixman_org",
homepage: "http://www.pixman.org/",
maintainer: "freedesktop",
name: "pixman.org",
version: "0.40.0",
last_modified: "2022-09-26T19:37:47.000Z",
full_name: "pixman.org",
dl_count: 0,
desc: "Pixman is a library that provides low-level pixel manipulation features such as image compositing and trapezoid rasterization.",
maintainer: "freedesktop",
description: "Pixman is a library for pixel manipulation, compositing, and rasterization",
short_description: "Pixel manipulation library",
keywords: [],
installs: 0,
categories: ["foundation_essentials"],
created: "2022-09-26T19:37:47.000Z",
@ -55,7 +59,9 @@ const packages: Package[] = [
last_modified: "2022-10-20T01:32:15.000Z",
full_name: "freedesktop.org/pkg-config",
dl_count: 2661501,
desc: "Manage compile and link flags for libraries",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["foundation_essentials"],
created: "2022-10-20T01:32:15.000Z",
@ -72,7 +78,9 @@ const packages: Package[] = [
last_modified: "2022-10-20T01:23:46.000Z",
full_name: "gnu.org/gettext",
dl_count: 3715970,
desc: "GNU internationalization (i18n) and localization (l10n) library",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["foundation_essentials"],
created: "2022-10-20T01:23:46.000Z",
@ -89,7 +97,9 @@ const packages: Package[] = [
full_name: "ipfs.tech",
dl_count: 14457,
maintainer: "",
desc: "Peer-to-peer hypermedia protocol",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["foundation_essentials"],
created: "2022-10-19T21:36:52.000Z",
@ -106,7 +116,9 @@ const packages: Package[] = [
last_modified: "2022-09-27T04:50:44.000Z",
full_name: "nixos.org/patchelf",
dl_count: 0,
desc: "PatchELF is a simple utility for modifying existing ELF executables and libraries.",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["top_packages", "foundation_essentials"],
created: "2022-09-27T04:50:44.000Z",
@ -123,7 +135,9 @@ const packages: Package[] = [
last_modified: "2022-10-19T19:13:51.000Z",
full_name: "tea.xyz",
dl_count: 0,
desc: "Website of tea.xyz",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["top_packages", "foundation_essentials"],
created: "2022-10-19T19:13:51.000Z",
@ -140,7 +154,9 @@ const packages: Package[] = [
last_modified: "2022-10-21T02:15:16.000Z",
full_name: "charm.sh/gum",
dl_count: 0,
desc: "",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["top_packages", "foundation_essentials"],
created: "2022-10-21T02:15:16.000Z",
@ -157,7 +173,9 @@ const packages: Package[] = [
full_name: "pyyaml.org",
dl_count: 107505,
maintainer: "",
desc: "YAML framework for Python",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["top_packages", "foundation_essentials"],
created: "2022-10-03T15:35:14.000Z",
@ -174,7 +192,9 @@ const packages: Package[] = [
last_modified: "2022-10-19T16:47:44.000Z",
full_name: "tea.xyz/gx/cc",
dl_count: 0,
desc: "",
description: "Manage compile and link flags for libraries",
short_description: "Manage compile and link flags for libraries",
keywords: [],
installs: 0,
categories: ["top_packages", "foundation_essentials"],
created: "2022-10-19T16:47:44.000Z",

View file

@ -6,8 +6,30 @@ let packagesIndex: Fuse<GUIPackage>;
export function indexPackages(packages: GUIPackage[]) {
try {
console.log("gui packages", packages);
packagesIndex = new Fuse(packages, {
keys: ["name", "full_name", "desc", "categories"],
keys: [
{
name: "name",
weight: 0.5
},
{
name: "full_name",
weight: 0.5
},
{
name: "description",
weight: 0.3
},
{
name: "categories",
weight: 0.2
},
{
name: "keywords",
weight: 0.5
}
],
minMatchCharLength: 3,
threshold: 0.3
});

View file

@ -15,7 +15,6 @@ export interface Package {
homepage: string;
last_modified: Date | string;
created: Date | string;
desc: string;
dl_count: number;
installs: number;
reviews?: Review[];
@ -36,6 +35,9 @@ export interface Package {
manual_sorting: number;
card_layout: "bottom" | "right" | "left";
image_added_at: Date | null;
keywords: string[];
description: string;
short_description: string;
}
export type AirtablePost = {