use chemical with wisp, cleanup

This commit is contained in:
Nebelung 2024-10-13 19:14:49 +00:00
parent fcd6718d0c
commit 408fa074bb
25 changed files with 2362 additions and 5177 deletions

11
.gitpod.yml Normal file
View file

@ -0,0 +1,11 @@
# This configuration file was automatically generated by Gitpod.
# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
# and commit this file to your remote git repository to share the goodness with others.
# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
tasks:
- init: pnpm install && pnpm run build
command: pnpm run start

View file

@ -2,7 +2,6 @@
## Simple, Super & Squeaky clean. ## Simple, Super & Squeaky clean.
## https://radiusowski.site ## https://radiusowski.site
Owned by Owski and Proudparrot2. Owned by Owski and Proudparrot2.
Developed by Radius Dev team. Developed by Radius Dev team.
@ -20,4 +19,3 @@ We are getting things handled for self-hosting, for now try making an iframe to
DM The Owners! DM The Owners!
Owski9 is owski09 on discord! Owski9 is owski09 on discord!
ProudParrot2 is proudparrot2 on discord as well. ProudParrot2 is proudparrot2 on discord as well.

4801
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,11 @@
{ {
"name": "radius", "name": "radius",
"description": "Simple, Super & Squeaky clean.",
"version": "0.1.0", "version": "0.1.0",
"private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "node server.mjs",
"build": "next build", "build": "next build",
"start": "next start", "start": "NODE_ENV=production node server.mjs"
"lint": "next lint"
}, },
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.9.0", "@hookform/resolvers": "^3.9.0",
@ -20,6 +19,7 @@
"@radix-ui/react-toast": "^1.2.2", "@radix-ui/react-toast": "^1.2.2",
"@radix-ui/react-tooltip": "^1.1.3", "@radix-ui/react-tooltip": "^1.1.3",
"@tomphttp/bare-server-node": "^2.0.4", "@tomphttp/bare-server-node": "^2.0.4",
"chemicaljs": "^2.0.2",
"class-variance-authority": "^0.7.0", "class-variance-authority": "^0.7.0",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"framer-motion": "^11.11.8", "framer-motion": "^11.11.8",

1941
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

24
server.mjs Normal file
View file

@ -0,0 +1,24 @@
import { ChemicalServer } from "chemicaljs";
import next from "next";
const [app, listen] = new ChemicalServer({
default: "uv",
uv: true,
rammerhead: false,
});
const port = process.env.PORT || 3000;
const dev = process.env.NODE_ENV !== "production";
const nextApp = next({ dev });
const handle = nextApp.getRequestHandler();
nextApp.prepare().then(() => {
app.serveChemical();
app.all("*", (req, res) => {
return handle(req, res);
});
listen(port, () => {
console.log(`Radius listening on port ${port}`);
});
});

View file

@ -1,32 +1,32 @@
'use client' "use client";
import { useState, useEffect } from 'react' import { useState, useEffect } from "react";
import App from '@/components/game' import App from "@/components/game";
interface AppData { interface AppData {
title: string title: string;
image: string image: string;
url: string url: string;
} }
export default function Apps() { export default function Apps() {
const [Apps, setApps] = useState<AppData[]>([]) const [Apps, setApps] = useState<AppData[]>([]);
useEffect(() => { useEffect(() => {
async function fetchApps() { async function fetchApps() {
try { try {
const response = await fetch('/apps.json') const response = await fetch("/apps.json");
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch data') throw new Error("Failed to fetch data");
} }
const data: AppData[] = await response.json() const data: AppData[] = await response.json();
setApps(data) setApps(data);
} catch (error) { } catch (error) {
console.error('Error fetching data:', error) console.error("Error fetching data:", error);
} }
} }
fetchApps() fetchApps();
}, []) }, []);
return ( return (
<div> <div>
@ -39,5 +39,5 @@ export default function Apps() {
))} ))}
</div> </div>
</div> </div>
) );
} }

View file

