-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2568fda
Showing
61 changed files
with
3,133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
.yarn/install-state.gz | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
.dev.vars | ||
|
||
|
||
# vercel | ||
.vercel | ||
|
||
#wrangler | ||
.wrangler | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Quill Zhou | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## Looq | ||
A SearxNG frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json", | ||
"organizeImports": { | ||
"enabled": true | ||
}, | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true, | ||
"suspicious": { | ||
"noExplicitAny": "off", | ||
"noArrayIndexKey": "off" | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://ui.shadcn.com/schema.json", | ||
"style": "default", | ||
"rsc": false, | ||
"tsx": true, | ||
"tailwind": { | ||
"config": "tailwind.config.js", | ||
"css": "src/styles/globals.less", | ||
"baseColor": "slate", | ||
"cssVariables": true, | ||
"prefix": "" | ||
}, | ||
"aliases": { | ||
"components": "src/components", | ||
"utils": "src/lib/utils" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import { zValidator } from "@hono/zod-validator"; | ||
import { Hono } from "hono"; | ||
import { env } from "hono/adapter"; | ||
import { handle } from "hono/cloudflare-pages"; | ||
import { z } from "zod"; | ||
|
||
const searchSchema = z.object({ | ||
q: z.string(), | ||
language: z.string().optional().default("en-US"), | ||
time_range: z.string().optional(), | ||
safesearch: z.string().optional().default("0"), | ||
categories: z.string().optional().default("general"), | ||
}); | ||
|
||
const autocompleteSchema = z.object({ | ||
q: z.string(), | ||
}); | ||
|
||
const searchResultSchema = z.object({ | ||
url: z.string(), | ||
title: z.string(), | ||
content: z.string().optional(), | ||
engine: z.string(), | ||
engines: z.array(z.string()), | ||
positions: z.array(z.number()), | ||
score: z.number(), | ||
category: z.string(), | ||
}); | ||
|
||
const searchDataResponseSchema = z.object({ | ||
query: z.string(), | ||
number_of_results: z.number(), | ||
results: z.array(searchResultSchema), | ||
infoboxes: z | ||
.array( | ||
z.object({ | ||
infobox: z.string(), | ||
content: z.string().optional(), | ||
urls: z.array( | ||
z.object({ | ||
title: z.string(), | ||
url: z.string(), | ||
}), | ||
), | ||
}), | ||
) | ||
.optional(), | ||
suggestions: z.array(z.string()).optional(), | ||
}); | ||
|
||
const autoCompleteResponseSchema = z.tuple([z.string(), z.array(z.string())]); | ||
|
||
const fetchSearchResults = async ({ | ||
query, | ||
baseUrl, | ||
}: { query: z.infer<typeof searchSchema>; baseUrl: string }) => { | ||
const searchParams = new URLSearchParams( | ||
query as { [key: string]: string }, | ||
).toString(); | ||
const searchUrl = `${baseUrl}/search?${searchParams}&format=json`; | ||
|
||
const response = await fetch(searchUrl, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
const data = await response.json(); | ||
const searchDataResponse = searchDataResponseSchema.parse(data); | ||
return searchDataResponse; | ||
}; | ||
|
||
const fetchAutocompleteResults = async ({ | ||
query, | ||
baseUrl, | ||
}: { query: z.infer<typeof autocompleteSchema>; baseUrl: string }) => { | ||
const searchParams = new URLSearchParams(query).toString(); | ||
const searchUrl = `${baseUrl}/autocompleter?${searchParams}`; | ||
|
||
const response = await fetch(searchUrl, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
const data = await response.json(); | ||
const autoCompleteResponse = autoCompleteResponseSchema.parse(data); | ||
return autoCompleteResponse; | ||
}; | ||
|
||
const app = new Hono() | ||
.basePath("/api") | ||
.get("/search", zValidator("query", searchSchema), async (c) => { | ||
const query = c.req.valid("query"); | ||
const { SEARXNG_URL } = env<Record<string, string>>(c); | ||
try { | ||
const data = await fetchSearchResults({ query, baseUrl: SEARXNG_URL }); | ||
return c.json(data); | ||
} catch (e: any) { | ||
console.error(e); | ||
return c.json({ error: e.message }, 500); | ||
} | ||
}) | ||
.get("/autocompleter", zValidator("query", autocompleteSchema), async (c) => { | ||
const query = c.req.valid("query"); | ||
const { SEARXNG_URL } = env<Record<string, string>>(c); | ||
try { | ||
const data = await fetchAutocompleteResults({ | ||
query, | ||
baseUrl: SEARXNG_URL, | ||
}); | ||
return c.json(data); | ||
} catch (e: any) { | ||
console.error(e); | ||
return c.json({ error: e.message }, 500); | ||
} | ||
}); | ||
|
||
type AppType = typeof app; | ||
|
||
export const onRequest = handle(app); | ||
|
||
export type { AppType }; | ||
|
||
export { | ||
searchSchema, | ||
autocompleteSchema, | ||
searchResultSchema, | ||
searchDataResponseSchema, | ||
autoCompleteResponseSchema, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html class="dark"> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8"> | ||
<meta charset="UTF-8"> | ||
<link rel="icon" href="/favicon.ico" type="image/x-icon"> | ||
<meta property="og:image" content="/og-image.jpeg" /> | ||
<meta property="og:title" content="Looq"> | ||
<meta property="og:site_name" content="Looq"> | ||
<meta property="og:description" content="Search"> | ||
|
||
<meta name="twitter:card" content="summary_large_image"> | ||
<meta name="twitter:image:alt" content="Looq"> | ||
<meta name="twitter:title" content="Looq"> | ||
<meta name="twitter:description" content="Search"> | ||
<meta name="twitter:image:src" content="/og-image.jpeg"> | ||
|
||
<meta name="description" content="Looq"> | ||
<meta name="keywords" content="vite,react,typescript,tailwindcss,template,starter,boilerplate"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<title></title> | ||
</head> | ||
<body class="bg-background text-foreground"> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"name": "looq", | ||
"private": true, | ||
"version": "0.0.0", | ||
"scripts": { | ||
"prepare": "husky install", | ||
"dev": "wrangler pages dev --local -- bun vite --proxy 5000", | ||
"dev:wrangler": "wrangler pages dev --local", | ||
"dev:vite": "vite", | ||
"start:wrangler": "wrangler pages dev", | ||
"start:vite": "vite preview --port 5000", | ||
"build": "npm run typecheck && vite build", | ||
"typecheck": "tsc --noEmit", | ||
"typecheck:watch": "tsc --noEmit --watch", | ||
"lint": "biome check", | ||
"i18next-resources-for-ts": "i18next-resources-for-ts toc -i ./src/i18n/locales/en -o ./src/types/resources.ts", | ||
"translate": "transmart" | ||
}, | ||
"dependencies": { | ||
"@hono/zod-validator": "^0.2.2", | ||
"@hookform/resolvers": "^3.9.0", | ||
"@loadable/component": "^5.16.4", | ||
"@radix-ui/react-accordion": "^1.2.0", | ||
"@radix-ui/react-alert-dialog": "^1.1.1", | ||
"@radix-ui/react-avatar": "^1.1.0", | ||
"@radix-ui/react-checkbox": "^1.1.1", | ||
"@radix-ui/react-collapsible": "^1.1.0", | ||
"@radix-ui/react-dialog": "^1.1.1", | ||
"@radix-ui/react-label": "^2.1.0", | ||
"@radix-ui/react-navigation-menu": "^1.2.0", | ||
"@radix-ui/react-popover": "^1.1.1", | ||
"@radix-ui/react-select": "^2.1.1", | ||
"@radix-ui/react-separator": "^1.1.0", | ||
"@radix-ui/react-slot": "^1.1.0", | ||
"@radix-ui/react-toggle": "^1.1.0", | ||
"@radix-ui/react-tooltip": "^1.1.2", | ||
"@tanstack/react-query": "^5.55.0", | ||
"@transmart/cli": "^0.5.1", | ||
"class-variance-authority": "^0.7.0", | ||
"clsx": "^2.1.1", | ||
"cmdk": "1.0.0", | ||
"i18next": "^23.14.0", | ||
"i18next-browser-languagedetector": "^8.0.0", | ||
"i18next-resources-to-backend": "^1.2.1", | ||
"lucide-react": "^0.439.0", | ||
"next-themes": "^0.3.0", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"react-helmet": "^6.1.0", | ||
"react-hook-form": "^7.53.0", | ||
"react-i18next": "^15.0.1", | ||
"react-router-dom": "^6.26.1", | ||
"sonner": "^1.5.0", | ||
"tailwind-merge": "^2.5.2", | ||
"tailwindcss-animate": "^1.0.7", | ||
"wrangler": "^3.75.0", | ||
"zod": "^3.23.8" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.8.3", | ||
"@commitlint/cli": "^19.4.1", | ||
"@commitlint/config-conventional": "^19.4.1", | ||
"@tanstack/react-query-devtools": "^5.55.0", | ||
"@types/loadable__component": "^5.13.9", | ||
"@types/react": "^18.3.5", | ||
"@types/react-dom": "^18.3.0", | ||
"@types/react-helmet": "^6.1.11", | ||
"@typescript-eslint/eslint-plugin": "^8.4.0", | ||
"@typescript-eslint/parser": "^8.4.0", | ||
"@vitejs/plugin-react": "^4.3.1", | ||
"autoprefixer": "^10.4.20", | ||
"eslint": "^9.9.1", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-import-resolver-typescript": "^3.6.3", | ||
"eslint-plugin-import": "^2.30.0", | ||
"eslint-plugin-prettier": "^5.2.1", | ||
"eslint-plugin-react": "^7.35.2", | ||
"eslint-plugin-react-hooks": "^4.6.2", | ||
"eslint-plugin-unused-imports": "^4.1.3", | ||
"husky": "^9.1.5", | ||
"i18next-resources-for-ts": "1.5.0", | ||
"less": "^4.2.0", | ||
"lint-staged": "^15.2.10", | ||
"postcss": "^8.4.45", | ||
"postcss-less": "^6.0.0", | ||
"prettier": "^3.3.3", | ||
"prettier-plugin-tailwindcss": "^0.6.6", | ||
"stylelint": "^16.9.0", | ||
"stylelint-config-standard": "^36.0.1", | ||
"stylelint-less": "^3.0.1", | ||
"stylelint-prettier": "5", | ||
"tailwindcss": "^3.4.10", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.5.4", | ||
"vite": "^5.4.3", | ||
"vite-plugin-external": "^4.3.1", | ||
"vite-plugin-svgr": "^4.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module.exports = { | ||
plugins: { | ||
autoprefixer: { | ||
overrideBrowserslist: [ | ||
"Android 4.1", | ||
"iOS 7.1", | ||
"Chrome > 31", | ||
"ff > 31", | ||
"ie >= 8", | ||
"last 10 versions", | ||
], | ||
grid: true, | ||
}, | ||
tailwindcss: {}, | ||
}, | ||
}; |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; | ||
import React, { useMemo } from "react"; | ||
import { RouterProvider } from "react-router-dom"; | ||
import { createRouter } from "./router"; | ||
|
||
export default function App() { | ||
const queryClient = useMemo(() => new QueryClient({}), []); | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<RouterProvider router={createRouter()} /> | ||
<ReactQueryDevtools /> | ||
</QueryClientProvider> | ||
); | ||
} |
Oops, something went wrong.