chore: repo cleanup
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
/**
|
||||
* GET /api/verify-access
|
||||
*
|
||||
* Returns whether password protection is enabled at runtime.
|
||||
* This is called by the PasswordGate client component on mount
|
||||
* to determine if it should show the password prompt.
|
||||
*/
|
||||
export async function GET() {
|
||||
const accessKey = process.env.ACCESS_KEY;
|
||||
const enabled = !!accessKey;
|
||||
return NextResponse.json({ enabled });
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /api/verify-access
|
||||
*
|
||||
* Validates a submitted key against the ACCESS_KEY environment variable.
|
||||
* Returns { valid: true } if matched, { valid: false } otherwise.
|
||||
*
|
||||
* If ACCESS_KEY is not set, all keys are rejected (locked by default).
|
||||
*/
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const submitted = body?.key;
|
||||
|
||||
if (typeof submitted !== "string" || !submitted) {
|
||||
return NextResponse.json({ valid: false }, { status: 400 });
|
||||
}
|
||||
|
||||
const accessKey = process.env.ACCESS_KEY;
|
||||
|
||||
// If no ACCESS_KEY is configured, reject everything
|
||||
if (!accessKey) {
|
||||
return NextResponse.json({ valid: false }, { status: 403 });
|
||||
}
|
||||
|
||||
const valid = submitted === accessKey;
|
||||
return NextResponse.json({ valid }, { status: valid ? 200 : 401 });
|
||||
} catch {
|
||||
return NextResponse.json({ valid: false }, { status: 400 });
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import { PageHeader } from "@/components/page-header";
|
||||
import { Logo } from "@/components/logo";
|
||||
import {
|
||||
BookOpen,
|
||||
FileText,
|
||||
BookA,
|
||||
PenLine,
|
||||
FileStack,
|
||||
@@ -22,8 +21,6 @@ import {
|
||||
Mic,
|
||||
} from "lucide-react";
|
||||
|
||||
const allowRtf = process.env.ALLOW_RTF === "true";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
@@ -283,38 +280,6 @@ export default function Home() {
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
|
||||
{/* RTF Document Viewer — only visible when ALLOW_RTF=true */}
|
||||
{allowRtf && (
|
||||
<Link href="/rtfs" className="block group h-full">
|
||||
<Card className="h-full transition-all group-hover:shadow-md group-hover:ring-foreground/20">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex items-center justify-center size-10 rounded-lg bg-primary/10 text-primary">
|
||||
<FileText className="size-5" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<CardTitle className="text-xl font-bold">
|
||||
RTF Document Viewer
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
17 original documents from the original unedited
|
||||
Vedabase
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Browse the complete original RTF files — Bhagavad-gītā,
|
||||
Śrīmad-Bhāgavatam, Caitanya-caritāmṛta, Śrī Īśopaniṣad,
|
||||
letters, magazines, and more — rendered in-browser with
|
||||
their original custom fonts.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
function formatTitle(slug: string) {
|
||||
return slug.replace(/-/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
}
|
||||
|
||||
export default async function ViewPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string }>;
|
||||
}) {
|
||||
if (process.env.ALLOW_RTF !== "true") notFound();
|
||||
|
||||
const { slug } = await params;
|
||||
const htmlPath = path.join(process.cwd(), "public/html", `${slug}.html`);
|
||||
|
||||
if (!fs.existsSync(htmlPath)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col bg-background">
|
||||
<header className="border-b border-border bg-card px-6 py-4 flex items-center gap-4 shrink-0">
|
||||
<Link
|
||||
href="/rtfs"
|
||||
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
← RTF Documents
|
||||
</Link>
|
||||
<h1 className="text-lg font-semibold text-foreground">
|
||||
{formatTitle(slug)}
|
||||
</h1>
|
||||
</header>
|
||||
<main className="flex-1">
|
||||
<iframe
|
||||
src={`/html/${slug}.html`}
|
||||
className="w-full h-[calc(100vh-65px)] border-0"
|
||||
title={formatTitle(slug)}
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { PageHeader } from "@/components/page-header";
|
||||
|
||||
function formatTitle(filename: string) {
|
||||
return filename
|
||||
.replace(/\.RTF$/i, "")
|
||||
.replace(/-/g, " ")
|
||||
.replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
}
|
||||
|
||||
function formatSize(bytes: number) {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
export default function RtfsPage() {
|
||||
if (process.env.ALLOW_RTF !== "true") notFound();
|
||||
|
||||
const rtfDir = path.join(process.cwd(), "public/rtfs");
|
||||
const files = fs.readdirSync(rtfDir).filter((f) => /\.rtf$/i.test(f));
|
||||
|
||||
const fileList = files.map((f) => {
|
||||
const stat = fs.statSync(path.join(rtfDir, f));
|
||||
return {
|
||||
filename: f,
|
||||
slug: f.replace(/\.RTF$/i, ""),
|
||||
title: formatTitle(f),
|
||||
size: stat.size,
|
||||
};
|
||||
});
|
||||
|
||||
fileList.sort((a, b) => a.title.localeCompare(b.title));
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-background">
|
||||
<PageHeader>
|
||||
<Link
|
||||
href="/"
|
||||
className="text-sm text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
← Home
|
||||
</Link>
|
||||
<h1 className="mt-3 text-2xl font-bold text-foreground">
|
||||
RTF Document Viewer
|
||||
</h1>
|
||||
<p className="mt-1 text-muted-foreground">
|
||||
{files.length} original documents from the pre-1978 Vedabase
|
||||
</p>
|
||||
</PageHeader>
|
||||
<main className="max-w-5xl mx-auto px-6 py-8">
|
||||
<Card className="py-0">
|
||||
<CardContent className="p-0 divide-y divide-border">
|
||||
{fileList.map((file) => (
|
||||
<Link
|
||||
key={file.slug}
|
||||
href={`/rtfs/${file.slug}`}
|
||||
className="flex items-center justify-between px-5 py-4 hover:bg-muted transition-colors first:rounded-t-xl last:rounded-b-xl"
|
||||
>
|
||||
<span className="font-medium text-foreground">
|
||||
{file.title}
|
||||
</span>
|
||||
<span className="text-sm text-muted-foreground shrink-0 ml-4">
|
||||
{formatSize(file.size)}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user