@ -1,32 +1,32 @@
'use client' "use client";
import { useState, useEffect } from 'react' import { useState, useEffect } from "react";
import Game from '@/components/game' import Game from "@/components/game";
interface GameData { interface GameData {
title: string title: string;
image: string image: string;
url: string url: string;
} }
export default function Games() { export default function Games() {
const [games, setGames] = useState<GameData[]>([]) const [games, setGames] = useState<GameData[]>([]);
useEffect(() => { useEffect(() => {
async function fetchGames() { async function fetchGames() {
try { try {
const response = await fetch('/games.json') const response = await fetch("/games.json");
if (!response.ok) { if (!response.ok) {
throw new Error('Failed to fetch data') throw new Error("Failed to fetch data");
} }
const data: GameData[] = await response.json() const data: GameData[] = await response.json();
setGames(data) setGames(data);
} catch (error) { } catch (error) {
console.error('Error fetching data:', error) console.error("Error fetching data:", error);
} }
} }
fetchGames() fetchGames();
}, []) }, []);
return ( return (
<div> <div>
@ -39,5 +39,5 @@ export default function Games() {
))} ))}
</div> </div>
</div> </div>
) );
} }

View file

@ -140,4 +140,4 @@
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
} }

View file

@ -1,76 +1,106 @@
'use client' "use client";
import Sidebar from '@/components/sidebar' import Sidebar from "@/components/sidebar";
import { Button } from '@/components/ui/button' import { Button } from "@/components/ui/button";
import { encodeXor, formatSearch } from '@/lib/utils' import { encodeXor } from "@/lib/utils";
import { useEffect, useRef, useState } from 'react' import { useEffect, useRef, useState } from "react";
import store from 'store2' import store from "store2";
import * as Lucide from 'lucide-react' import * as Lucide from "lucide-react";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
interface ContentWindow extends Window { interface ContentWindow extends Window {
__uv$location: Location __uv$location: Location;
}
declare global {
interface Window {
chemical: any;
}
} }
export default function Route({ params }: { params: { route: string[] } }) { export default function Route({ params }: { params: { route: string[] } }) {
const ref = useRef<HTMLIFrameElement>(null) const ref = useRef<HTMLIFrameElement>(null);
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false);
const route = params.route.join('/') const route = params.route.join("/");
const [tabIcon, setTabIcon] = useState('') const [tabIcon, setTabIcon] = useState("");
const [tabName, setTabName] = useState('') const [tabName, setTabName] = useState("");
const [shortcutted, setShortcutted] = useState(false) const [shortcutted, setShortcutted] = useState(false);
useEffect(() => { useEffect(() => {
if ('serviceWorker' in navigator) { async function go() {
navigator.serviceWorker if (ref.current) {
.register('/uv/sw.js', { ref.current.src = await window.chemical.encode(
scope: '/uv/service' atob(decodeURIComponent(route)),
}) {
.then(() => { autoHttps: true,
if (ref.current) { searchEngine: "https://www.google.com/search?q=%s",
ref.current.src = '/uv/service/' + encodeXor(formatSearch(atob(decodeURIComponent(route))))
} }
}) );
}
} }
}, [])
go();
}, []);
function triggerShortcut() { function triggerShortcut() {
store.set('shortcuts', [], false) store.set("shortcuts", [], false);
if (!ref.current || !ref.current.contentWindow) return if (!ref.current || !ref.current.contentWindow) return;
const contentWindow = ref.current.contentWindow as ContentWindow const contentWindow = ref.current.contentWindow as ContentWindow;
if (!('__uv$location' in contentWindow)) return if (!("__uv$location" in contentWindow)) return;
const shortcuts: any[] = store('shortcuts') const shortcuts: any[] = store("shortcuts");
if (shortcuts.some((value) => value.url == contentWindow.__uv$location.href)) { if (
shortcuts.some((value) => value.url == contentWindow.__uv$location.href)
) {
store( store(
'shortcuts', "shortcuts",
shortcuts.filter((value) => value.url !== contentWindow.__uv$location.href) shortcuts.filter(
) (value) => value.url !== contentWindow.__uv$location.href
setShortcutted(false) )
);
setShortcutted(false);
} else { } else {
store('shortcuts', [ store("shortcuts", [
...store('shortcuts'), ...store("shortcuts"),
{ {
image: (contentWindow.document.querySelector("link[rel*='icon']") as HTMLLinkElement)?.href || `${contentWindow.__uv$location.origin}/favicon.ico`, image:
(
contentWindow.document.querySelector(
"link[rel*='icon']"
) as HTMLLinkElement
)?.href || `${contentWindow.__uv$location.origin}/favicon.ico`,
title: contentWindow.document.title, title: contentWindow.document.title,
url: contentWindow.__uv$location.href url: contentWindow.__uv$location.href,
} },
]) ]);
setShortcutted(true) setShortcutted(true);
} }
} }
function handleLoad() { function handleLoad() {
if (!ref.current || !ref.current.contentWindow) return if (!ref.current || !ref.current.contentWindow) return;
const contentWindow = ref.current.contentWindow as ContentWindow const contentWindow = ref.current.contentWindow as ContentWindow;
setTabName(contentWindow.document.title) setTabName(contentWindow.document.title);
setTabIcon((contentWindow.document.querySelector("link[rel*='icon']") as HTMLLinkElement)?.href || `${contentWindow.__uv$location.origin}/favicon.ico`) setTabIcon(
(
contentWindow.document.querySelector(
"link[rel*='icon']"
) as HTMLLinkElement
)?.href || `${contentWindow.__uv$location.origin}/favicon.ico`
);
store.set('shortcuts', [], false) store.set("shortcuts", [], false);
const shortcuts: any[] = store('shortcuts') const shortcuts: any[] = store("shortcuts");
if (shortcuts.some((value) => value.url == contentWindow.__uv$location.href)) { if (
setShortcutted(true) shortcuts.some((value) => value.url == contentWindow.__uv$location.href)
) {
setShortcutted(true);
} }
} }
return ( return (
@ -81,8 +111,14 @@ export default function Route({ params }: { params: { route: string[] } }) {
<Lucide.Menu className="h-7 w-7" /> <Lucide.Menu className="h-7 w-7" />
</Button> </Button>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
{tabIcon ? <img src={tabIcon} className="h-8 w-8" /> : <Lucide.Radius className="h-8 w-8 rotate-180" />} {tabIcon ? (
<h1 className="text-xl font-bold">{tabName ? tabName : 'Radius'}</h1> <img src={tabIcon} className="h-8 w-8" />
) : (
<Lucide.Radius className="h-8 w-8 rotate-180" />
)}
<h1 className="text-xl font-bold">
{tabName ? tabName : "Radius"}
</h1>
</div> </div>
</div> </div>
<div className="flex items-center gap-2 z-50"> <div className="flex items-center gap-2 z-50">
@ -108,7 +144,9 @@ export default function Route({ params }: { params: { route: string[] } }) {
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<Button variant="ghost" size="icon" onClick={triggerShortcut}> <Button variant="ghost" size="icon" onClick={triggerShortcut}>
<Lucide.Star className={shortcutted ? 'fill-foreground' : 'fill-none'} /> <Lucide.Star
className={shortcutted ? "fill-foreground" : "fill-none"}
/>
</Button> </Button>
</TooltipTrigger> </TooltipTrigger>
<TooltipContent>Shortcut</TooltipContent> <TooltipContent>Shortcut</TooltipContent>
@ -118,14 +156,30 @@ export default function Route({ params }: { params: { route: string[] } }) {
<Sidebar open={open} onOpenChange={setOpen} /> <Sidebar open={open} onOpenChange={setOpen} />
</div> </div>
<iframe ref={ref} onLoad={handleLoad} className="h-[calc(100vh-3.5rem)] w-full"></iframe> <iframe
ref={ref}
onLoad={handleLoad}
className="h-[calc(100vh-3.5rem)] w-full"
></iframe>
<div className="flex items-center justify-center fixed h-full w-full pointer-events-none -z-10"> <div className="flex items-center justify-center fixed h-full w-full pointer-events-none -z-10">
<svg aria-hidden="true" className="w-20 h-20 animate-spin text-gray-600 fill-primary" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor" /> aria-hidden="true"
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill" /> className="w-20 h-20 animate-spin text-gray-600 fill-primary"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg> </svg>
</div> </div>
</div> </div>
) );
} }

View file

@ -1,34 +1,33 @@
import type { Metadata } from 'next' import type { Metadata } from "next";
import { Inter } from 'next/font/google' import { Inter } from "next/font/google";
import './globals.css' import "./globals.css";
import Navbar from '@/components/navbar' import Navbar from "@/components/navbar";
import { Themes } from "./providers"; import { Themes } from "./providers";
const inter = Inter({ subsets: ['latin'] }) const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = { export const metadata: Metadata = {
title: 'Radius', title: "Radius",
description: '' description: "",
} };
export default function RootLayout({ export default function RootLayout({
children children,
}: Readonly<{ }: Readonly<{
children: React.ReactNode children: React.ReactNode;
}>) { }>) {
return ( return (
<html lang="en"> <html lang="en">
<head> <head>
<link rel="icon" href="/icon.png" /> <link rel="icon" href="/icon.png" />
<script src="/chemical.js"></script>
</head> </head>
<body className={inter.className}> <body className={inter.className}>
<Themes> <Themes>
<Navbar /> <Navbar />
<div className="pt-14">{children}</div> <div className="pt-14">{children}</div>
</Themes> </Themes>
</body> </body>
</html> </html>
) );
} }

View file

@ -1,45 +1,46 @@
'use client' "use client";
import { Button } from '@/components/ui/button'; import { Button } from "@/components/ui/button";
import { Card, CardContent, CardTitle } from '@/components/ui/card'; import { Card, CardContent, CardTitle } from "@/components/ui/card";
import { ShieldX } from 'lucide-react'; import { ShieldX } from "lucide-react";
import Image from 'next/image'; import Image from "next/image";
export default function PageNotFound() { export default function PageNotFound() {
return ( return (
<div className="flex h-screen items-center justify-center"> <div className="flex h-screen items-center justify-center">
{/* Container for mobile and desktop layouts */} {/* Container for mobile and desktop layouts */}
<div className="flex flex-col lg:flex-row items-center justify-center space-y-6 lg:space-y-0 lg:space-x-8"> <div className="flex flex-col lg:flex-row items-center justify-center space-y-6 lg:space-y-0 lg:space-x-8">
{/* Cat gif on top for mobile, on the left for larger screens */} {/* Cat gif on top for mobile, on the left for larger screens */}
<div className="flex-shrink-0"> <div className="flex-shrink-0">
<Image <Image
src="/kitty.gif" src="/kitty.gif"
width={300} // dont adjust unless you're weird width={300} // dont adjust unless you're weird
height={300} height={300}
alt="kitty" alt="kitty"
className="rounded-lg" // rounded corner for kitty className="rounded-lg" // rounded corner for kitty
/> />
</div> </div>
{/* the error card */} {/* the error card */}
<Card className="flex h-96 w-96 flex-col items-center justify-center"> <Card className="flex h-96 w-96 flex-col items-center justify-center">
<CardTitle className="mx-auto mb-2 flex flex-col items-center justify-center"> <CardTitle className="mx-auto mb-2 flex flex-col items-center justify-center">
<ShieldX className="h-14 w-14" /> <ShieldX className="h-14 w-14" />
<h2 className="mt-2 text-3xl font-semibold">404 Error</h2> <h2 className="mt-2 text-3xl font-semibold">404 Error</h2>
</CardTitle> </CardTitle>
<CardContent className="mt-4 text-center text-base"> <CardContent className="mt-4 text-center text-base">
Click below to go to the home page.<br /> 404 - Page not found Click below to go to the home page.
</CardContent> <br /> 404 - Page not found
<CardContent className="mt-4"> </CardContent>
<Button <CardContent className="mt-4">
type="button" <Button
onClick={() => (window.location.href = '/')} type="button"
className="text-muted-background text-black" onClick={() => (window.location.href = "/")}
> className="text-muted-background text-black"
Go Home >
</Button> Go Home
</CardContent> </Button>
</Card> </CardContent>
</div> </Card>
</div> </div>
); </div>
);
} }

View file

@ -1,31 +1,30 @@
'use client' "use client";
import Shortcut from '@/components/shortcut' import Shortcut from "@/components/shortcut";
import { Input } from '@/components/ui/input' import { Input } from "@/components/ui/input";
import { Flame, Radius, Search } from 'lucide-react' import { Flame, Radius, Search } from "lucide-react";
import { useEffect, useState } from 'react' import { useEffect, useState } from "react";
import { useRouter } from 'next/navigation' import { useRouter } from "next/navigation";
import { Item } from '@/lib/types' import { Item } from "@/lib/types";
import store from 'store2' import store from "store2";
export default function Home() { export default function Home() {
const router = useRouter() const router = useRouter();
const [shortcuts, setShortcuts] = useState<Item[]>([]) const [shortcuts, setShortcuts] = useState<Item[]>([]);
const [splashText, setSplashText] = useState<string>('') const [splashText, setSplashText] = useState<string>("");
useEffect(() => { useEffect(() => {
fetch("/splash.json")
fetch('/splash.json') .then((response) => response.json())
.then(response => response.json()) .then((data) => {
.then(data => {
const randomIndex = Math.floor(Math.random() * data.length); const randomIndex = Math.floor(Math.random() * data.length);
setSplashText(data[randomIndex].splash); setSplashText(data[randomIndex].splash);
}) })
.catch(error => console.error('Error fetching splash text:', error)); .catch((error) => console.error("Error fetching splash text:", error));
store.set('shortcuts', [], false) store.set("shortcuts", [], false);
const data: Item[] = store('shortcuts') const data: Item[] = store("shortcuts");
setShortcuts(data) setShortcuts(data);
}, []) }, []);
return ( return (
<div> <div>
@ -40,22 +39,37 @@ export default function Home() {
className="w-[26rem] px-9 h-12 rounded-lg" className="w-[26rem] px-9 h-12 rounded-lg"
placeholder="Search the web" placeholder="Search the web"
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key !== 'Enter') return if (e.key !== "Enter") return;
router.push(`/go/${btoa(e.currentTarget.value)}`) router.push(`/go/${btoa(e.currentTarget.value)}`);
}} }}
/> />
<Search className="h-4 w-4 text-muted-foreground absolute top-1/2 -translate-y-1/2 left-3" /> <Search className="h-4 w-4 text-muted-foreground absolute top-1/2 -translate-y-1/2 left-3" />
</div> </div>
</div> </div>
<p style={{ fontSize: '1rem', fontWeight: 'normal', marginTop: '0.4rem' }}>{splashText}</p> <p
style={{
fontSize: "1rem",
fontWeight: "normal",
marginTop: "0.4rem",
}}
>
{splashText}
</p>
{shortcuts.length > 0 && ( {shortcuts.length > 0 && (
<div className="py-2 flex flex-wrap gap-2 justify-center"> <div className="py-2 flex flex-wrap gap-2 justify-center">
{shortcuts.map((shortcut: Item) => { {shortcuts.map((shortcut: Item) => {
return <Shortcut key={shortcut.title} image={shortcut.image} title={shortcut.title} url={shortcut.url} /> return (
<Shortcut
key={shortcut.title}
image={shortcut.image}
title={shortcut.title}
url={shortcut.url}
/>
);
})} })}
</div> </div>
)} )}
</div> </div>
</div> </div>
) );
} }

