From 8007597b505064225eb08d7ce7569753d2da58af Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 17 Oct 2025 14:22:16 +0200 Subject: [PATCH 1/7] add 'useGithubStarts' hook --- .../connectors/add/baidu-search-api/page.tsx | 16 ++++---- .../[search_space_id]/connectors/add/page.tsx | 2 +- .../components/chat/SourceDetailSheet.tsx | 6 +-- surfsense_web/hooks/use-github-starts.ts | 37 +++++++++++++++++++ 4 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 surfsense_web/hooks/use-github-starts.ts diff --git a/surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx index 1eaee9676..6624b8214 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/connectors/add/baidu-search-api/page.tsx @@ -153,8 +153,8 @@ export default function BaiduSearchApiPage() { Connect Baidu Search - Integrate with Baidu AI Search to enhance your search capabilities with - intelligent Chinese web search results. + Integrate with Baidu AI Search to enhance your search capabilities with intelligent + Chinese web search results. @@ -224,13 +224,9 @@ export default function BaiduSearchApiPage() { ERNIE 3.5 8K ERNIE 4.5 Turbo 32K - - ERNIE 4.5 Turbo 128K - + ERNIE 4.5 Turbo 128K DeepSeek V3 - - Qwen3 235B - + Qwen3 235B @@ -255,7 +251,9 @@ export default function BaiduSearchApiPage() { Baidu Search V1 - Baidu Search V2 (Recommended) + + Baidu Search V2 (Recommended) + diff --git a/surfsense_web/app/dashboard/[search_space_id]/connectors/add/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/connectors/add/page.tsx index ccf02f107..7e63f5815 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/connectors/add/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/connectors/add/page.tsx @@ -65,7 +65,7 @@ const connectorCategories: ConnectorCategory[] = [ description: "Connect to Elasticsearch to index and search documents, logs and metrics.", icon: getConnectorIcon(EnumConnectorName.ELASTICSEARCH_CONNECTOR, "h-6 w-6"), status: "available", - }, + }, { id: "baidu-search-api", title: "Baidu Search", diff --git a/surfsense_web/components/chat/SourceDetailSheet.tsx b/surfsense_web/components/chat/SourceDetailSheet.tsx index ecc8db4d2..e28e35070 100644 --- a/surfsense_web/components/chat/SourceDetailSheet.tsx +++ b/surfsense_web/components/chat/SourceDetailSheet.tsx @@ -53,9 +53,9 @@ export function SourceDetailSheet({ // Check if this is a source type that should render directly from node const isDirectRenderSource = - sourceType === "TAVILY_API" || - sourceType === "LINKUP_API" || - sourceType === "SEARXNG_API" || + sourceType === "TAVILY_API" || + sourceType === "LINKUP_API" || + sourceType === "SEARXNG_API" || sourceType === "BAIDU_SEARCH_API"; useEffect(() => { diff --git a/surfsense_web/hooks/use-github-starts.ts b/surfsense_web/hooks/use-github-starts.ts new file mode 100644 index 000000000..8f343796d --- /dev/null +++ b/surfsense_web/hooks/use-github-starts.ts @@ -0,0 +1,37 @@ +import { useCallback, useEffect, useState } from "react"; +import { apiClient } from "@/lib/api"; + +export const useGithubStarts = () => { + const repo = process.env.NEXT_PUBLIC_GITHUB_REPO; + const owner = process.env.NEXT_PUBLIC_GITHUB_OWNER; + const token = process.env.NEXT_PUBLIC_GITHUB_TOKEN; + + const [starts, setStarts] = useState(null); + + useEffect(() => { + const getStarts = async () => { + try { + if (!repo || !owner || !token) { + throw new Error("Missing GitHub credentials"); + } + const response = await apiClient.get<{ stargazers_count: number }>( + `https://api.github.com/repos/${owner}/${repo}`, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ); + + setStarts(response.stargazers_count); + } catch (err) { + console.error("Error fetching starts:", err); + throw err; + } + }; + + getStarts(); + }, []); + + return { starts }; +}; From 8f4ccba59a19d478766985c36b9ac251c12c9805 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 17 Oct 2025 14:31:10 +0200 Subject: [PATCH 2/7] add compact formatting eg : 2.3k --- surfsense_web/components/homepage/navbar.tsx | 2 + surfsense_web/hooks/use-github-starts.ts | 59 +++++++++++--------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/surfsense_web/components/homepage/navbar.tsx b/surfsense_web/components/homepage/navbar.tsx index 1be8abad7..cf921f1ae 100644 --- a/surfsense_web/components/homepage/navbar.tsx +++ b/surfsense_web/components/homepage/navbar.tsx @@ -6,6 +6,7 @@ import React, { useEffect, useState } from "react"; import { Logo } from "@/components/Logo"; import { ThemeTogglerComponent } from "@/components/theme/theme-toggle"; import { cn } from "@/lib/utils"; +import { useGithubStarts } from "@/hooks/use-github-starts"; export const Navbar = () => { const [isScrolled, setIsScrolled] = useState(false); @@ -36,6 +37,7 @@ export const Navbar = () => { const DesktopNav = ({ navItems, isScrolled }: any) => { const [hovered, setHovered] = useState(null); + const {starts : githubStarts} = useGithubStarts(); return ( { diff --git a/surfsense_web/hooks/use-github-starts.ts b/surfsense_web/hooks/use-github-starts.ts index 8f343796d..5065ae4d0 100644 --- a/surfsense_web/hooks/use-github-starts.ts +++ b/surfsense_web/hooks/use-github-starts.ts @@ -2,36 +2,41 @@ import { useCallback, useEffect, useState } from "react"; import { apiClient } from "@/lib/api"; export const useGithubStarts = () => { - const repo = process.env.NEXT_PUBLIC_GITHUB_REPO; - const owner = process.env.NEXT_PUBLIC_GITHUB_OWNER; - const token = process.env.NEXT_PUBLIC_GITHUB_TOKEN; + const repo = process.env.NEXT_PUBLIC_GITHUB_REPO; + const owner = process.env.NEXT_PUBLIC_GITHUB_OWNER; + const token = process.env.NEXT_PUBLIC_GITHUB_TOKEN; - const [starts, setStarts] = useState(null); + const [starts, setStarts] = useState(null); - useEffect(() => { - const getStarts = async () => { - try { - if (!repo || !owner || !token) { - throw new Error("Missing GitHub credentials"); - } - const response = await apiClient.get<{ stargazers_count: number }>( - `https://api.github.com/repos/${owner}/${repo}`, - { - headers: { - Authorization: `Bearer ${token}`, - }, - } - ); + useEffect(() => { + const getStarts = async () => { + try { + if (!repo || !owner || !token) { + throw new Error("Missing GitHub credentials"); + } + const response = await apiClient.get<{ stargazers_count: number }>( + `https://api.github.com/repos/${owner}/${repo}`, + { + headers: { + Authorization: `Bearer ${token}`, + }, + } + ); - setStarts(response.stargazers_count); - } catch (err) { - console.error("Error fetching starts:", err); - throw err; - } - }; + setStarts(response.stargazers_count); + } catch (err) { + console.error("Error fetching starts:", err); + throw err; + } + }; - getStarts(); - }, []); + getStarts(); + }, []); - return { starts }; + return { + starts, + compactFormat: Intl.NumberFormat("en-US", { + notation: "compact", + }).format(starts || 0), + }; }; From 525564bd82650b73dd42c27ad8b6949bdd3bc9c3 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 17 Oct 2025 14:55:19 +0200 Subject: [PATCH 3/7] display github starts on header and hamburger menu --- surfsense_web/.env.example | 4 +- surfsense_web/components/homepage/navbar.tsx | 21 ++++-- surfsense_web/hooks/use-github-starts.ts | 68 ++++++++++---------- 3 files changed, 54 insertions(+), 39 deletions(-) diff --git a/surfsense_web/.env.example b/surfsense_web/.env.example index 157bfaa37..b6936baf3 100644 --- a/surfsense_web/.env.example +++ b/surfsense_web/.env.example @@ -2,4 +2,6 @@ NEXT_PUBLIC_FASTAPI_BACKEND_URL=http://localhost:8000 NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE=LOCAL or GOOGLE NEXT_PUBLIC_ETL_SERVICE=UNSTRUCTURED or LLAMACLOUD or DOCLING # Contact Form Vars - OPTIONAL -DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@db.sdsf.supabase.co:5432/postgres \ No newline at end of file +DATABASE_URL=postgresql://postgres:[YOUR-PASSWORD]@db.sdsf.supabase.co:5432/postgres +NEXT_PUBLIC_GITHUB_REPO=SurfSense +NEXT_PUBLIC_GITHUB_OWNER=MODSetter \ No newline at end of file diff --git a/surfsense_web/components/homepage/navbar.tsx b/surfsense_web/components/homepage/navbar.tsx index cf921f1ae..a42ea960a 100644 --- a/surfsense_web/components/homepage/navbar.tsx +++ b/surfsense_web/components/homepage/navbar.tsx @@ -37,7 +37,7 @@ export const Navbar = () => { const DesktopNav = ({ navItems, isScrolled }: any) => { const [hovered, setHovered] = useState(null); - const {starts : githubStarts} = useGithubStarts(); + const { compactFormat: githubStarts, loading: loadingGithubStarts } = useGithubStarts(); return ( { @@ -88,7 +88,13 @@ const DesktopNav = ({ navItems, isScrolled }: any) => { className="hidden rounded-full px-3 py-2 hover:bg-gray-100 dark:hover:bg-neutral-800 transition-colors md:flex items-center gap-1.5" > - 9.5k + {loadingGithubStarts ? ( +
+ ) : ( + + {githubStarts} + + )} { const MobileNav = ({ navItems, isScrolled }: any) => { const [open, setOpen] = useState(false); + const { compactFormat: githubStarts, loading: loadingGithubStarts } = useGithubStarts(); return ( <> @@ -162,9 +169,13 @@ const MobileNav = ({ navItems, isScrolled }: any) => { className="flex items-center gap-1.5 rounded-lg px-3 py-2 hover:bg-gray-100 dark:hover:bg-neutral-800 transition-colors" > - - 9.5k - + {loadingGithubStarts ? ( +
+ ) : ( + + {githubStarts} + + )}
diff --git a/surfsense_web/components/pricing.tsx b/surfsense_web/components/pricing.tsx index 55a8855cb..61c1f4f1f 100644 --- a/surfsense_web/components/pricing.tsx +++ b/surfsense_web/components/pricing.tsx @@ -76,7 +76,10 @@ export function Pricing({
-