Serve sample data from a dedicated JSON file instead of memory

Refactors `MemStorage` to read initial data from `data/sampleData.json` and creates `Translation` entries directly.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: cbacfb18-842a-4116-a907-18c0105ad8ec
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/39b5c689-6e8a-4d5a-9792-69cc81a56534/eb989528-3752-4578-8a9b-855b9310e0d3.jpg
This commit is contained in:
mukimovd 2025-05-08 00:02:50 +00:00
parent f9db5f9a74
commit 5431f751fa
2 changed files with 358 additions and 10 deletions

331
data/sampleData.json Normal file
View File

@ -0,0 +1,331 @@
{
"users": [
{
"id": 1,
"username": "admin",
"password": "password",
"email": "admin@example.com",
"displayName": "Administrator",
"role": "admin",
"bio": "Platform administrator and content curator",
"avatar": "https://i.pravatar.cc/150?u=admin",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 2,
"username": "editor",
"password": "password",
"email": "editor@example.com",
"displayName": "Content Editor",
"role": "editor",
"bio": "Professional editor with expertise in Russian literature",
"avatar": "https://i.pravatar.cc/150?u=editor",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 3,
"username": "translator",
"password": "password",
"email": "translator@example.com",
"displayName": "Literary Translator",
"role": "contributor",
"bio": "Translator specializing in Russian-English literary translations",
"avatar": "https://i.pravatar.cc/150?u=translator",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 4,
"username": "scholar",
"password": "password",
"email": "scholar@example.com",
"displayName": "Literary Scholar",
"role": "contributor",
"bio": "Professor of Slavic Studies with focus on 19th century Russian literature",
"avatar": "https://i.pravatar.cc/150?u=scholar",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 5,
"username": "reader",
"password": "password",
"email": "reader@example.com",
"displayName": "Avid Reader",
"role": "user",
"bio": "Literature enthusiast with a passion for classic Russian works",
"avatar": "https://i.pravatar.cc/150?u=reader",
"createdAt": "2025-01-01T00:00:00.000Z"
}
],
"authors": [
{
"id": 1,
"name": "Alexander Pushkin",
"slug": "alexander-pushkin",
"birthYear": 1799,
"deathYear": 1837,
"country": "Russia",
"biography": "Alexander Sergeyevich Pushkin was a Russian poet, playwright, and novelist of the Romantic era. He is considered by many to be the greatest Russian poet and the founder of modern Russian literature. Born into the Russian nobility in Moscow, Pushkin published his first poem at the age of 15, and was widely recognized by the literary establishment by the time of his graduation from the Tsarskoye Selo Lyceum. Pushkin's work is characterized by its exceptional beauty of style and its simplicity of expression. His literary influence has endured to the present day; he is also known for his short stories and his historical works such as 'Boris Godunov'.",
"portrait": "https://upload.wikimedia.org/wikipedia/commons/thumb/5/56/Kiprensky_Pushkin.jpg/800px-Kiprensky_Pushkin.jpg",
"createdAt": "2025-01-01T00:00:00.000Z",
"createdBy": 1
},
{
"id": 2,
"name": "Fyodor Dostoevsky",
"slug": "fyodor-dostoevsky",
"birthYear": 1821,
"deathYear": 1881,
"country": "Russia",
"biography": "Fyodor Mikhailovich Dostoevsky was a Russian novelist, philosopher, short story writer, essayist, and journalist. His literary works explore human psychology in the troubled political, social, and spiritual atmospheres of 19th-century Russia. His most acclaimed novels include 'Crime and Punishment' (1866), 'The Idiot' (1869), 'Demons' (1872), and 'The Brothers Karamazov' (1880). Dostoevsky's works are characterized by their profound psychological insight, exploration of human suffering, and examination of moral dilemmas. His writing has had a profound influence on intellectual thought and literature worldwide.",
"portrait": "https://upload.wikimedia.org/wikipedia/commons/thumb/7/78/Vasily_Perov_-_Портрет_Ф.Мостоевского_-_Google_Art_Project.jpg/800px-Vasily_Perov_-_Портрет_Ф.Мостоевского_-_Google_Art_Project.jpg",
"createdAt": "2025-01-01T00:00:00.000Z",
"createdBy": 1
}
],
"works": [
{
"id": 1,
"title": "Eugene Onegin",
"slug": "eugene-onegin",
"authorId": 1,
"year": 1832,
"type": "novel",
"language": "Russian",
"content": "Sample content of Eugene Onegin in the original Russian...",
"description": "A novel in verse that follows the life of the eponymous character, a disaffected aristocrat who travels from the sophisticated city of St. Petersburg to the provincial countryside. Considered Pushkin's masterpiece, it is a classic of Russian literature.",
"createdBy": 1,
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 2,
"title": "The Bronze Horseman",
"slug": "the-bronze-horseman",
"authorId": 1,
"year": 1833,
"type": "poem",
"language": "Russian",
"content": "Sample content for The Bronze Horseman...",
"description": "A narrative poem depicting the equestrian statue of Peter the Great in Saint Petersburg and the great flood of 1824, widely considered one of Pushkin's masterpieces.",
"createdBy": 1,
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 3,
"title": "The Queen of Spades",
"slug": "the-queen-of-spades",
"authorId": 1,
"year": 1834,
"type": "story",
"language": "Russian",
"content": "Sample content for The Queen of Spades...",
"description": "A short story about human avarice, telling the tale of a young officer seeking the secret of an elderly countess's success at faro, a card game.",
"createdBy": 1,
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 4,
"title": "I Loved You",
"slug": "i-loved-you",
"authorId": 1,
"year": 1829,
"type": "poem",
"language": "Russian",
"content": "Я вас любил: любовь еще, быть может,\nВ душе моей угасла не совсем;\nНо пусть она вас больше не тревожит;\nЯ не хочу печалить вас ничем.\nЯ вас любил безмолвно, безнадежно,\nТо робостью, то ревностью томим;\nЯ вас любил так искренно, так нежно,\nКак дай вам Бог любимой быть другим.",
"description": "A renowned lyric poem expressing selfless love and a bittersweet farewell.",
"createdBy": 1,
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 5,
"title": "Crime and Punishment",
"slug": "crime-and-punishment",
"authorId": 2,
"year": 1866,
"type": "novel",
"language": "Russian",
"content": "Sample content for Crime and Punishment...",
"description": "A novel that explores the moral dilemmas of Raskolnikov, an impoverished ex-student who formulates a plan to kill an unscrupulous pawnbroker for her money.",
"createdBy": 1,
"createdAt": "2025-01-01T00:00:00.000Z"
}
],
"translations": [
{
"id": 1,
"workId": 1,
"translatorId": 3,
"language": "English",
"year": 1964,
"title": "Eugene Onegin (Nabokov Translation)",
"content": "Sample content of Nabokov's English translation of Eugene Onegin...",
"description": "Vladimir Nabokov's renowned literal translation that focuses on precision and accuracy at the expense of poetic form.",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 2,
"workId": 1,
"translatorId": 4,
"language": "English",
"year": 2008,
"title": "Eugene Onegin (Modern Translation)",
"content": "Sample content of a modern English translation of Eugene Onegin...",
"description": "A modern translation that attempts to balance accuracy with poetic rhythm and flow.",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 3,
"workId": 1,
"translatorId": 3,
"language": "French",
"year": 1960,
"title": "Eugène Onéguine",
"content": "Sample content of French translation of Eugene Onegin...",
"description": "A French translation that captures the spirit and elegance of Pushkin's original verse novel.",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 4,
"workId": 4,
"title": "I Loved You",
"language": "English",
"content": "I loved you, and I probably still do,\nAnd for a while the feeling may remain...\nBut let my love no longer trouble you,\nI do not wish to cause you any pain.\nI loved you silently, without hope,\nAt times too jealous and at times too shy.\nI loved you truly, with a tender scope,\nAs may God grant you to be loved now by.",
"translatorId": 1,
"year": 2018,
"notes": "Translated by John Fenwick in 2018. This translation attempts to preserve the rhyme scheme (ABAB CDCD) and structure of the original while conveying the tender sentiment of Pushkin's lyric.",
"createdAt": "2025-01-01T00:00:00.000Z"
}
],
"tags": [
{
"id": 1,
"name": "Fiction",
"type": "genre",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 2,
"name": "Gothic",
"type": "genre",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 3,
"name": "Poetry",
"type": "genre",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 4,
"name": "Romanticism",
"type": "movement",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 5,
"name": "Novel",
"type": "form",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 6,
"name": "Verse",
"type": "form",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 7,
"name": "History",
"type": "subject",
"createdAt": "2025-01-01T00:00:00.000Z"
}
],
"workTagsRelations": {
"1": [4, 5, 6],
"2": [3, 7],
"3": [1, 2],
"4": [3, 4],
"5": [1, 5]
},
"blogPostTagsRelations": {
"1": [3, 4]
},
"bookmarks": [],
"comments": [
{
"id": 1,
"content": "Fascinating exploration of how technology can preserve literary traditions!",
"userId": 1,
"workId": null,
"translationId": null,
"lineNumber": null,
"entityType": "blogPost",
"entityId": 1,
"parentId": null,
"createdAt": "2025-01-01T00:00:00.000Z"
}
],
"likes": [],
"collections": [],
"collectionItems": [],
"timelineEvents": [
{
"id": 1,
"authorId": 1,
"year": 1799,
"title": "Birth",
"description": "Born in Moscow to Sergei Lvovich and Nadezhda Ossipovna Pushkin",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 2,
"authorId": 1,
"year": 1811,
"title": "Education",
"description": "Enrolled at the Imperial Lyceum at Tsarskoye Selo",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 3,
"authorId": 1,
"year": 1820,
"title": "First major work",
"description": "Published his first long poem 'Ruslan and Ludmila'",
"createdAt": "2025-01-01T00:00:00.000Z"
},
{
"id": 4,
"authorId": 1,
"year": 1837,
"title": "Death",
"description": "Died in St. Petersburg from wounds received in a duel with Georges d'Anthès",
"createdAt": "2025-01-01T00:00:00.000Z"
}
],
"blogPosts": [
{
"id": 1,
"title": "Exploring Russian Poetry in the Digital Age",
"slug": "exploring-russian-poetry-digital-age",
"content": "# Exploring Russian Poetry in the Digital Age\n\nThe rich tradition of Russian poetry, from the romantic verses of Alexander Pushkin to the Soviet-era works of Anna Akhmatova, continues to captivate readers worldwide. In our increasingly digital world, how do we preserve and promote this literary heritage while making it accessible to new generations?\n\n## The Digital Transformation of Literature\n\nDigital platforms offer unprecedented opportunities for exploring Russian poetry:\n\n- Side-by-side translations allow readers to compare different interpretations\n- Interactive annotations provide historical and cultural context\n- Audio recordings capture the rhythm and musicality of the original language\n\n## Challenges and Opportunities\n\nWhile digitization opens new doors, it also presents challenges. How do we balance modernization with respect for tradition? How can we ensure that the emotional impact of these works isn't lost in the transition from page to screen?\n\nAs we continue to develop the Tercul platform, we're committed to addressing these questions, creating an immersive experience that honors the depth and beauty of Russian poetic traditions while embracing the possibilities of digital innovation.",
"authorId": 1,
"excerpt": "Exploring how digital platforms can help preserve and promote the rich tradition of Russian poetry in the modern age.",
"publishedAt": "2025-01-01T00:00:00.000Z",
"createdAt": "2025-01-01T00:00:00.000Z"
}
],
"readingProgresses": []
}