View file

@ -4,4 +4,4 @@ import { ThemeProvider } from "next-themes";
export function Themes({ children }: { children: React.ReactNode }) { export function Themes({ children }: { children: React.ReactNode }) {
return <ThemeProvider attribute="class">{children}</ThemeProvider>; return <ThemeProvider attribute="class">{children}</ThemeProvider>;
} }

View file

@ -1,51 +1,58 @@
'use client' "use client";
import { zodResolver } from '@hookform/resolvers/zod' import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from 'react-hook-form' import { useForm } from "react-hook-form";
import { z } from 'zod' import { z } from "zod";
import { Button } from '@/components/ui/button' import { Button } from "@/components/ui/button";
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form' import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from '@/components/ui/input' import { Input } from "@/components/ui/input";
import { Separator } from '@/components/ui/separator' import { Separator } from "@/components/ui/separator";
import { Save, RotateCcw } from 'lucide-react' import { Save, RotateCcw } from "lucide-react";
import { useState } from 'react' import { useState } from "react";
import { toast } from 'sonner' import { toast } from "sonner";
const formSchema = z.object({ const formSchema = z.object({
backgroundImage: z.string().url('Please provide a valid URL'), backgroundImage: z.string().url("Please provide a valid URL"),
description: z.string().optional(), description: z.string().optional(),
}) });
export default function Settings() { export default function Settings() {
const [submitting, setSubmitting] = useState(false) const [submitting, setSubmitting] = useState(false);
const form = useForm<z.infer<typeof formSchema>>({ const form = useForm<z.infer<typeof formSchema>>({
resolver: zodResolver(formSchema), resolver: zodResolver(formSchema),
defaultValues: { defaultValues: {
backgroundImage: '', backgroundImage: "",
}, },
}) });
function onSubmit(values: z.infer<typeof formSchema>) { function onSubmit(values: z.infer<typeof formSchema>) {
setSubmitting(true) setSubmitting(true);
document.body.style.backgroundImage = `url(${values.backgroundImage})` document.body.style.backgroundImage = `url(${values.backgroundImage})`;
document.body.style.backgroundSize = 'cover' document.body.style.backgroundSize = "cover";
document.body.style.backgroundPosition = 'center' document.body.style.backgroundPosition = "center";
setTimeout(() => { setTimeout(() => {
setSubmitting(false) setSubmitting(false);
toast.success('Settings saved') toast.success("Settings saved");
}, 1000) }, 1000);
console.log(values) console.log(values);
} }
function onReset() { function onReset() {
form.reset() form.reset();
document.body.style.backgroundImage = '' document.body.style.backgroundImage = "";
toast('Settings reset') toast("Settings reset");
} }
return ( return (
@ -53,7 +60,10 @@ export default function Settings() {
<h1 className="text-4xl font-semibold">Appearance</h1> <h1 className="text-4xl font-semibold">Appearance</h1>
<Separator /> <Separator />
<Form {...form}> <Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="w-1/2 space-y-4"> <form
onSubmit={form.handleSubmit(onSubmit)}
className="w-1/2 space-y-4"
>
<FormField <FormField
control={form.control} control={form.control}
name="backgroundImage" name="backgroundImage"
@ -80,5 +90,5 @@ export default function Settings() {
</form> </form>
</Form> </Form>
</div> </div>
) );
} }

View file

@ -1,6 +1,6 @@
'use client' "use client";
import { Separator } from '@/components/ui/separator' import { Separator } from "@/components/ui/separator";
export default function Credits() { export default function Credits() {
return ( return (
@ -15,8 +15,9 @@ export default function Credits() {
<li>Sparkzil</li> <li>Sparkzil</li>
<li>Scaratek</li> <li>Scaratek</li>
<li>fwxe</li> <li>fwxe</li>
<li>Nebelung</li>
</ul> </ul>
</div> </div>
</div> </div>
) );
} }

View file

@ -1,33 +1,50 @@
'use client' "use client";
import { Button } from '@/components/ui/button' import { Button } from "@/components/ui/button";
import { Users, Link, Palette } from 'lucide-react' import { Users, Link, Palette } from "lucide-react";
import NextLink from 'next/link' import NextLink from "next/link";
import { usePathname } from 'next/navigation' import { usePathname } from "next/navigation";
export default function SettingsLayout({ children }: Readonly<{ children: React.ReactNode }>) { export default function SettingsLayout({
const pathname = usePathname() children,
}: Readonly<{ children: React.ReactNode }>) {
const pathname = usePathname();
return ( return (
<div className="flex"> <div className="flex">
<div className="flex w-1/4 flex-col gap-2 p-4 pl-8 pt-8"> <div className="flex w-1/4 flex-col gap-2 p-4 pl-8 pt-8">
<NextLink href="/settings/appearance/"> <NextLink href="/settings/appearance/">
<Button variant={pathname?.includes('/settings/appearance') ? 'secondary' : 'ghost'} className="w-full items-center justify-start gap-2"> <Button
variant={
pathname?.includes("/settings/appearance") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<Palette className="h-5 w-5" /> Appearance <Palette className="h-5 w-5" /> Appearance
</Button> </Button>
</NextLink> </NextLink>
<NextLink href="/settings/credits/"> <NextLink href="/settings/credits/">
<Button variant={pathname?.includes('/settings/credits') ? 'secondary' : 'ghost'} className="w-full items-center justify-start gap-2"> <Button
variant={
pathname?.includes("/settings/credits") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<Users className="h-5 w-5" /> Credits <Users className="h-5 w-5" /> Credits
</Button> </Button>
</NextLink> </NextLink>
<NextLink href="/settings/links/"> <NextLink href="/settings/links/">
<Button variant={pathname?.includes('/settings/links') ? 'secondary' : 'ghost'} className="w-full items-center justify-start gap-2"> <Button
variant={
pathname?.includes("/settings/links") ? "secondary" : "ghost"
}
className="w-full items-center justify-start gap-2"
>
<Link className="h-5 w-5" /> Social Links <Link className="h-5 w-5" /> Social Links
</Button> </Button>
</NextLink> </NextLink>
</div> </div>
<div className="w-3/4 px-12 py-8">{children}</div> <div className="w-3/4 px-12 py-8">{children}</div>
</div> </div>
) );
} }

View file

@ -1,7 +1,7 @@
'use client' "use client";
import NextLink from 'next/link' import NextLink from "next/link";
import { Separator } from '@/components/ui/separator' import { Separator } from "@/components/ui/separator";
export default function SocialLinks() { export default function SocialLinks() {
return ( return (
@ -14,13 +14,17 @@ export default function SocialLinks() {
<li>TikTok: @radiusproxy</li> <li>TikTok: @radiusproxy</li>
<li>YouTube: @RadiusProxy</li> <li>YouTube: @RadiusProxy</li>
<li> <li>
Discord:{' '} Discord:{" "}
<NextLink href="https://discord.gg/JrAxQz7Qkw" target="_blank" className="text-blue-500 underline"> <NextLink
href="https://discord.gg/JrAxQz7Qkw"
target="_blank"
className="text-blue-500 underline"
>
Join Now! Join Now!
</NextLink> </NextLink>
</li> </li>
</ul> </ul>
</div> </div>
</div> </div>
) );
} }

View file

@ -1,29 +0,0 @@
import fs from 'fs'
import { notFound } from 'next/navigation'
import { NextRequest } from 'next/server'
export async function GET(_req: NextRequest, { params }: { params: { uv: string } }) {
const requestedFile = params.uv
if (requestedFile === 'uv.config.js' || requestedFile === 'sw.js') {
const file = fs.readFileSync(process.cwd() + `/src/lib/uv/${requestedFile}`)
const fileBlob = new Blob([file])
return new Response(fileBlob, {
headers: {
'Content-Type': 'application/javascript'
}
})
} else {
try {
const res = await fetch(`https://unpkg.com/@titaniumnetwork-dev/ultraviolet@2.0.0/dist/${requestedFile}`)
const file = await res.text()
const fileBlob = new Blob([file])
return new Response(fileBlob, {
headers: {
'Content-Type': 'application/javascript'
}
})
} catch {
notFound()
}
}
}

6
src/lib/types.d.ts vendored
View file

@ -1,5 +1,5 @@
export interface Item { export interface Item {
title: string title: string;
image: string image: string;
url: string url: string;
} }

View file

@ -1,32 +1,20 @@
import { type ClassValue, clsx } from 'clsx' import { type ClassValue, clsx } from "clsx";
import { twMerge } from 'tailwind-merge' import { twMerge } from "tailwind-merge";
import { useRouter } from 'next/navigation'
export function cn(...inputs: ClassValue[]) { export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs)) return twMerge(clsx(inputs));
} }
export const fetcher = (url: string) => fetch(url).then((res) => res.json()) export const fetcher = (url: string) => fetch(url).then((res) => res.json());
export function encodeXor(str: string) { export function encodeXor(str: string) {
if (!str) return str if (!str) return str;
return encodeURIComponent( return encodeURIComponent(
str str
.toString() .toString()
.split('') .split("")
.map((char, ind) => (ind % 2 ? String.fromCharCode(char.charCodeAt(NaN) ^ 2) : char)) .map((char, ind) =>
.join('') ind % 2 ? String.fromCharCode(char.charCodeAt(NaN) ^ 2) : char
) )
.join("")
);
} }
export function formatSearch(input: string): string {
try {
return new URL(input).toString()
} catch (e) {}
try {
const url = new URL(`http://${input}`)
if (url.hostname.includes('.')) return url.toString()
} catch (e) {}
return new URL(`https://google.com/search?q=${input}`).toString()
}

View file

@ -1,14 +0,0 @@
/*global UVServiceWorker,__uv$config*/
/*
* Stock service worker script.
* Users can provide their own sw.js if they need to extend the functionality of the service worker.
* Ideally, this will be registered under the scope in uv.config.js so it will not need to be modified.
* However, if a user changes the location of uv.bundle.js/uv.config.js or sw.js is not relative to them, they will need to modify this script locally.
*/
importScripts('/uv/uv.bundle.js');
importScripts('/uv/uv.config.js');
importScripts(__uv$config.sw || '/uv/uv.sw.js');
const sw = new UVServiceWorker();
self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event)));

