Add multi-version Bible support with ESV and NKJV translations

- Rename project from 'ESV Bible' to 'The Bible'
- Implement version selection dropdown in homepage header
- Add support for multiple Bible versions:
  * ESV (English Standard Version) - from mdbible
  * NKJV (New King James Version) - from local NKJV/ directory
- Update all API endpoints to accept version parameter (?version=esv|?version=nkjv)
- Add version-aware favorites system that stores and displays Bible version (e.g., 'Genesis 1:1 (ESV)')
- Update database schema to include version column in favorites table
- Maintain backward compatibility with existing data
- Update Docker configuration and documentation
This commit is contained in:
Ryderjj89
2025-09-28 12:13:37 -04:00
parent 5f832aecd4
commit ceeb465c8d
1199 changed files with 187 additions and 86 deletions

View File

@@ -50,7 +50,22 @@ function initializeTables() {
)
`);
// Favorites table
// Check if favorites table exists and needs migration
db.all("PRAGMA table_info(favorites)", [], (err, columns) => {
if (!err && columns.length > 0) {
const hasVersionColumn = columns.some(col => col.name === 'version');
if (!hasVersionColumn) {
// Add version column to existing table
db.run("ALTER TABLE favorites ADD COLUMN version TEXT DEFAULT 'esv'", (err) => {
if (!err) {
console.log('Added version column to favorites table');
}
});
}
}
});
// Favorites table (with IF NOT EXISTS for safety)
db.run(`
CREATE TABLE IF NOT EXISTS favorites (
id INTEGER PRIMARY KEY AUTOINCREMENT,
@@ -59,10 +74,11 @@ function initializeTables() {
chapter TEXT,
verse_start INTEGER,
verse_end INTEGER,
version TEXT DEFAULT 'esv',
note TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE,
UNIQUE(user_id, book, chapter, verse_start, verse_end)
UNIQUE(user_id, book, chapter, verse_start, verse_end, version)
)
`);
@@ -168,12 +184,12 @@ const favoritesOps = {
// Add favorite
addFavorite: (userId, favorite, callback) => {
const { book, chapter, verse_start, verse_end, note } = favorite;
const { book, chapter, verse_start, verse_end, version, note } = favorite;
db.run(
`INSERT INTO favorites (user_id, book, chapter, verse_start, verse_end, note)
VALUES (?, ?, ?, ?, ?, ?)`,
[userId, book, chapter, verse_start, verse_end, note],
`INSERT INTO favorites (user_id, book, chapter, verse_start, verse_end, version, note)
VALUES (?, ?, ?, ?, ?, ?, ?)`,
[userId, book, chapter, verse_start, verse_end, version || 'esv', note],
callback
);
},
@@ -188,10 +204,10 @@ const favoritesOps = {
},
// Check if verse is favorited
isFavorited: (userId, book, chapter, verse_start, verse_end, callback) => {
isFavorited: (userId, book, chapter, verse_start, verse_end, version, callback) => {
db.get(
'SELECT id FROM favorites WHERE user_id = ? AND book = ? AND chapter = ? AND verse_start = ? AND verse_end = ?',
[userId, book, chapter, verse_start, verse_end],
'SELECT id FROM favorites WHERE user_id = ? AND book = ? AND chapter = ? AND verse_start = ? AND verse_end = ? AND version = ?',
[userId, book, chapter, verse_start, verse_end, version || 'esv'],
(err, row) => {
if (err) return callback(err);
callback(null, !!row);