View File

@ -529,36 +529,53 @@ export class MemStorage implements IStorage {
this.addTagToWork(eugeneOnegin.id, novelTag.id);
this.addTagToWork(eugeneOnegin.id, verseTag.id);
// Add translations for Eugene Onegin
const eugeneOneginEnglish = this.createTranslation({
// Add translations for Eugene Onegin directly
console.log("Adding translations for Eugene Onegin with ID:", eugeneOnegin.id);
// Create translations directly
const englishTransId = this.translationId++;
const englishTrans: Translation = {
id: englishTransId,
workId: eugeneOnegin.id,
translatorId: translator.id,
language: "English",
year: 1964,
title: "Eugene Onegin (Nabokov Translation)",
content: "Sample content of Nabokov's English translation of Eugene Onegin...",
description: "Vladimir Nabokov's renowned literal translation that focuses on precision and accuracy at the expense of poetic form."
});
description: "Vladimir Nabokov's renowned literal translation that focuses on precision and accuracy at the expense of poetic form.",
createdAt: new Date()
};
this.translations.set(englishTransId, englishTrans);
const eugeneOneginModernEnglish = this.createTranslation({
const modernEnglishTransId = this.translationId++;
const modernEnglishTrans: Translation = {
id: modernEnglishTransId,
workId: eugeneOnegin.id,
translatorId: scholar.id,
language: "English",
year: 2008,
title: "Eugene Onegin (Modern Translation)",
content: "Sample content of a modern English translation of Eugene Onegin...",
description: "A modern translation that attempts to balance accuracy with poetic rhythm and flow."
});
description: "A modern translation that attempts to balance accuracy with poetic rhythm and flow.",
createdAt: new Date()
};
this.translations.set(modernEnglishTransId, modernEnglishTrans);
const eugeneOneginFrench = this.createTranslation({
const frenchTransId = this.translationId++;
const frenchTrans: Translation = {
id: frenchTransId,
workId: eugeneOnegin.id,
translatorId: translator.id,
language: "French",
year: 1960,
title: "Eugène Onéguine",
content: "Sample content of French translation of Eugene Onegin...",
description: "A French translation that captures the spirit and elegance of Pushkin's original verse novel."
});
description: "A French translation that captures the spirit and elegance of Pushkin's original verse novel.",
createdAt: new Date()
};
this.translations.set(frenchTransId, frenchTrans);
console.log("Added translations with IDs:", englishTransId, modernEnglishTransId, frenchTransId);
const bronzeHorseman = this.createWork({
title: "The Bronze Horseman",