View file

@ -1,12 +0,0 @@
/*global Ultraviolet*/
self.__uv$config = {
prefix: '/uv/service/',
bare: '/api/bare/',
encodeUrl: Ultraviolet.codec.xor.encode,
decodeUrl: Ultraviolet.codec.xor.decode,
handler: '/uv/uv.handler.js',
client: '/uv/uv.client.js',
bundle: '/uv/uv.bundle.js',
config: '/uv/uv.config.js',
sw: '/uv/uv.sw.js',
};

View file

@ -1,20 +0,0 @@
import type { NextApiRequest, NextApiResponse } from 'next'
import { createBareServer } from '@tomphttp/bare-server-node'
const bare = createBareServer('/api/bare/', {
logErrors: false,
localAddress: undefined,
maintainer: {
email: 'contact@proudparrot2.tech',
website: 'https://github.com/proudparrot2/'
}
})
export const config = {
api: {
externalResolver: true
}
}
export default function handler(req: NextApiRequest, res: NextApiResponse) {
bare.routeRequest(req, res)
}

View file

@ -1,82 +1,89 @@
/** @type {import('tailwindcss').Config} */ /** @type {import('tailwindcss').Config} */
const defaultTheme = require('tailwindcss/defaultTheme') const defaultTheme = require("tailwindcss/defaultTheme");
const svgToDataUri = require('mini-svg-data-uri') const svgToDataUri = require("mini-svg-data-uri");
const colors = require('tailwindcss/colors') const colors = require("tailwindcss/colors");
const { default: flattenColorPalette } = require('tailwindcss/lib/util/flattenColorPalette') const {
default: flattenColorPalette,
} = require("tailwindcss/lib/util/flattenColorPalette");
const config = { const config = {
darkMode: ['class'], darkMode: ["class"],
content: ['./pages/**/*.{ts,tsx}', './components/**/*.{ts,tsx}', './app/**/*.{ts,tsx}', './src/**/*.{ts,tsx}'], content: [
prefix: '', "./pages/**/*.{ts,tsx}",
"./components/**/*.{ts,tsx}",
"./app/**/*.{ts,tsx}",
"./src/**/*.{ts,tsx}",
],
prefix: "",
theme: { theme: {
container: { container: {
center: true, center: true,
padding: '2rem', padding: "2rem",
screens: { screens: {
'2xl': '1400px' "2xl": "1400px",
} },
}, },
extend: { extend: {
colors: { colors: {
border: 'hsl(var(--border))', border: "hsl(var(--border))",
input: 'hsl(var(--input))', input: "hsl(var(--input))",
ring: 'hsl(var(--ring))', ring: "hsl(var(--ring))",
background: 'hsl(var(--background))', background: "hsl(var(--background))",
foreground: 'hsl(var(--foreground))', foreground: "hsl(var(--foreground))",
primary: { primary: {
DEFAULT: 'hsl(var(--primary))', DEFAULT: "hsl(var(--primary))",
foreground: 'hsl(var(--primary-foreground))' foreground: "hsl(var(--primary-foreground))",
}, },
secondary: { secondary: {
DEFAULT: 'hsl(var(--secondary))', DEFAULT: "hsl(var(--secondary))",
foreground: 'hsl(var(--secondary-foreground))' foreground: "hsl(var(--secondary-foreground))",
}, },
destructive: { destructive: {
DEFAULT: 'hsl(var(--destructive))', DEFAULT: "hsl(var(--destructive))",
foreground: 'hsl(var(--destructive-foreground))' foreground: "hsl(var(--destructive-foreground))",
}, },
muted: { muted: {
DEFAULT: 'hsl(var(--muted))', DEFAULT: "hsl(var(--muted))",
foreground: 'hsl(var(--muted-foreground))' foreground: "hsl(var(--muted-foreground))",
}, },
accent: { accent: {
DEFAULT: 'hsl(var(--accent))', DEFAULT: "hsl(var(--accent))",
foreground: 'hsl(var(--accent-foreground))' foreground: "hsl(var(--accent-foreground))",
}, },
popover: { popover: {
DEFAULT: 'hsl(var(--popover))', DEFAULT: "hsl(var(--popover))",
foreground: 'hsl(var(--popover-foreground))' foreground: "hsl(var(--popover-foreground))",
}, },
card: { card: {
DEFAULT: 'hsl(var(--card))', DEFAULT: "hsl(var(--card))",
foreground: 'hsl(var(--card-foreground))' foreground: "hsl(var(--card-foreground))",
} },
}, },
borderRadius: { borderRadius: {
lg: 'var(--radius)', lg: "var(--radius)",
md: 'calc(var(--radius) - 2px)', md: "calc(var(--radius) - 2px)",
sm: 'calc(var(--radius) - 4px)' sm: "calc(var(--radius) - 4px)",
}, },
keyframes: { keyframes: {
'accordion-down': { "accordion-down": {
from: { height: '0' }, from: { height: "0" },
to: { height: 'var(--radix-accordion-content-height)' } to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
}, },
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' }
}
}, },
animation: { animation: {
'accordion-down': 'accordion-down 0.2s ease-out', "accordion-down": "accordion-down 0.2s ease-out",
'accordion-up': 'accordion-up 0.2s ease-out' "accordion-up": "accordion-up 0.2s ease-out",
} },
} },
}, },
plugins: [require('tailwindcss-animate')] plugins: [require("tailwindcss-animate")],
} };
module.exports = config module.exports = config;