From 0c1a0d74d797d25a0217753372a6a5293dd00ae5 Mon Sep 17 00:00:00 2001 From: UltraLionFr Date: Wed, 20 Aug 2025 14:14:33 +0200 Subject: [PATCH] Update code --- .gitignore | 2 + README.md | 2 +- app/[id]/page.tsx | 330 +++ app/about/page.tsx | 173 ++ app/api/auth/[...nextauth]/route.ts | 25 + app/api/paste/[id]/page.tsx | 30 + app/api/paste/[id]/route.ts | 68 + app/api/paste/route.ts | 61 + app/api/stats/route.ts | 10 + app/api/user-pastes/route.ts | 45 + app/dashboard/layout.tsx | 9 + app/dashboard/page.tsx | 142 ++ app/favicon.ico | Bin 25931 -> 0 bytes app/globals.css | 56 +- app/layout.tsx | 64 +- app/not-found.tsx | 54 + app/page.module.css | 167 -- app/page.tsx | 96 +- app/utils/fetcher.ts | 4 + components/PasteForm.tsx | 76 + components/SessionProvider.tsx | 8 + components/dashboard/Header.tsx | 40 + components/dashboard/LoadingDashboard.tsx | 77 + components/dashboard/LordIcon.tsx | 20 + components/dashboard/Pagination.tsx | 31 + components/dashboard/PasteCard.tsx | 60 + components/dashboard/SearchBar.tsx | 20 + components/dashboard/Sidebar.tsx | 51 + components/dashboard/StatCard.tsx | 36 + components/modals/ConfirmDeleteModal.tsx | 75 + components/paste-form/AuthSection.tsx | 61 + components/paste-form/Editor.tsx | 48 + components/paste-form/SaveButton.tsx | 28 + components/paste-form/SidebarPanel.tsx | 111 + components/ui/LogoutButton.tsx | 24 + components/ui/ToasterProvider.tsx | 30 + lib/format-bytes.ts | 7 + lib/prisma.ts | 10 + lib/stats.ts | 50 + package.json | 29 +- pnpm-lock.yaml | 1903 ++++++++++++++++- postcss.config.mjs | 6 + prisma/altbin.db | Bin 0 -> 57344 bytes .../20250819133430_init/migration.sql | 12 + prisma/migrations/migration_lock.toml | 3 + prisma/schema.prisma | 28 + public/favicon.png | Bin 0 -> 27154 bytes public/file.svg | 1 - public/globe.svg | 1 - public/next.svg | 1 - public/vercel.svg | 1 - public/window.svg | 1 - types/next-auth.d.ts | 16 + 53 files changed, 3830 insertions(+), 373 deletions(-) create mode 100644 app/[id]/page.tsx create mode 100644 app/about/page.tsx create mode 100644 app/api/auth/[...nextauth]/route.ts create mode 100644 app/api/paste/[id]/page.tsx create mode 100644 app/api/paste/[id]/route.ts create mode 100644 app/api/paste/route.ts create mode 100644 app/api/stats/route.ts create mode 100644 app/api/user-pastes/route.ts create mode 100644 app/dashboard/layout.tsx create mode 100644 app/dashboard/page.tsx delete mode 100644 app/favicon.ico create mode 100644 app/not-found.tsx delete mode 100644 app/page.module.css create mode 100644 app/utils/fetcher.ts create mode 100644 components/PasteForm.tsx create mode 100644 components/SessionProvider.tsx create mode 100644 components/dashboard/Header.tsx create mode 100644 components/dashboard/LoadingDashboard.tsx create mode 100644 components/dashboard/LordIcon.tsx create mode 100644 components/dashboard/Pagination.tsx create mode 100644 components/dashboard/PasteCard.tsx create mode 100644 components/dashboard/SearchBar.tsx create mode 100644 components/dashboard/Sidebar.tsx create mode 100644 components/dashboard/StatCard.tsx create mode 100644 components/modals/ConfirmDeleteModal.tsx create mode 100644 components/paste-form/AuthSection.tsx create mode 100644 components/paste-form/Editor.tsx create mode 100644 components/paste-form/SaveButton.tsx create mode 100644 components/paste-form/SidebarPanel.tsx create mode 100644 components/ui/LogoutButton.tsx create mode 100644 components/ui/ToasterProvider.tsx create mode 100644 lib/format-bytes.ts create mode 100644 lib/prisma.ts create mode 100644 lib/stats.ts create mode 100644 postcss.config.mjs create mode 100644 prisma/altbin.db create mode 100644 prisma/migrations/20250819133430_init/migration.sql create mode 100644 prisma/migrations/migration_lock.toml create mode 100644 prisma/schema.prisma create mode 100644 public/favicon.png delete mode 100644 public/file.svg delete mode 100644 public/globe.svg delete mode 100644 public/next.svg delete mode 100644 public/vercel.svg delete mode 100644 public/window.svg create mode 100644 types/next-auth.d.ts diff --git a/.gitignore b/.gitignore index 5ef6a52..45254b6 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,5 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +/app/generated/prisma diff --git a/README.md b/README.md index e215bc4..9baee9a 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ You can check out [the Next.js GitHub repository](https://github.com/vercel/next The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. +Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. \ No newline at end of file diff --git a/app/[id]/page.tsx b/app/[id]/page.tsx new file mode 100644 index 0000000..6298ec4 --- /dev/null +++ b/app/[id]/page.tsx @@ -0,0 +1,330 @@ +'use client'; + +import { + CalendarDays, + Copy, + Download, + Eye, + FileText, + Plus, +} from 'lucide-react'; +import { useRouter } from 'next/navigation'; +import { useEffect, useRef, useState } from 'react'; + +import Prism from 'prismjs'; +import 'prismjs/components/prism-bash'; +import 'prismjs/components/prism-javascript'; +import 'prismjs/components/prism-json'; +import 'prismjs/components/prism-python'; +import 'prismjs/components/prism-typescript'; +import 'prismjs/themes/prism-tomorrow.css'; + +import 'prismjs/plugins/line-numbers/prism-line-numbers.css'; +import 'prismjs/plugins/line-numbers/prism-line-numbers.js'; + +/** ---------- Loader animé (spinner + skeletons) ---------- */ +function LoadingPaste() { + return ( +
+ {/* Zone code (skeleton lignes) */} +
+
+
+
+ Chargement du paste… +
+
+ {Array.from({ length: 28 }).map((_, i) => ( +
+ ))} +
+
+
+ + {/* Sidebar (skeleton cartes + boutons) */} +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ +
+ {Array.from({ length: 4 }).map((_, i) => ( +
+ ))} +
+ +
+
+
+ ); +} +/** -------------------------------------------------------- */ + +export default function PastePage({ params }: { params: { id: string } }) { + const [paste, setPaste] = useState(null); + const [error, setError] = useState(''); + const [loading, setLoading] = useState(true); + const [language, setLanguage] = useState('language-javascript'); + const [copied, setCopied] = useState(false); + + const codeRef = useRef(null); + const router = useRouter(); + + const fetchPaste = async (pwd?: string) => { + setLoading(true); + const res = await fetch(`/api/paste/${params.id}`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ password: pwd || '' }), + }); + + if (res.status === 403) { + setError('Invalid password.'); + setLoading(false); + return; + } + if (res.status === 404) { + setError('Paste not found or expired.'); + setLoading(false); + return; + } + + const data = await res.json(); + setPaste(data); + + if (data.content.includes('function') || data.content.includes('const')) { + setLanguage('language-javascript'); + } else if (data.content.includes('import') || data.content.includes('export')) { + setLanguage('language-typescript'); + } else if (data.content.includes('{') && data.content.includes('}')) { + setLanguage('language-json'); + } else { + setLanguage('language-bash'); + } + + setLoading(false); + }; + + useEffect(() => { + fetchPaste(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + + useEffect(() => { + if (paste?.content) { + Prism.highlightAll(); + } + }, [paste]); + + // 👉 Remplace l'ancien message "Loading..." par le loader animé + if (loading) return ; + + if (error || (paste?.protected && !paste?.content)) { + return ( +
+
{ + e.preventDefault(); + fetchPaste((e.currentTarget as any).password.value); + }} + className=" + w-full max-w-sm rounded-2xl p-6 space-y-4 + backdrop-blur-xl shadow-2xl + bg-[linear-gradient(to_bottom_right,rgba(20,24,38,0.9),rgba(14,16,24,0.9))] + ring-1 ring-white/10 + " + > +

+ 🔒 Protected Paste +

+ {error &&

{error}

} + + + + +
+
+ ); + } + + return ( +
+
+
+          
+            {paste.content}
+          
+        
+
+ +
+
+
+

+ AltBin +

+ +
+ {paste.title && ( +

+ {paste.title} +

+ )} +
+ +
+
+ +
+
Views
+
{paste.views}
+
+
+
+ +
+
Created
+
+ {new Date(paste.createdAt).toLocaleDateString()} +
+
+
+
+ +
+ +
+ + + + + + + +
+ +
+ Copied! +
+
+
+ ); +} \ No newline at end of file diff --git a/app/about/page.tsx b/app/about/page.tsx new file mode 100644 index 0000000..4eced33 --- /dev/null +++ b/app/about/page.tsx @@ -0,0 +1,173 @@ +"use client"; + +import { Player } from "@lordicon/react"; +import { motion } from "framer-motion"; +import { ArrowLeft } from "lucide-react"; +import { useRouter } from "next/navigation"; +import { forwardRef, useEffect, useRef, useState } from "react"; + +// URLs d’icônes Lordicon +const icons = { + simplicity: "https://cdn.lordicon.com/tsrgicte.json", // simplicité + shield: "https://cdn.lordicon.com/sjoccsdj.json", // sécurité + community: "https://cdn.lordicon.com/ubpgwkmy.json", // communauté / open source + github: "https://cdn.lordicon.com/jjxzcivr.json", // GitHub + discord: "https://cdn.lordicon.com/zvnxzuwv.json", // Discord +}; + +// Wrapper pour Lordicon +const LordIcon = forwardRef(function LordIcon( + { url, size = 30, colorize = "#3b82f6" }: { url: string; size?: number; colorize?: string }, + ref: any +) { + const [iconData, setIconData] = useState(null); + + useEffect(() => { + fetch(url).then((res) => res.json()).then(setIconData); + }, [url]); + + if (!iconData) return null; + return ; +}); + +// Carte Feature +function FeatureCard({ + title, + desc, + icon, +}: { + title: string; + desc: string; + icon: string; +}) { + const iconRef = useRef(null); + + return ( + iconRef.current?.playFromBeginning()} + onMouseLeave={() => iconRef.current?.goToFirstFrame()} + > +
+
+ +
+

