Features added: - Database schema for pages and media files with content types (Rich Text, HTML, Markdown) - Admin API routes for full page CRUD operations - Image upload functionality with file management - Rich text editor using TinyMCE with image insertion - Admin interface for creating/editing pages with SEO options - Dynamic navigation and footer integration - Public page display routes with proper SEO metadata - Support for featured images and content excerpts Admin features: - Create/edit/delete pages with rich content editor - Upload and manage images through media library - Configure pages to appear in navigation or footer - Set page status (Draft, Published, Archived) - SEO title and description management - Real-time preview of content changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
184 lines
4.6 KiB
TypeScript
184 lines
4.6 KiB
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
// Sample Bible data - Genesis 1:1-5 for demonstration
|
|
const sampleBibleData = {
|
|
books: [
|
|
{
|
|
id: 1,
|
|
name: "Geneza",
|
|
testament: "Vechiul Testament",
|
|
chapters: [
|
|
{
|
|
number: 1,
|
|
verses: [
|
|
{
|
|
number: 1,
|
|
text: "La început Dumnezeu a făcut cerurile și pământul."
|
|
},
|
|
{
|
|
number: 2,
|
|
text: "Pământul era pustiu și gol; peste adâncuri era întuneric, și Duhul lui Dumnezeu Se mișca pe deasupra apelor."
|
|
},
|
|
{
|
|
number: 3,
|
|
text: "Dumnezeu a zis: \"Să fie lumină!\" Și a fost lumină."
|
|
},
|
|
{
|
|
number: 4,
|
|
text: "Dumnezeu a văzut că lumina era bună; și Dumnezeu a despărțit lumina de întuneric."
|
|
},
|
|
{
|
|
number: 5,
|
|
text: "Dumnezeu a numit lumina zi, iar întunericul l-a numit noapte. Astfel, a fost o seară, și a fost o dimineață: ziua întâi."
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
id: 2,
|
|
name: "Exodul",
|
|
testament: "Vechiul Testament",
|
|
chapters: [
|
|
{
|
|
number: 1,
|
|
verses: [
|
|
{
|
|
number: 1,
|
|
text: "Iată numele fiilor lui Israel care au intrat în Egipt cu Iacob și au intrat fiecare cu familia lui:"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
id: 40,
|
|
name: "Matei",
|
|
testament: "Noul Testament",
|
|
chapters: [
|
|
{
|
|
number: 1,
|
|
verses: [
|
|
{
|
|
number: 1,
|
|
text: "Cartea neamului lui Isus Hristos, fiul lui David, fiul lui Avraam."
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
|
|
async function importBible() {
|
|
console.log('Starting Bible import...')
|
|
|
|
try {
|
|
for (const book of sampleBibleData.books) {
|
|
console.log(`Importing ${book.name}...`)
|
|
|
|
// Create book
|
|
await prisma.bibleBook.upsert({
|
|
where: { id: book.id },
|
|
update: {},
|
|
create: {
|
|
id: book.id,
|
|
name: book.name,
|
|
testament: book.testament,
|
|
orderNum: book.id
|
|
}
|
|
})
|
|
|
|
// Create chapters and verses
|
|
for (const chapter of book.chapters) {
|
|
const createdChapter = await prisma.bibleChapter.upsert({
|
|
where: {
|
|
bookId_chapterNum: {
|
|
bookId: book.id,
|
|
chapterNum: chapter.number
|
|
}
|
|
},
|
|
update: {},
|
|
create: {
|
|
bookId: book.id,
|
|
chapterNum: chapter.number
|
|
}
|
|
})
|
|
|
|
// Create verses
|
|
for (const verse of chapter.verses) {
|
|
await prisma.bibleVerse.upsert({
|
|
where: {
|
|
chapterId_verseNum_version: {
|
|
chapterId: createdChapter.id,
|
|
verseNum: verse.number,
|
|
version: 'RO'
|
|
}
|
|
},
|
|
update: {},
|
|
create: {
|
|
chapterId: createdChapter.id,
|
|
verseNum: verse.number,
|
|
text: verse.text,
|
|
version: 'RO'
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
console.log('Bible import completed successfully!')
|
|
|
|
// Create search function after import
|
|
await prisma.$executeRaw`
|
|
CREATE OR REPLACE FUNCTION search_verses(search_query TEXT, limit_count INT DEFAULT 10)
|
|
RETURNS TABLE(
|
|
verse_id TEXT,
|
|
book_name TEXT,
|
|
chapter_num INT,
|
|
verse_num INT,
|
|
verse_text TEXT,
|
|
rank REAL
|
|
) AS $$
|
|
BEGIN
|
|
RETURN QUERY
|
|
SELECT
|
|
v.id::TEXT,
|
|
b.name,
|
|
c."chapterNum",
|
|
v."verseNum",
|
|
v.text,
|
|
CASE
|
|
WHEN v.text ILIKE '%' || search_query || '%' THEN 1.0
|
|
ELSE 0.5
|
|
END as rank
|
|
FROM "BibleVerse" v
|
|
JOIN "BibleChapter" c ON v."chapterId" = c.id
|
|
JOIN "BibleBook" b ON c."bookId" = b.id
|
|
WHERE v.text ILIKE '%' || search_query || '%'
|
|
ORDER BY rank DESC, b."orderNum", c."chapterNum", v."verseNum"
|
|
LIMIT limit_count;
|
|
END;
|
|
$$ LANGUAGE plpgsql;
|
|
`
|
|
|
|
console.log('Search function created successfully!')
|
|
|
|
} catch (error) {
|
|
console.error('Error importing Bible:', error)
|
|
throw error
|
|
}
|
|
}
|
|
|
|
importBible()
|
|
.then(() => {
|
|
console.log('Import process completed')
|
|
process.exit(0)
|
|
})
|
|
.catch((error) => {
|
|
console.error('Import failed:', error)
|
|
process.exit(1)
|
|
})
|
|
.finally(() => prisma.$disconnect()) |