mongo fix
This commit is contained in:
+102
-52
@@ -1,67 +1,117 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import Link from "next/link";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import {
|
||||
Card,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
CardDescription,
|
||||
CardContent,
|
||||
} from "@/components/ui/card";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { PageHeader } from "@/components/page-header";
|
||||
import { BookOpen, FileText, BookA } from "lucide-react";
|
||||
|
||||
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`;
|
||||
}
|
||||
const allowRtf = process.env.ALLOW_RTF === "true";
|
||||
|
||||
export default function Home() {
|
||||
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>
|
||||
<h1 className="text-2xl font-bold text-foreground">
|
||||
RTF Document Viewer
|
||||
</h1>
|
||||
<h1 className="text-3xl font-bold text-foreground">Prabhupāda Says</h1>
|
||||
<p className="mt-1 text-muted-foreground">
|
||||
{files.length} documents available
|
||||
Browse the books and teachings of His Divine Grace A.C. Bhaktivedanta
|
||||
Swami Prabhupāda
|
||||
</p>
|
||||
</PageHeader>
|
||||
|
||||
<main className="max-w-3xl 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={`/view/${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>
|
||||
<div className="grid gap-4">
|
||||
{/* Structured Books (JSON) */}
|
||||
<Link href="/books" className="block group">
|
||||
<Card className="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">
|
||||
<BookOpen className="size-5" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<CardTitle className="text-xl font-bold">Books</CardTitle>
|
||||
<CardDescription>
|
||||
Structured verse-by-verse editions
|
||||
</CardDescription>
|
||||
</div>
|
||||
<Badge variant="secondary">Recommended</Badge>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Bhagavad-gītā, Śrīmad-Bhāgavatam, and Caitanya-caritāmṛta with
|
||||
Devanagari, Bengali, transliteration, synonyms, translations
|
||||
& purports. Extraction is still in progress but offers a
|
||||
refined, searchable reading experience.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
|
||||
{/* Glossary */}
|
||||
<Link href="/glossary" className="block group">
|
||||
<Card className="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">
|
||||
<BookA className="size-5" />
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<CardTitle className="text-xl font-bold">
|
||||
Glossary
|
||||
</CardTitle>
|
||||
<CardDescription>
|
||||
2,700+ Sanskrit & Vedic terms
|
||||
</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
A comprehensive, searchable glossary of Sanskrit and Vedic
|
||||
terms from Śrīla Prabhupāda's books — definitions,
|
||||
cross-references, and encyclopedic entries.
|
||||
</p>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Link>
|
||||
|
||||
{/* RTF Document Viewer — only visible when ALLOW_RTF=true */}
|
||||
{allowRtf && (
|
||||
<Link href="/rtfs" className="block group">
|
||||
<Card className="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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user