From 9dc03ce5b5ad7ce259250d965cc985760802f060 Mon Sep 17 00:00:00 2001 From: Florian Maas Date: Sat, 22 Jun 2024 12:25:40 +0200 Subject: [PATCH] add github and kofi badges, add rate limiter --- frontend/app/components/GitHubButton.tsx | 25 +++ .../app/components/SearchResultsTable.tsx | 10 +- frontend/app/components/SupportButton.tsx | 23 +++ frontend/app/page.tsx | 21 ++- frontend/app/utils/search.ts | 11 +- frontend/public/kofi.png | Bin 0 -> 35716 bytes poetry.lock | 144 +++++++++++++++++- pypi_scout/api/main.py | 32 +++- pypi_scout/config.py | 4 +- pypi_scout/vector_database/interface.py | 1 + pyproject.toml | 1 + 11 files changed, 251 insertions(+), 21 deletions(-) create mode 100644 frontend/app/components/GitHubButton.tsx create mode 100644 frontend/app/components/SupportButton.tsx create mode 100644 frontend/public/kofi.png diff --git a/frontend/app/components/GitHubButton.tsx b/frontend/app/components/GitHubButton.tsx new file mode 100644 index 0000000..8104cc5 --- /dev/null +++ b/frontend/app/components/GitHubButton.tsx @@ -0,0 +1,25 @@ +import React from "react"; + +const GitHubButton: React.FC = () => { + return ( + + + + + GitHub + + ); +}; + +export default GitHubButton; diff --git a/frontend/app/components/SearchResultsTable.tsx b/frontend/app/components/SearchResultsTable.tsx index 4e866c3..befefa5 100644 --- a/frontend/app/components/SearchResultsTable.tsx +++ b/frontend/app/components/SearchResultsTable.tsx @@ -25,6 +25,12 @@ const SearchResultsTable: React.FC = ({ return sortField === field ? (sortDirection === "asc" ? "▲" : "▼") : ""; }; + const truncateText = (text: string, maxLength: number) => { + return text.length > maxLength + ? `${text.substring(0, maxLength)}...` + : text; + }; + return (
@@ -70,7 +76,7 @@ const SearchResultsTable: React.FC = ({ {results.map((result, index) => ( -
- {result.name} + {truncateText(result.name, 20)} {result.similarity.toFixed(3)} @@ -78,7 +84,7 @@ const SearchResultsTable: React.FC = ({ {result.weekly_downloads.toLocaleString()} + {result.summary} diff --git a/frontend/app/components/SupportButton.tsx b/frontend/app/components/SupportButton.tsx new file mode 100644 index 0000000..a55a2fb --- /dev/null +++ b/frontend/app/components/SupportButton.tsx @@ -0,0 +1,23 @@ +import React from "react"; + +const SupportButton: React.FC = () => { + return ( + + Ko-fi logo + Support + + ); +}; + +export default SupportButton; diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index f9b603f..b539365 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -5,6 +5,8 @@ import { handleSearch, sortResults } from "./utils/search"; import SearchResultsTable from "./components/SearchResultsTable"; import InfoBox from "./components/InfoBox"; import { ClipLoader } from "react-spinners"; +import GitHubButton from "./components/GitHubButton"; +import SupportButton from "./components/SupportButton"; interface Match { name: string; @@ -31,20 +33,29 @@ export default function Home() { }; return ( -
-
+
+
+
+ + +
+
+ +
pypi-scout logo

Enter your query to search for Python packages

-
+ +