{title}

+
+

{desc}

+
+ ); +} + +// Bouton Contact +function ContactButton({ + href, + icon, + text, + gradient, + shadow, + color = "#fff", +}: { + href: string; + icon: string; + text: string; + gradient: string; + shadow: string; + color?: string; +}) { + const iconRef = useRef(null); + + return ( + iconRef.current?.playFromBeginning()} + onMouseLeave={() => iconRef.current?.goToFirstFrame()} + > + + {text} + + ); +} + +export default function AboutPage() { + const router = useRouter(); + + const features = [ + { + title: "Simplicity", + desc: "Create a paste in seconds, distraction-free.", + icon: icons.simplicity, + }, + { + title: "Security", + desc: "Protect your posts with a password or limited number of views.", + icon: icons.shield, + }, + { + title: "Open Source", + desc: "Contribute to the project and improve the platform.", + icon: icons.community, + }, + ]; + + return ( +
+ {/* Navbar */} +
+ router.back()} + className="cursor-pointer inline-flex items-center gap-2 px-5 py-2 rounded-xl text-sm font-medium + text-white bg-gradient-to-r from-blue-600 to-blue-500 shadow-lg shadow-blue-500/30 + hover:shadow-blue-500/50 transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-blue-400/60" + > + + Back + + +

AltBin

+
+ + {/* Features */} +
+ {features.map((f, i) => ( + + ))} +
+ + {/* Contact */} +
+

Contact

+

+ Any questions or{" "} + suggestions? + Join the community or check out the source code +

+ +
+ + +
+
+
+ ); +} \ No newline at end of file diff --git a/app/api/auth/[...nextauth]/route.ts b/app/api/auth/[...nextauth]/route.ts new file mode 100644 index 0000000..9f3894a --- /dev/null +++ b/app/api/auth/[...nextauth]/route.ts @@ -0,0 +1,25 @@ +import NextAuth, { NextAuthOptions } from 'next-auth'; +import DiscordProvider from 'next-auth/providers/discord'; + +export const authOptions: NextAuthOptions = { + providers: [ + DiscordProvider({ + clientId: process.env.DISCORD_CLIENT_ID!, + clientSecret: process.env.DISCORD_CLIENT_SECRET!, + }), + ], + callbacks: { + async session({ session, token }) { + if (session.user && token.sub) { + session.user.id = token.sub; + } else { + session.user.id = ''; + } + return session; + }, +} +}; + +const handler = NextAuth(authOptions); + +export { handler as GET, handler as POST }; diff --git a/app/api/paste/[id]/page.tsx b/app/api/paste/[id]/page.tsx new file mode 100644 index 0000000..f7a21c9 --- /dev/null +++ b/app/api/paste/[id]/page.tsx @@ -0,0 +1,30 @@ +import { prisma } from '@/lib/prisma'; + +interface Props { + params: { id: string }; +} + +export default async function PastePage({ params }: Props) { + const paste = await prisma.paste.findUnique({ + where: { id: params.id }, + select: { title: true, content: true, createdAt: true, views: true }, + }); + + if (!paste) return
Paste not found
; + + return ( +
+

+ {paste.title || 'Untitled'} +

+ +
+        {paste.content}
+      
+ +

+ Views: {paste.views} · Created at: {new Date(paste.createdAt).toLocaleString()} +

+
+ ); +} diff --git a/app/api/paste/[id]/route.ts b/app/api/paste/[id]/route.ts new file mode 100644 index 0000000..2c46997 --- /dev/null +++ b/app/api/paste/[id]/route.ts @@ -0,0 +1,68 @@ +import { prisma } from '@/lib/prisma'; +import bcrypt from 'bcryptjs'; +import { NextRequest, NextResponse } from 'next/server'; + +export const dynamic = 'force-dynamic'; +export const revalidate = 0; + +export async function POST( + request: NextRequest, + context: { params: { id: string } } +) { + const { params } = context; + const pasteId = params.id; + + const { password = '' } = await request.json(); + + if (!pasteId) { + return NextResponse.json({ error: 'Invalid ID' }, { status: 400 }); + } + + const paste = await prisma.paste.findUnique({ where: { id: pasteId } }); + if (!paste) { + return NextResponse.json({ error: 'Not found' }, { status: 404 }); + } + + if (paste.maxViews !== null && paste.views >= paste.maxViews) { + await prisma.paste.delete({ where: { id: paste.id } }); + return NextResponse.json({ error: 'Max views exceeded' }, { status: 404 }); + } + + if (paste.password) { + const valid = await bcrypt.compare(password, paste.password); + if (!valid) { + return NextResponse.json({ error: 'Invalid password' }, { status: 403 }); + } + } + + const updated = await prisma.paste.update({ + where: { id: paste.id }, + data: { views: { increment: 1 } }, + select: { + id: true, + title: true, + content: true, + createdAt: true, + views: true, + maxViews: true, + password: true, + }, + }); + + const payload = { + id: updated.id, + title: updated.title, + content: updated.content, + createdAt: updated.createdAt, + views: updated.views, + protected: !!updated.password, + }; + + if (updated.maxViews !== null && updated.views >= updated.maxViews) { + prisma.paste.delete({ where: { id: updated.id } }).catch(() => {}); + } + + return NextResponse.json(payload, { + headers: { 'Cache-Control': 'no-store' }, + }); +} diff --git a/app/api/paste/route.ts b/app/api/paste/route.ts new file mode 100644 index 0000000..a830ff7 --- /dev/null +++ b/app/api/paste/route.ts @@ -0,0 +1,61 @@ +import { prisma } from '@/lib/prisma'; +import bcrypt from 'bcryptjs'; +import { getServerSession } from 'next-auth'; +import { NextResponse } from 'next/server'; +import { authOptions } from '../auth/[...nextauth]/route'; + +import { customAlphabet } from 'nanoid'; +const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz0123456789', 7); + +export async function POST(req: Request) { + const body = await req.json(); + const session = await getServerSession(authOptions); + + let hashedPassword = null; + if (body.password) { + hashedPassword = await bcrypt.hash(body.password, 10); + } + + const paste = await prisma.paste.create({ + data: { + id: nanoid(), + title: body.title || null, + content: body.content, + password: hashedPassword, + maxViews: body.maxViews ? parseInt(body.maxViews, 10) : null, + createdBy: session?.user?.id ?? null, + size: Buffer.byteLength(body.content, 'utf8'), + }, + }); + + return NextResponse.json(paste); +} + +export async function DELETE(req: Request) { + const session = await getServerSession(authOptions); + if (!session?.user?.id) { + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); + } + + const { searchParams } = new URL(req.url); + const id = searchParams.get("id"); + + if (!id) { + return NextResponse.json({ error: "Missing id" }, { status: 400 }); + } + + try { + const paste = await prisma.paste.findUnique({ where: { id } }); + + if (!paste || paste.createdBy !== session.user.id) { + return NextResponse.json({ error: "Not found" }, { status: 404 }); + } + + await prisma.paste.delete({ where: { id } }); + + return NextResponse.json({ success: true }); + } catch (error) { + console.error(error); + return NextResponse.json({ error: "Server error" }, { status: 500 }); + } +} diff --git a/app/api/stats/route.ts b/app/api/stats/route.ts new file mode 100644 index 0000000..2ed2489 --- /dev/null +++ b/app/api/stats/route.ts @@ -0,0 +1,10 @@ +import { getDashboardStats } from '@/lib/stats'; +import { getServerSession } from 'next-auth'; +import { NextResponse } from 'next/server'; +import { authOptions } from '../auth/[...nextauth]/route'; + +export async function GET() { + const session = await getServerSession(authOptions); + const stats = await getDashboardStats(session?.user?.id); + return NextResponse.json(stats); +} diff --git a/app/api/user-pastes/route.ts b/app/api/user-pastes/route.ts new file mode 100644 index 0000000..d2490f0 --- /dev/null +++ b/app/api/user-pastes/route.ts @@ -0,0 +1,45 @@ +import { authOptions } from '@/app/api/auth/[...nextauth]/route'; +import { prisma } from '@/lib/prisma'; +import { getServerSession } from 'next-auth'; +import { NextResponse } from 'next/server'; + +export async function GET(req: Request) { + const session = await getServerSession(authOptions); + if (!session?.user?.id) { + return NextResponse.json([], { status: 401 }); + } + + const { searchParams } = new URL(req.url); + + const page = parseInt(searchParams.get('page') || '1', 10); + const perPage = parseInt(searchParams.get('perPage') || '10', 10); + const skip = (page - 1) * perPage; + + const search = searchParams.get('q') || ''; + + const filter = { + createdBy: session.user.id, + ...(search + ? { + title: { + contains: search, + mode: 'insensitive', + }, + } + : {}), + }; + + const [pastes, total] = await Promise.all([ + prisma.paste.findMany({ + where: filter, + orderBy: { createdAt: 'desc' }, + skip, + take: perPage, + }), + prisma.paste.count({ + where: filter, + }), + ]); + + return NextResponse.json({ pastes, total }); +} diff --git a/app/dashboard/layout.tsx b/app/dashboard/layout.tsx new file mode 100644 index 0000000..8b5de89 --- /dev/null +++ b/app/dashboard/layout.tsx @@ -0,0 +1,9 @@ +import type { Metadata } from 'next'; + +export const metadata: Metadata = { + title: 'AltBin - Dashboard', +}; + +export default function DashboardLayout({ children }: { children: React.ReactNode }) { + return <>{children}; +} \ No newline at end of file diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx new file mode 100644 index 0000000..e45ae71 --- /dev/null +++ b/app/dashboard/page.tsx @@ -0,0 +1,142 @@ +"use client"; + +import { useSession } from "next-auth/react"; +import { useRouter } from "next/navigation"; +import { useEffect, useState } from "react"; +import { toast } from "react-hot-toast"; + +import Header from "@/components/dashboard/Header"; +import LoadingDashboard from "@/components/dashboard/LoadingDashboard"; +import Pagination from "@/components/dashboard/Pagination"; +import PasteCard from "@/components/dashboard/PasteCard"; +import SearchBar from "@/components/dashboard/SearchBar"; +import Sidebar from "@/components/dashboard/Sidebar"; +import StatCard from "@/components/dashboard/StatCard"; +import ConfirmDeleteModal from "@/components/modals/ConfirmDeleteModal"; + +import { formatBytes } from "@/lib/format-bytes"; + +const PER_PAGE = 6; + +const dashboardIcons = { + clipboard: "https://cdn.lordicon.com/gvtjlyjf.json", + views: "https://cdn.lordicon.com/dicvhxpz.json", + calendar: "https://cdn.lordicon.com/uphbloed.json", + code: "https://cdn.lordicon.com/xqdfobxg.json", + storage: "https://cdn.lordicon.com/kikjlzqr.json", + chart: "https://cdn.lordicon.com/abwrkdvl.json", + flame: "https://cdn.lordicon.com/thtrcqvk.json", + file: "https://cdn.lordicon.com/fikcyfpp.json", + paste: "https://cdn.lordicon.com/hmpomorl.json", +}; + +export default function DashboardPage() { + const { data: session, status } = useSession(); + const router = useRouter(); + + const [searchTerm, setSearchTerm] = useState(""); + const [stats, setStats] = useState(null); + const [pastes, setPastes] = useState([]); + const [page, setPage] = useState(1); + const [totalPastes, setTotalPastes] = useState(0); + const [deleteId, setDeleteId] = useState(null); + + const handleDelete = async (id: string) => { + const res = await fetch(`/api/paste?id=${id}`, { method: "DELETE" }); + if (res.ok) { + setPastes((prev) => prev.filter((p) => p.id !== id)); + setTotalPastes((prev) => prev - 1); + toast.success("Paste deleted successfully 🚀"); + } else { + toast.error("Failed to delete paste ❌"); + } + }; + + useEffect(() => { + if (status === "unauthenticated") router.push("/"); + }, [status, router]); + + useEffect(() => { + if (status === "authenticated") { + const fetchStats = async () => { + const res = await fetch("/api/stats"); + if (res.ok) setStats(await res.json()); + }; + + const fetchPastes = async () => { + const res = await fetch( + `/api/user-pastes?page=${page}&perPage=${PER_PAGE}&q=${encodeURIComponent(searchTerm)}` + ); + if (!res.ok) return setPastes([]); + try { + const data = await res.json(); + setPastes(data.pastes ?? []); + setTotalPastes(data.total ?? 0); + } catch { + setPastes([]); + setTotalPastes(0); + } + }; + + fetchStats(); + fetchPastes(); + } + }, [status, page, searchTerm]); + + if (status === "loading" || !stats) return ; + + const totalPages = Math.ceil(totalPastes / PER_PAGE); + + return ( +
+ + +
+
+ + {/* Stats */} +
+ {[ + { label: "Total Pastes", value: stats.totalPastes, icon: dashboardIcons.clipboard }, + { label: "Total Views", value: stats.totalViews, icon: dashboardIcons.views }, + { label: "Last 30 Days", value: stats.recentPastes, icon: dashboardIcons.calendar }, + { label: "API Usage", value: stats.apiUsage, icon: dashboardIcons.code }, + { label: "Storage Used", value: formatBytes(stats.storageUsed), icon: dashboardIcons.storage }, + { label: "Avg Views", value: stats.avgViews, icon: dashboardIcons.chart }, + { label: "Most Viewed", value: stats.mostViewed, icon: dashboardIcons.flame }, + { label: "Avg Paste Size", value: formatBytes(stats.avgSize), icon: dashboardIcons.file }, + ].map((stat, i) => ( + + ))} +
+ + { setSearchTerm(v); setPage(1); }} /> + + {/* Pastes */} +

Your Pastes

+ {pastes.length === 0 ? ( +
No pastes found.
+ ) : ( +
+ {pastes.map((paste) => ( + + ))} +
+ )} + + + + !open && setDeleteId(null)} + onConfirm={() => { if (deleteId) { handleDelete(deleteId); setDeleteId(null); } }} + /> +
+
+ ); +} \ No newline at end of file diff --git a/app/favicon.ico b/app/favicon.ico deleted file mode 100644 index 718d6fea4835ec2d246af9800eddb7ffb276240c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25931 zcmeHv30#a{`}aL_*G&7qml|y<+KVaDM2m#dVr!KsA!#An?kSQM(q<_dDNCpjEux83 zLb9Z^XxbDl(w>%i@8hT6>)&Gu{h#Oeyszu?xtw#Zb1mO{pgX9699l+Qppw7jXaYf~-84xW z)w4x8?=youko|}Vr~(D$UXIbiXABHh`p1?nn8Po~fxRJv}|0e(BPs|G`(TT%kKVJAdg5*Z|x0leQq0 zkdUBvb#>9F()jo|T~kx@OM8$9wzs~t2l;K=woNssA3l6|sx2r3+kdfVW@e^8e*E}v zA1y5{bRi+3Z`uD3{F7LgFJDdvm;nJilkzDku>BwXH(8ItVCXk*-lSJnR?-2UN%hJ){&rlvg`CDTj z)Bzo!3v7Ou#83zEDEFcKt(f1E0~=rqeEbTnMvWR#{+9pg%7G8y>u1OVRUSoox-ovF z2Ydma(;=YuBY(eI|04{hXzZD6_f(v~H;C~y5=DhAC{MMS>2fm~1H_t2$56pc$NH8( z5bH|<)71dV-_oCHIrzrT`2s-5w_+2CM0$95I6X8p^r!gHp+j_gd;9O<1~CEQQGS8) zS9Qh3#p&JM-G8rHekNmKVewU;pJRcTAog68KYo^dRo}(M>36U4Us zfgYWSiHZL3;lpWT=zNAW>Dh#mB!_@Lg%$ms8N-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FD5aoS4g~7#6NR^ma7-!>mHuJfY5kTe6PpNNKC9GGRiu^L31uG z$7v`*JknQHsYB!Tm_W{a32TM099djW%5e+j0Ve_ct}IM>XLF1Ap+YvcrLV=|CKo6S zb+9Nl3_YdKP6%Cxy@6TxZ>;4&nTneadr z_ES90ydCev)LV!dN=#(*f}|ZORFdvkYBni^aLbUk>BajeWIOcmHP#8S)*2U~QKI%S zyrLmtPqb&TphJ;>yAxri#;{uyk`JJqODDw%(Z=2`1uc}br^V%>j!gS)D*q*f_-qf8&D;W1dJgQMlaH5er zN2U<%Smb7==vE}dDI8K7cKz!vs^73o9f>2sgiTzWcwY|BMYHH5%Vn7#kiw&eItCqa zIkR2~Q}>X=Ar8W|^Ms41Fm8o6IB2_j60eOeBB1Br!boW7JnoeX6Gs)?7rW0^5psc- zjS16yb>dFn>KPOF;imD}e!enuIniFzv}n$m2#gCCv4jM#ArwlzZ$7@9&XkFxZ4n!V zj3dyiwW4Ki2QG{@i>yuZXQizw_OkZI^-3otXC{!(lUpJF33gI60ak;Uqitp74|B6I zgg{b=Iz}WkhCGj1M=hu4#Aw173YxIVbISaoc z-nLZC*6Tgivd5V`K%GxhBsp@SUU60-rfc$=wb>zdJzXS&-5(NRRodFk;Kxk!S(O(a0e7oY=E( zAyS;Ow?6Q&XA+cnkCb{28_1N8H#?J!*$MmIwLq^*T_9-z^&UE@A(z9oGYtFy6EZef LrJugUA?W`A8`#=m diff --git a/app/globals.css b/app/globals.css index e3734be..95510be 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1,42 +1,22 @@ -:root { - --background: #ffffff; - --foreground: #171717; +@import "tailwindcss"; + +.hljs, +code[class*="language-"], +pre[class*="language-"] { + background: transparent !important; } -@media (prefers-color-scheme: dark) { - :root { - --background: #0a0a0a; - --foreground: #ededed; - } -} - -html, -body { - max-width: 100vw; - overflow-x: hidden; -} - -body { - color: var(--foreground); - background: var(--background); - font-family: Arial, Helvetica, sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -* { - box-sizing: border-box; - padding: 0; - margin: 0; -} - -a { - color: inherit; - text-decoration: none; -} - -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; +/* ➡️ Hors du @layer */ +code[class*="language-"], +pre[class*="language-"] { + white-space: pre-wrap !important; + word-break: break-word !important; +} + +@layer utilities { + .neon-border { + box-shadow: + 0 0 0 1.5px oklch(0.65 0.2 250 / 0.5), + 0 0 10px oklch(0.65 0.2 250 / 0.2); } } diff --git a/app/layout.tsx b/app/layout.tsx index 42fc323..45243d0 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,32 +1,52 @@ -import type { Metadata } from "next"; -import { Geist, Geist_Mono } from "next/font/google"; -import "./globals.css"; +import AuthProvider from '@/components/SessionProvider'; +import ToasterProvider from '@/components/ui/ToasterProvider'; +import { ReactNode } from 'react'; +import './globals.css'; -const geistSans = Geist({ - variable: "--font-geist-sans", - subsets: ["latin"], -}); - -const geistMono = Geist_Mono({ - variable: "--font-geist-mono", - subsets: ["latin"], -}); +import type { Metadata, Viewport } from "next"; export const metadata: Metadata = { - title: "Create Next App", - description: "Generated by create next app", + title: "AltBin - Modern text and code sharing", + description: + "AltBin is a fast and modern pastebin for sharing text and code snippets with ease. Secure, minimal, and developer-friendly.", + metadataBase: new URL("https://altbin.dev"), + openGraph: { + title: "AltBin - Modern text and code sharing", + description: + "Easily share text and code snippets with AltBin. A sleek and secure pastebin for developers.", + url: "https://altbin.dev", + siteName: "AltBin", + images: ["/og-image.png"], + locale: "en_US", + type: "website", + }, + twitter: { + card: "summary_large_image", + title: "AltBin - Modern text and code sharing", + description: + "Share and manage text/code snippets effortlessly with AltBin. Secure and developer-friendly.", + images: ["/og-image.png"], + creator: "@AltBinApp", + }, + icons: { + icon: "/favicon.png", + shortcut: "/favicon.png", + }, }; -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { +export const viewport: Viewport = { + themeColor: "#0f172a", +}; + +export default function RootLayout({ children }: { children: ReactNode }) { return ( - - {children} + + + + {children} + ); -} +} \ No newline at end of file diff --git a/app/not-found.tsx b/app/not-found.tsx new file mode 100644 index 0000000..a2d0303 --- /dev/null +++ b/app/not-found.tsx @@ -0,0 +1,54 @@ +'use client'; + +import { motion } from 'framer-motion'; +import { Plus } from 'lucide-react'; +import { useRouter } from 'next/navigation'; + +export default function NotFoundPage() { + const router = useRouter(); + + return ( +
+ +

+ 404 +

+ +

+ Page Not Found +

+ +

+ The paste you're looking for might have been deleted, expired, or the + URL is incorrect. +

+ + router.push('/')} + className="cursor-pointer group inline-flex items-center gap-2 px-6 py-3 rounded-xl text-base font-medium + text-white bg-gradient-to-r from-blue-600 to-blue-500 shadow-lg shadow-blue-500/30 + hover:shadow-blue-500/50 transition-all duration-300 focus:outline-none focus:ring-2 focus:ring-blue-400/60" + > + + Create New Paste + +
+
+ ); +} diff --git a/app/page.module.css b/app/page.module.css deleted file mode 100644 index 58c71af..0000000 --- a/app/page.module.css +++ /dev/null @@ -1,167 +0,0 @@ -.page { - --gray-rgb: 0, 0, 0; - --gray-alpha-200: rgba(var(--gray-rgb), 0.08); - --gray-alpha-100: rgba(var(--gray-rgb), 0.05); - - --button-primary-hover: #383838; - --button-secondary-hover: #f2f2f2; - - display: grid; - grid-template-rows: 20px 1fr 20px; - align-items: center; - justify-items: center; - min-height: 100svh; - padding: 80px; - gap: 64px; - font-family: var(--font-geist-sans); -} - -@media (prefers-color-scheme: dark) { - .page { - --gray-rgb: 255, 255, 255; - --gray-alpha-200: rgba(var(--gray-rgb), 0.145); - --gray-alpha-100: rgba(var(--gray-rgb), 0.06); - - --button-primary-hover: #ccc; - --button-secondary-hover: #1a1a1a; - } -} - -.main { - display: flex; - flex-direction: column; - gap: 32px; - grid-row-start: 2; -} - -.main ol { - font-family: var(--font-geist-mono); - padding-left: 0; - margin: 0; - font-size: 14px; - line-height: 24px; - letter-spacing: -0.01em; - list-style-position: inside; -} - -.main li:not(:last-of-type) { - margin-bottom: 8px; -} - -.main code { - font-family: inherit; - background: var(--gray-alpha-100); - padding: 2px 4px; - border-radius: 4px; - font-weight: 600; -} - -.ctas { - display: flex; - gap: 16px; -} - -.ctas a { - appearance: none; - border-radius: 128px; - height: 48px; - padding: 0 20px; - border: 1px solid transparent; - transition: - background 0.2s, - color 0.2s, - border-color 0.2s; - cursor: pointer; - display: flex; - align-items: center; - justify-content: center; - font-size: 16px; - line-height: 20px; - font-weight: 500; -} - -a.primary { - background: var(--foreground); - color: var(--background); - gap: 8px; -} - -a.secondary { - border-color: var(--gray-alpha-200); - min-width: 158px; -} - -.footer { - grid-row-start: 3; - display: flex; - gap: 24px; -} - -.footer a { - display: flex; - align-items: center; - gap: 8px; -} - -.footer img { - flex-shrink: 0; -} - -/* Enable hover only on non-touch devices */ -@media (hover: hover) and (pointer: fine) { - a.primary:hover { - background: var(--button-primary-hover); - border-color: transparent; - } - - a.secondary:hover { - background: var(--button-secondary-hover); - border-color: transparent; - } - - .footer a:hover { - text-decoration: underline; - text-underline-offset: 4px; - } -} - -@media (max-width: 600px) { - .page { - padding: 32px; - padding-bottom: 80px; - } - - .main { - align-items: center; - } - - .main ol { - text-align: center; - } - - .ctas { - flex-direction: column; - } - - .ctas a { - font-size: 14px; - height: 40px; - padding: 0 16px; - } - - a.secondary { - min-width: auto; - } - - .footer { - flex-wrap: wrap; - align-items: center; - justify-content: center; - } -} - -@media (prefers-color-scheme: dark) { - .logo { - filter: invert(); - } -} diff --git a/app/page.tsx b/app/page.tsx index 52bd15e..ac5584d 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,95 +1,11 @@ -import Image from "next/image"; -import styles from "./page.module.css"; +'use client'; -export default function Home() { +import PasteForm from '@/components/PasteForm'; + +export default function HomePage() { return ( -
-
- Next.js logo -
    -
  1. - Get started by editing app/page.tsx. -
  2. -
  3. Save and see your changes instantly.
  4. -
- - -
- +
+
); } diff --git a/app/utils/fetcher.ts b/app/utils/fetcher.ts new file mode 100644 index 0000000..bffe8de --- /dev/null +++ b/app/utils/fetcher.ts @@ -0,0 +1,4 @@ +export async function fetchPastes() { + const res = await fetch('/api/paste'); + return await res.json(); +} diff --git a/components/PasteForm.tsx b/components/PasteForm.tsx new file mode 100644 index 0000000..b6ceddf --- /dev/null +++ b/components/PasteForm.tsx @@ -0,0 +1,76 @@ +"use client"; + +import AuthSection from "@/components/paste-form/AuthSection"; +import Editor from "@/components/paste-form/Editor"; +import SidebarPanel from "@/components/paste-form/SidebarPanel"; +import { useSession } from "next-auth/react"; +import { useRouter } from "next/navigation"; +import { useCallback, useEffect, useState } from "react"; + +export default function PasteForm() { + const router = useRouter(); + const { data: session } = useSession(); + + const [title, setTitle] = useState(""); + const [content, setContent] = useState(""); + const [password, setPassword] = useState(""); + const [maxViews, setMaxViews] = useState(""); + const [isSaving, setIsSaving] = useState(false); + const [advanced, setAdvanced] = useState(true); + + const handleSave = useCallback(async () => { + if (!content.trim()) return; + setIsSaving(true); + + const res = await fetch("/api/paste", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + title: title.trim() || null, + content, + password: password || null, + maxViews: maxViews ? parseInt(maxViews, 10) : null, + createdBy: session?.user?.id || null, + }), + }); + + if (res.ok) { + const data = await res.json(); + router.push(`/${data.id}`); + } + + setIsSaving(false); + }, [title, content, password, maxViews, session, router]); + + // Raccourci clavier Ctrl+S + useEffect(() => { + const onKeyDown = (e: KeyboardEvent) => { + if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "s") { + e.preventDefault(); + if (!isSaving && content.trim()) handleSave(); + } + }; + window.addEventListener("keydown", onKeyDown); + return () => window.removeEventListener("keydown", onKeyDown); + }, [handleSave, isSaving, content]); + + return ( +
+ + + +
+ ); +} \ No newline at end of file diff --git a/components/SessionProvider.tsx b/components/SessionProvider.tsx new file mode 100644 index 0000000..69051d0 --- /dev/null +++ b/components/SessionProvider.tsx @@ -0,0 +1,8 @@ +'use client'; + +import { SessionProvider } from 'next-auth/react'; +import { ReactNode } from 'react'; + +export default function AuthProvider({ children }: { children: ReactNode }) { + return {children}; +} \ No newline at end of file diff --git a/components/dashboard/Header.tsx b/components/dashboard/Header.tsx new file mode 100644 index 0000000..7d61cb7 --- /dev/null +++ b/components/dashboard/Header.tsx @@ -0,0 +1,40 @@ +"use client"; + +import { motion } from "framer-motion"; +import { useRouter } from "next/navigation"; +import { useRef } from "react"; +import LordIcon from "./LordIcon"; + +export default function Header({ user }: { user?: string | null }) { + const plusIconRef = useRef(null); + const router = useRouter(); + + return ( +
+

+ Welcome back, {user || "User"} +

+ + router.push("/")} + className="cursor-pointer flex items-center gap-2 px-6 py-3 rounded-xl text-base font-medium + text-white bg-gradient-to-r from-blue-600 to-blue-500 shadow-lg shadow-blue-500/30 + hover:shadow-blue-500/50 transition-all duration-300" + onMouseEnter={() => plusIconRef.current?.playFromBeginning()} + onMouseLeave={() => plusIconRef.current?.goToFirstFrame()} + > +
+ +
+ Create New Paste +
+
+ ); +} \ No newline at end of file diff --git a/components/dashboard/LoadingDashboard.tsx b/components/dashboard/LoadingDashboard.tsx new file mode 100644 index 0000000..e522eb0 --- /dev/null +++ b/components/dashboard/LoadingDashboard.tsx @@ -0,0 +1,77 @@ +"use client"; + +export default function LoadingDashboard() { + const StatSkeleton = () => ( +
+
+
+
+
+
+
+
+
+ ); + + const PasteSkeleton = () => ( +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ); + + return ( +
+ {/* Sidebar skeleton */} + + +
+ {/* Header skeleton + spinner */} +
+
+
+
+ Loading dashboard... +
+
+ + {/* Stat cards skeleton */} +
+ {Array.from({ length: 8 }).map((_, i) => ( + + ))} +
+ + {/* Search skeleton */} +
+
+
+ + {/* Pastes skeleton grid */} +
+ {Array.from({ length: 6 }).map((_, i) => ( + + ))} +
+
+
+ ); +} \ No newline at end of file diff --git a/components/dashboard/LordIcon.tsx b/components/dashboard/LordIcon.tsx new file mode 100644 index 0000000..9553efc --- /dev/null +++ b/components/dashboard/LordIcon.tsx @@ -0,0 +1,20 @@ +"use client"; + +import { Player } from "@lordicon/react"; +import { forwardRef, useEffect, useState } from "react"; + +const LordIcon = forwardRef(function LordIcon( + { url, size = 28, colorize = "#3b82f6" }: { url: string; size?: number; colorize?: string }, + ref: any +) { + const [iconData, setIconData] = useState(null); + + useEffect(() => { + fetch(url).then((res) => res.json()).then(setIconData); + }, [url]); + + if (!iconData) return null; + return ; +}); + +export default LordIcon; diff --git a/components/dashboard/Pagination.tsx b/components/dashboard/Pagination.tsx new file mode 100644 index 0000000..c530a13 --- /dev/null +++ b/components/dashboard/Pagination.tsx @@ -0,0 +1,31 @@ +"use client"; + +export default function Pagination({ + totalPages, + currentPage, + onPageChange, +}: { + totalPages: number; + currentPage: number; + onPageChange: (page: number) => void; +}) { + if (totalPages <= 1) return null; + + return ( +
+ {Array.from({ length: totalPages }, (_, i) => ( + + ))} +
+ ); +} \ No newline at end of file diff --git a/components/dashboard/PasteCard.tsx b/components/dashboard/PasteCard.tsx new file mode 100644 index 0000000..20deecd --- /dev/null +++ b/components/dashboard/PasteCard.tsx @@ -0,0 +1,60 @@ +"use client"; + +import { motion } from "framer-motion"; +import { useRef } from "react"; +import LordIcon from "./LordIcon"; + +export default function PasteCard({ + paste, + onDelete, + pasteIconUrl, +}: { + paste: any; + onDelete: (id: string) => void; + pasteIconUrl: string; +}) { + const pasteIconRef = useRef(null); + + return ( + pasteIconRef.current?.playFromBeginning()} + onMouseLeave={() => pasteIconRef.current?.goToFirstFrame()} + > +
+
+ +
+
+ {paste.title || 'Untitled'} +
+
+
+ {paste.content || 'No content'} +
+
+ {new Date(paste.createdAt).toLocaleString()} + + {paste.views} views + +
+
+ + View + + +
+
+ ); +} \ No newline at end of file diff --git a/components/dashboard/SearchBar.tsx b/components/dashboard/SearchBar.tsx new file mode 100644 index 0000000..d14ec35 --- /dev/null +++ b/components/dashboard/SearchBar.tsx @@ -0,0 +1,20 @@ +"use client"; + +import { Search } from "lucide-react"; + +export default function SearchBar({ value, onChange }: { value: string; onChange: (v: string) => void }) { + return ( +
+ + onChange(e.target.value)} + className="cursor-text w-full pl-10 pr-4 py-2 rounded-xl bg-[#0f1320]/70 text-white + placeholder:text-neutral-500 outline-none ring-1 ring-white/10 + focus:ring-2 focus:ring-blue-500/50 transition-all" + /> +
+ ); +} diff --git a/components/dashboard/Sidebar.tsx b/components/dashboard/Sidebar.tsx new file mode 100644 index 0000000..6b73dcd --- /dev/null +++ b/components/dashboard/Sidebar.tsx @@ -0,0 +1,51 @@ +"use client"; + +import LogoutButton from "@/components/ui/LogoutButton"; +import { FileText } from "lucide-react"; +import Link from "next/link"; +import { usePathname } from "next/navigation"; + +export default function Sidebar() { + const pathname = usePathname(); + + const navItems = [ + { label: "My Pastes", href: "/dashboard", icon: FileText }, + ]; + + return ( + + ); +} \ No newline at end of file diff --git a/components/dashboard/StatCard.tsx b/components/dashboard/StatCard.tsx new file mode 100644 index 0000000..f156fc1 --- /dev/null +++ b/components/dashboard/StatCard.tsx @@ -0,0 +1,36 @@ +"use client"; + +import { motion } from "framer-motion"; +import { useRef } from "react"; +import LordIcon from "./LordIcon"; + +export default function StatCard({ + label, + value, + icon, +}: { + label: string; + value: any; + icon: string; +}) { + const iconRef = useRef(null); + + return ( + iconRef.current?.playFromBeginning()} + onMouseLeave={() => iconRef.current?.goToFirstFrame()} + > +
+
+ +
+
+
{label}
+
{value}
+
+
+
+ ); +} diff --git a/components/modals/ConfirmDeleteModal.tsx b/components/modals/ConfirmDeleteModal.tsx new file mode 100644 index 0000000..201ca2f --- /dev/null +++ b/components/modals/ConfirmDeleteModal.tsx @@ -0,0 +1,75 @@ +"use client"; + +import * as Dialog from "@radix-ui/react-dialog"; +import { motion } from "framer-motion"; +import { X } from "lucide-react"; + +interface ConfirmDeleteModalProps { + open: boolean; + onOpenChange: (open: boolean) => void; + onConfirm: () => void; + title?: string; + description?: string; +} + +export default function ConfirmDeleteModal({ + open, + onOpenChange, + onConfirm, + title = "Delete paste?", + description = "This action cannot be undone. Are you sure you want to delete this paste?", +}: ConfirmDeleteModalProps) { + return ( + + + {/* Overlay noir semi-transparent */} + + + {/* Contenu centré */} + +
+ + {/* Header */} +
+ + {title} + + + + +
+ + {/* Description */} + + {description} + + + {/* Actions */} +
+ + + + +
+
+
+
+
+
+ ); +} \ No newline at end of file diff --git a/components/paste-form/AuthSection.tsx b/components/paste-form/AuthSection.tsx new file mode 100644 index 0000000..249e433 --- /dev/null +++ b/components/paste-form/AuthSection.tsx @@ -0,0 +1,61 @@ +"use client"; + +import { Info, Shield } from "lucide-react"; +import { signIn, signOut, useSession } from "next-auth/react"; + +export default function AuthSection() { + const { data: session, status } = useSession(); + + if (status === "loading") return null; + + return ( +
+ {!session?.user ? ( +
+ {/* Bouton About */} + + + About + + + {/* Bouton Login */} + +
+ ) : ( +
+
+ + Connected as + + {session.user.name || "User"} + +
+ +
+ + Dashboard + + +
+
+ )} +
+ ); +} \ No newline at end of file diff --git a/components/paste-form/Editor.tsx b/components/paste-form/Editor.tsx new file mode 100644 index 0000000..8639806 --- /dev/null +++ b/components/paste-form/Editor.tsx @@ -0,0 +1,48 @@ +"use client"; + +import { ChevronRight } from "lucide-react"; +import { useRef } from "react"; + +interface EditorProps { + content: string; + setContent: (v: string) => void; +} + +export default function Editor({ content, setContent }: EditorProps) { + const textareaRef = useRef(null); + const lineNumbersRef = useRef(null); + + const handleScroll = () => { + if (lineNumbersRef.current && textareaRef.current) { + lineNumbersRef.current.scrollTop = textareaRef.current.scrollTop; + } + }; + + return ( +
+ {/* Numéros de lignes */} +
+ {content.split("\n").map((_, i) => ( +
+ {i === 0 && } + {i + 1} +
+ ))} +
+ + {/* Zone d’édition */} +