Compare commits
19
Commits
ba35ccab19
..
main
No files matched your search
@@ -62,3 +62,6 @@ data/nuggets-workflow.json
|
||||
|
||||
# Live download counters — server data volume only
|
||||
data/download-counts.json
|
||||
|
||||
# Generated audio (upload via Admin → Asset Manager, do not commit)
|
||||
audio-out/
|
||||
Generated
+1258
-1125
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "siteforge",
|
||||
"private": true,
|
||||
"version": "2.36.5",
|
||||
"version": "2.46.1",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -38,7 +38,7 @@
|
||||
"react-dom": "^19.2.4",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-router-dom": "^7.13.1",
|
||||
"react-simple-maps": "^3.0.0",
|
||||
"react-simple-maps": "^5.0.5",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"resend": "^6.10.0",
|
||||
"tar": "^7.5.19"
|
||||
|
||||
+965
-16
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,148 @@
|
||||
// Generates the /salvation audio from the narration files in scripts/salvation/ using ElevenLabs.
|
||||
// There are three tracks: the case, then the listener chooses Guilty or Not guilty.
|
||||
//
|
||||
// node --env-file=.env scripts/generate-salvation-audio.mjs --list-voices # find your voice id
|
||||
// node --env-file=.env scripts/generate-salvation-audio.mjs --sample # ~40 seconds, to test the voice (cheap)
|
||||
// node --env-file=.env scripts/generate-salvation-audio.mjs # generate all three MP3s
|
||||
// node --env-file=.env scripts/generate-salvation-audio.mjs --only=guilty # just one: case | guilty | not-guilty
|
||||
//
|
||||
// Needs, in your local .env (never commit it):
|
||||
// ELEVENLABS_API_KEY=...
|
||||
// ELEVENLABS_VOICE_ID=... (from --list-voices, or your cloned voice)
|
||||
// Optional:
|
||||
// ELEVENLABS_MODEL=eleven_multilingual_v2
|
||||
// ELEVENLABS_STABILITY=0.5 (lower = more expressive, higher = steadier)
|
||||
// ELEVENLABS_SPEED=1
|
||||
//
|
||||
// Output goes to audio-out/ (git-ignored). Upload the MP3s in Admin → Asset Manager, then paste their
|
||||
// URLs into Admin → Gospel Page.
|
||||
import { readFile, writeFile, mkdir } from 'node:fs/promises'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
||||
const API = 'https://api.elevenlabs.io/v1'
|
||||
const apiKey = process.env.ELEVENLABS_API_KEY
|
||||
const voiceId = process.env.ELEVENLABS_VOICE_ID
|
||||
const model = process.env.ELEVENLABS_MODEL || 'eleven_multilingual_v2'
|
||||
const MAX_CHARS = 4500
|
||||
let totalCost = 0
|
||||
|
||||
function fail(message) {
|
||||
console.error(`\n${message}\n`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
if (!apiKey) fail('ELEVENLABS_API_KEY is not set. Add it to your local .env file (not to chat or to git).')
|
||||
|
||||
async function listVoices() {
|
||||
const res = await fetch(`${API}/voices`, { headers: { 'xi-api-key': apiKey } })
|
||||
if (!res.ok) fail(`Could not list voices (${res.status}). Check the API key.`)
|
||||
const { voices = [] } = await res.json()
|
||||
console.log('\nYour voices (name: voice id)\n')
|
||||
for (const v of voices) console.log(` ${v.name}${v.category ? ` [${v.category}]` : ''}: ${v.voice_id}`)
|
||||
console.log('\nPut the one you want in .env as ELEVENLABS_VOICE_ID=...\n')
|
||||
}
|
||||
|
||||
// Split on paragraph boundaries so each request stays under MAX_CHARS and never cuts a sentence.
|
||||
function chunkText(text) {
|
||||
const paragraphs = text.split(/\n{2,}/).map(p => p.trim()).filter(Boolean)
|
||||
const chunks = []
|
||||
let current = ''
|
||||
for (const p of paragraphs) {
|
||||
if (current && current.length + p.length + 2 > MAX_CHARS) { chunks.push(current); current = '' }
|
||||
current = current ? `${current}\n\n${p}` : p
|
||||
}
|
||||
if (current) chunks.push(current)
|
||||
return chunks
|
||||
}
|
||||
|
||||
async function speak(text, previous, next) {
|
||||
const res = await fetch(`${API}/text-to-speech/${voiceId}?output_format=mp3_44100_128`, {
|
||||
method: 'POST',
|
||||
headers: { 'xi-api-key': apiKey, 'Content-Type': 'application/json', Accept: 'audio/mpeg' },
|
||||
body: JSON.stringify({
|
||||
text,
|
||||
model_id: model,
|
||||
voice_settings: {
|
||||
stability: Number(process.env.ELEVENLABS_STABILITY ?? 0.5),
|
||||
similarity_boost: 0.75,
|
||||
style: 0,
|
||||
use_speaker_boost: true,
|
||||
speed: Number(process.env.ELEVENLABS_SPEED ?? 1),
|
||||
},
|
||||
...(previous ? { previous_text: previous.slice(-600) } : {}),
|
||||
...(next ? { next_text: next.slice(0, 600) } : {}),
|
||||
}),
|
||||
})
|
||||
if (!res.ok) {
|
||||
const detail = await res.text().catch(() => '')
|
||||
fail(`ElevenLabs returned ${res.status}.\n${detail.slice(0, 400)}`)
|
||||
}
|
||||
const cost = res.headers.get('character-cost')
|
||||
if (cost) totalCost += Number(cost) || 0
|
||||
return Buffer.from(await res.arrayBuffer())
|
||||
}
|
||||
|
||||
const TRACKS = [
|
||||
{ id: 'case', file: 'narration-1-case.txt', out: 'salvation-case.mp3' },
|
||||
{ id: 'guilty', file: 'narration-2-guilty.txt', out: 'salvation-guilty.mp3' },
|
||||
{ id: 'not-guilty', file: 'narration-3-not-guilty.txt', out: 'salvation-not-guilty.mp3' },
|
||||
]
|
||||
|
||||
async function renderTrack(text, outPath) {
|
||||
const chunks = chunkText(text)
|
||||
const parts = []
|
||||
for (let i = 0; i < chunks.length; i += 1) {
|
||||
process.stdout.write(` part ${i + 1}/${chunks.length}… `)
|
||||
parts.push(await speak(chunks[i], chunks[i - 1], chunks[i + 1]))
|
||||
console.log('done')
|
||||
}
|
||||
await writeFile(outPath, Buffer.concat(parts))
|
||||
}
|
||||
|
||||
async function main() {
|
||||
if (process.argv.includes('--list-voices')) { await listVoices(); return }
|
||||
if (!voiceId) fail('ELEVENLABS_VOICE_ID is not set. Run with --list-voices to find it, then add it to .env.')
|
||||
|
||||
const outDir = path.join(ROOT, 'audio-out')
|
||||
await mkdir(outDir, { recursive: true })
|
||||
|
||||
if (process.argv.includes('--sample')) {
|
||||
const full = (await readFile(path.join(ROOT, 'scripts/salvation', TRACKS[0].file), 'utf8')).trim()
|
||||
// Whole paragraphs only, so the sample never stops mid-sentence (about 700 characters).
|
||||
let sample = ''
|
||||
for (const para of full.split(/\n{2,}/)) {
|
||||
if (sample && sample.length + para.length > 750) break
|
||||
sample = sample ? `${sample}\n\n${para}` : para
|
||||
}
|
||||
// Don't end on a lone heading like "The Accuser."
|
||||
const lastBreak = sample.lastIndexOf('\n\n')
|
||||
if (lastBreak > 0 && sample.length - lastBreak < 40) sample = sample.slice(0, lastBreak)
|
||||
console.log(`\nSample: ${sample.length} characters (model ${model}).\n`)
|
||||
const out = path.join(outDir, 'salvation-sample.mp3')
|
||||
await renderTrack(sample, out)
|
||||
if (totalCost) console.log(`\nElevenLabs reported ${totalCost.toLocaleString()} credits used.`)
|
||||
console.log(`\nSaved ${out}\nIf the voice sounds right, run again without --sample.\n`)
|
||||
return
|
||||
}
|
||||
|
||||
const only = (process.argv.find(a => a.startsWith('--only=')) || '').split('=')[1]
|
||||
const tracks = only ? TRACKS.filter(t => t.id === only) : TRACKS
|
||||
if (!tracks.length) fail(`Unknown --only value "${only}". Use: case, guilty or not-guilty.`)
|
||||
|
||||
const texts = []
|
||||
for (const t of tracks) texts.push((await readFile(path.join(ROOT, 'scripts/salvation', t.file), 'utf8')).trim())
|
||||
const chars = texts.reduce((n, t) => n + t.length, 0)
|
||||
console.log(`\n${tracks.length} track(s), ${chars.toLocaleString()} characters in total (model ${model}).`)
|
||||
console.log('This uses about that many ElevenLabs credits.\n')
|
||||
|
||||
for (const [i, t] of tracks.entries()) {
|
||||
console.log(` ${t.id} (${texts[i].length.toLocaleString()} characters)`)
|
||||
await renderTrack(texts[i], path.join(outDir, t.out))
|
||||
}
|
||||
if (totalCost) console.log(`\nElevenLabs reported ${totalCost.toLocaleString()} credits used.`)
|
||||
console.log(`\nSaved to ${outDir}:\n${tracks.map(t => ` ${t.out}`).join('\n')}\nListen to each one before you upload it. Check the Scripture names and references.\n`)
|
||||
}
|
||||
|
||||
main().catch(err => fail(err?.message ?? String(err)))
|
||||
@@ -0,0 +1,71 @@
|
||||
The Gospel, in a Courtroom.
|
||||
|
||||
Imagine a courtroom. Not a courtroom on earth, but the highest court there is: the Court of Heaven. God is the Judge. Satan is the accuser. The charges are your sins, and you are the one on trial. But before the verdict is read, a Substitute has stepped forward to take your place. Let me walk you through the case.
|
||||
|
||||
The Judge.
|
||||
|
||||
God is perfectly just. He will not overlook wrongdoing. Nothing is hidden from him, and he judges rightly. In the book of Genesis, chapter eighteen, verse twenty-five, Scripture asks: "Will not the Judge of all the earth do right?" And in Acts, chapter seventeen, verse thirty-one: "For He has set a day when He will judge the world with justice by the Man He has appointed."
|
||||
|
||||
The Accuser.
|
||||
|
||||
Every courtroom has an accuser, and ours is Satan. His very name means "adversary." Scripture calls him the accuser of the brothers, who brings charges against us before God. He does not have to invent anything. He only has to point to what we have actually done. Revelation, chapter twelve, verse ten, calls him "the accuser of our brothers, who accuses them before our God day and night." And First Peter, chapter five, verse eight, warns: "Your adversary the devil prowls around like a roaring lion, looking for someone to devour."
|
||||
|
||||
The Charges.
|
||||
|
||||
So what are the charges? The charges are the sins you have committed.
|
||||
|
||||
Sin is breaking God's law. That includes the wrong things we knowingly do, the good things we fail to do, and the things we say and think in secret.
|
||||
|
||||
It also includes breaking his law without knowing it. Not knowing the law has never made anyone innocent. God's standard is written on every conscience, so that no one is without excuse. Even sin done unknowingly still leaves a person guilty.
|
||||
|
||||
And God does not grade on a curve. Stumbling at one point means you have broken the whole law. We have all sinned. That includes you, and it includes me.
|
||||
|
||||
First John, chapter three, verse four: "Everyone who practices sin practices lawlessness; indeed, sin is lawlessness." James, chapter two, verse ten: "For whoever keeps the whole law but stumbles at just one point is guilty of breaking all of it." Romans, chapter three, verse ten: "There is no one righteous, not even one." And Romans, chapter three, verse twenty-three: "For all have sinned and fall short of the glory of God."
|
||||
|
||||
The Verdict.
|
||||
|
||||
The evidence is clear, and there is no defense. We cannot argue our way out, and our good deeds cannot cancel our guilt. The sentence for sin is death: separation from the God who made us. Romans, chapter three, verse nineteen: "...so that every mouth may be silenced and the whole world held accountable to God." And Romans, chapter six, verse twenty-three: "For the wages of sin is death..."
|
||||
|
||||
But that is not the end of the story.
|
||||
|
||||
The Substitute.
|
||||
|
||||
Then God himself stepped forward to take your place.
|
||||
|
||||
Jesus is God. The eternal Son took on flesh and was born as a baby in Bethlehem, and he came for one purpose: to take the place of sinners like you and me. He did not come to be served. He came to give his life, and the cross was always where the road was heading.
|
||||
|
||||
He lived the perfect life you could not live. On the cross he took the sentence that belonged to you, and he rose again on the third day to prove the payment was accepted.
|
||||
|
||||
John, chapter one, verse fourteen: "The Word became flesh and dwelt among us." Matthew, chapter one, verse twenty-one: "She will bear a Son, and you are to name Him Jesus, because He will save His people from their sins." Mark, chapter ten, verse forty-five: "For even the Son of Man did not come to be served, but to serve, and to give His life as a ransom for many." First Peter, chapter three, verse eighteen: "For Christ also suffered once for sins, the righteous for the unrighteous, to bring you to God." Second Corinthians, chapter five, verse twenty-one: "God made Him who knew no sin to be sin for us, so that in Him we might become the righteousness of God." And Romans, chapter five, verse eight: "But God proves His love for us in this: While we were still sinners, Christ died for us."
|
||||
|
||||
The Pardon.
|
||||
|
||||
The pardon is a gift. It cannot be earned or bought. You receive it by turning from your sin and trusting Jesus alone. When you do, God declares you forgiven and counts you righteous because of what Christ has done.
|
||||
|
||||
Ephesians, chapter two, verses eight and nine: "For by grace you have been saved through faith, and this is not from yourselves, but it is the gift of God, not by works, so that no one can boast." And Romans, chapter ten, verse nine: "If you confess with your mouth that Jesus is Lord, and believe in your heart that God raised Him from the dead, you will be saved."
|
||||
|
||||
The Result.
|
||||
|
||||
Case closed. The accuser has nothing left to say. Our sins were real charges, but they have been answered, because the penalty has been paid in full by the Substitute. The one who trusts in Christ is not waiting nervously for a verdict. The verdict has already been given in their favor.
|
||||
|
||||
Romans, chapter eight, verse one: "Therefore, there is now no condemnation for those who are in Christ Jesus." And verses thirty-three and thirty-four: "Who can bring an accusation against those whom God has chosen? It is God who justifies. Who then can condemn? Christ Jesus, who died, more than that, was raised to life, is at the right hand of God, and He is interceding for us."
|
||||
|
||||
Before you plead.
|
||||
|
||||
Before you plead, read what Jesus did for you. Everything you have just heard tells you that the Substitute took your place. The record shows you how: the night he was arrested, the trials where he was declared innocent and condemned anyway, the long road to the cross, and the empty tomb on the third day.
|
||||
|
||||
Please do not skip it. It is the story of what Jesus did for you, told by four witnesses and woven into one account. Take your time and read it slowly. You can pause this audio at any time, read the record, and then come back and press play. When you are ready, continue.
|
||||
|
||||
How do you plead?
|
||||
|
||||
The court is not asking whether you are a good person. It is asking you to be honest about the charges, and to decide where you will stand: on your own record, or on what Jesus has done in your place.
|
||||
|
||||
You have two choices.
|
||||
|
||||
You can plead guilty. That means: I admit it. I have broken God's law, whether I knew it or not, and I cannot save myself. I am not asking the court to find me innocent. I am asking for the pardon Jesus paid for with his life. And here is what happens: the Judge declares you forgiven, and counts you righteous because of Christ. The accuser has nothing left to say.
|
||||
|
||||
Or you can plead not guilty. That means: I stand on my own record. I believe I have kept God's law well enough to be found innocent, and I do not need anyone to take my place. That plea has a cost, and I will explain it if you choose it.
|
||||
|
||||
Now look at the two buttons below the player. When you are ready, press the one that matches your plea, and I will walk you through what happens next.
|
||||
|
||||
Take a moment. Be honest with God, and honest with yourself.
|
||||
@@ -0,0 +1,19 @@
|
||||
You have pleaded guilty. That is the beginning of the good news.
|
||||
|
||||
You are not earning anything by saying this. You are receiving a gift. Romans, chapter six, verse twenty-three: "For the wages of sin is death, but the gift of God is eternal life in Christ Jesus our Lord." Here is what to do next.
|
||||
|
||||
First, tell God. Words do not save you. Trusting Jesus does. But you can say it to him in your own words, or you can pray this prayer. If you mean it, pray it out loud with me.
|
||||
|
||||
"Lord God, I plead guilty. I have sinned against you, and I cannot save myself. I believe Jesus Christ took my place on the cross, died for my sins, and rose again. I turn from my sin, and I trust him alone. Thank you for the pardon I could never earn. Make me new, and help me follow you. Amen."
|
||||
|
||||
Second, believe it is finished. If you meant that prayer, God has forgiven you. Romans, chapter eight, verse one: "Therefore, there is now no condemnation for those who are in Christ Jesus." Your feelings may go up and down, but the verdict does not change.
|
||||
|
||||
Third, tell someone. Tell a Christian friend or family member what you decided.
|
||||
|
||||
Fourth, start reading. Begin with the Gospel of John, then keep going through the New Testament, and talk to God every day.
|
||||
|
||||
Fifth, find a church. Join a Bible-teaching church where you can grow, and be baptized as a public sign of your faith. Acts, chapter two, verse thirty-eight.
|
||||
|
||||
And if you prayed that prayer and meant it, we would love to rejoice with you. Press the button below that says, Let us know. You can leave your name and your email, and someone from our team will reach out to you personally. It is completely optional.
|
||||
|
||||
Welcome to the family of God.
|
||||
@@ -0,0 +1,23 @@
|
||||
You have pleaded not guilty. Please be sure you understand what that means.
|
||||
|
||||
Pleading not guilty is not just saying, "I am not a bad person." It is telling the Judge, "I have kept your law perfectly, and I need no one to take my place."
|
||||
|
||||
God's standard is not "better than most people." It is perfection. Matthew, chapter five, verse forty-eight: "Be perfect, therefore, as your heavenly Father is perfect." And breaking that standard at even one point makes a person guilty of breaking all of it. James, chapter two, verse ten: "For whoever keeps the whole law but stumbles at just one point is guilty of breaking all of it." That includes the things done without knowing they were wrong.
|
||||
|
||||
So test your plea honestly.
|
||||
|
||||
Have you ever told a lie, even a small one?
|
||||
|
||||
Have you ever taken something that was not yours?
|
||||
|
||||
Have you ever used God's name carelessly, or put something else ahead of him: money, a person, yourself?
|
||||
|
||||
Have you ever hated someone in your heart, or looked at someone with lust? Jesus said those count too. Matthew, chapter five.
|
||||
|
||||
If the answer to any of those is yes, then by God's own standard, the plea does not hold. First John, chapter one, verse eight: "If we say that we have no sin, we are deceiving ourselves, and the truth is not in us."
|
||||
|
||||
And here is what a not guilty plea costs. It means standing before the Judge on your own record, with no Substitute. The sentence for sin stands. Romans, chapter six, verse twenty-three. But that is not what God wants for you. He says he takes no pleasure in anyone's death. Ezekiel, chapter thirty-three, verse eleven. And the offer of pardon is open right now. Second Corinthians, chapter six, verse two: "Now is the day of salvation."
|
||||
|
||||
If you are not sure, that is okay. Questions and doubts are fine. Asking honestly is not the same as refusing.
|
||||
|
||||
If you would like to change your plea, press the button below that says, Change my plea to guilty. You can also read the record of what Jesus did for you, or ask us a question. Whatever you decide, thank you for listening honestly. The offer of the pardon is still open.
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
loadStudySessionsFromDisk,
|
||||
queueStudySessionsWrite,
|
||||
loadNewsletterIssuesFromDisk,
|
||||
loadNuggetsTagsFromDisk,
|
||||
createBackupSnapshot,
|
||||
refreshContentCaches,
|
||||
queueHitStatsWrite,
|
||||
@@ -38,10 +39,12 @@ import {
|
||||
sanitizeUserAgent,
|
||||
shouldCountHit,
|
||||
recordHit,
|
||||
isKnownSitePath,
|
||||
scheduleStudyReminders,
|
||||
scheduleReengagementEmails,
|
||||
scheduleWeeklyDigestEmails,
|
||||
backfillCompletedStudies,
|
||||
backfillReminderDefault,
|
||||
} from './server/study-helpers.js'
|
||||
import { recordVisitor } from './server/routes/analytics.js'
|
||||
|
||||
@@ -75,6 +78,7 @@ import { register as registerFeed } from './server/routes/feed.js'
|
||||
import { register as registerQrCodes } from './server/routes/qr-codes.js'
|
||||
import { register as registerBiblePassage } from './server/routes/bible-passage.js'
|
||||
import { register as registerNewsletter } from './server/routes/newsletter.js'
|
||||
import { register as registerSalvation } from './server/routes/salvation.js'
|
||||
import { register as registerPublic } from './server/routes/public.js'
|
||||
|
||||
preferIpv4ForSeafile()
|
||||
@@ -101,7 +105,7 @@ app.use((_req, res, next) => {
|
||||
"font-src 'self' https://fonts.gstatic.com",
|
||||
"img-src 'self' data: https:",
|
||||
"media-src 'self' https:",
|
||||
"frame-src https:",
|
||||
"frame-src 'self' https:",
|
||||
"connect-src 'self' https:",
|
||||
].join('; '),
|
||||
)
|
||||
@@ -135,12 +139,14 @@ registerFeed(app)
|
||||
registerQrCodes(app)
|
||||
registerBiblePassage(app)
|
||||
registerNewsletter(app)
|
||||
registerSalvation(app)
|
||||
|
||||
// Hit-counting middleware (must come before public routes)
|
||||
app.use((req, res, next) => {
|
||||
if (shouldCountHit(req)) {
|
||||
const ua = sanitizeUserAgent(req.get('user-agent'))
|
||||
const botDetection = detectBot(ua)
|
||||
const knownPath = isKnownSitePath(req.path)
|
||||
const botDetection = knownPath ? detectBot(ua) : { isBot: true, reason: 'unknown-path' }
|
||||
recordHit(req.path, botDetection.isBot, botDetection.reason)
|
||||
queueHitStatsWrite()
|
||||
if (hasVisitorConsent(req) && !botDetection.isBot && !isValidAdminSession(req)) {
|
||||
@@ -194,6 +200,7 @@ Promise.all([
|
||||
loadWebhooksFromDisk(),
|
||||
loadStudySessionsFromDisk(),
|
||||
loadNewsletterIssuesFromDisk(),
|
||||
loadNuggetsTagsFromDisk(),
|
||||
refreshContentCaches(),
|
||||
])
|
||||
.catch(err => {
|
||||
@@ -204,6 +211,11 @@ Promise.all([
|
||||
.catch(err => {
|
||||
console.error('[study] completed-study backfill failed:', err)
|
||||
})
|
||||
.then(() => backfillReminderDefault())
|
||||
.then(updated => { if (updated > 0) console.log(`[study] turned lesson reminders on for ${updated} existing accounts`) })
|
||||
.catch(err => {
|
||||
console.error('[study] reminder-default backfill failed:', err)
|
||||
})
|
||||
.finally(() => {
|
||||
createBackupSnapshot('startup').catch(() => {})
|
||||
setInterval(() => {
|
||||
|
||||
+4
-2
@@ -73,6 +73,7 @@ export const AUDIT_LOG_FILE = path.join(DATA_DIR, 'audit-log.json')
|
||||
export const WEBHOOKS_FILE = path.join(DATA_DIR, 'webhooks.json')
|
||||
export const STUDY_SESSIONS_FILE = path.join(DATA_DIR, 'study-sessions.json')
|
||||
export const NEWSLETTER_ISSUES_FILE = path.join(DATA_DIR, 'newsletter-issues.json')
|
||||
export const NUGGETS_TAGS_FILE = path.join(DATA_DIR, 'nuggets-tags.json')
|
||||
export const MAX_EPISODE_SCRIPT_LENGTH = 200_000 // ~150k words, well beyond any sermon
|
||||
|
||||
// Seafile integration for Nuggets episode uploads
|
||||
@@ -121,8 +122,8 @@ export const MAX_STUDY_COMMENTS = 10000
|
||||
export const MAX_STUDY_COMMENT_LENGTH = 2000
|
||||
export const MAX_STUDY_USERS = 5000
|
||||
export const MAX_STUDY_ENROLLMENTS_PER_USER = 100
|
||||
export const MAX_STUDY_NOTES_PER_USER = 500
|
||||
export const MAX_STUDY_NOTE_LENGTH = 12000
|
||||
export const MAX_STUDY_NOTES_PER_USER = 3000
|
||||
export const MAX_STUDY_NOTE_LENGTH = 200000
|
||||
export const EMAIL_CHANGE_TOKEN_TTL_MS = 24 * 60 * 60 * 1000
|
||||
export const EMAIL_VERIFY_TOKEN_TTL_MS = 7 * 24 * 60 * 60 * 1000
|
||||
export const PASSWORD_RESET_TOKEN_TTL_MS = 60 * 60 * 1000
|
||||
@@ -171,6 +172,7 @@ export const EMPTY_HIT_STATS = {
|
||||
byPath: {},
|
||||
byPathReal: {},
|
||||
byPathBot: {},
|
||||
byPathUnknown: {},
|
||||
byDay: {},
|
||||
byDayReal: {},
|
||||
byDayBot: {},
|
||||
|
||||
+29
-1
@@ -37,6 +37,7 @@ import {
|
||||
WEBHOOKS_FILE,
|
||||
STUDY_SESSIONS_FILE,
|
||||
NEWSLETTER_ISSUES_FILE,
|
||||
NUGGETS_TAGS_FILE,
|
||||
EMPTY_HIT_STATS,
|
||||
EMPTY_VISITOR_STATS,
|
||||
DEFAULT_REPLY_TEMPLATES,
|
||||
@@ -166,6 +167,7 @@ export function loadHitStatsFromDisk() {
|
||||
byPath: parsed?.byPath && typeof parsed.byPath === 'object' ? parsed.byPath : {},
|
||||
byPathReal: parsed?.byPathReal && typeof parsed.byPathReal === 'object' ? parsed.byPathReal : {},
|
||||
byPathBot: parsed?.byPathBot && typeof parsed.byPathBot === 'object' ? parsed.byPathBot : {},
|
||||
byPathUnknown: parsed?.byPathUnknown && typeof parsed.byPathUnknown === 'object' ? parsed.byPathUnknown : {},
|
||||
byDay: parsed?.byDay && typeof parsed.byDay === 'object' ? parsed.byDay : {},
|
||||
byDayReal: parsed?.byDayReal && typeof parsed.byDayReal === 'object' ? parsed.byDayReal : {},
|
||||
byDayBot: parsed?.byDayBot && typeof parsed.byDayBot === 'object' ? parsed.byDayBot : {},
|
||||
@@ -1165,7 +1167,7 @@ export async function restoreFromBackup(filename) {
|
||||
// (These are defined here rather than study-helpers to avoid circular imports)
|
||||
|
||||
export function normalizeMessageType(value) {
|
||||
if (value === 'question' || value === 'testimony' || value === 'topic') return value
|
||||
if (value === 'question' || value === 'testimony' || value === 'topic' || value === 'gospel' || value === 'community') return value
|
||||
return 'general'
|
||||
}
|
||||
|
||||
@@ -1249,6 +1251,7 @@ function sanitizeLoadedHitStats(value) {
|
||||
byPath: value?.byPath && typeof value.byPath === 'object' ? value.byPath : {},
|
||||
byPathReal: value?.byPathReal && typeof value.byPathReal === 'object' ? value.byPathReal : {},
|
||||
byPathBot: value?.byPathBot && typeof value.byPathBot === 'object' ? value.byPathBot : {},
|
||||
byPathUnknown: value?.byPathUnknown && typeof value.byPathUnknown === 'object' ? value.byPathUnknown : {},
|
||||
byDay: value?.byDay && typeof value.byDay === 'object' ? value.byDay : {},
|
||||
byDayReal: value?.byDayReal && typeof value.byDayReal === 'object' ? value.byDayReal : {},
|
||||
byDayBot: value?.byDayBot && typeof value.byDayBot === 'object' ? value.byDayBot : {},
|
||||
@@ -1418,6 +1421,7 @@ export function sanitizeStudyUsers(value) {
|
||||
remindersPausedUntil: typeof item?.remindersPausedUntil === 'string' ? item.remindersPausedUntil : null,
|
||||
reminderFrequency: item?.reminderFrequency === 'weekly' ? 'weekly' : 'immediate',
|
||||
weeklyDigestSentAt: typeof item?.weeklyDigestSentAt === 'string' ? item.weeklyDigestSentAt : null,
|
||||
remindersDefaultedAt: typeof item?.remindersDefaultedAt === 'string' ? item.remindersDefaultedAt : null,
|
||||
})
|
||||
}
|
||||
return out.slice(0, MAX_STUDY_USERS)
|
||||
@@ -1588,3 +1592,27 @@ export function loadNewsletterIssuesFromDisk() {
|
||||
state.newsletterIssues = []
|
||||
})
|
||||
}
|
||||
|
||||
// ── Nuggets Episode Tags ─────────────────────────────────────────────────────
|
||||
|
||||
export function queueNuggetsTagsWrite() {
|
||||
state.nuggetsEpisodeTagsWritePromise = state.nuggetsEpisodeTagsWritePromise
|
||||
.then(async () => {
|
||||
await mkdir(DATA_DIR, { recursive: true })
|
||||
await writeFile(NUGGETS_TAGS_FILE, JSON.stringify({ tags: state.nuggetsEpisodeTags }, null, 2), 'utf8')
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('[nuggets-tags] failed to write:', err)
|
||||
})
|
||||
}
|
||||
|
||||
export function loadNuggetsTagsFromDisk() {
|
||||
return readFile(NUGGETS_TAGS_FILE, 'utf8')
|
||||
.then(raw => {
|
||||
const parsed = JSON.parse(raw)
|
||||
state.nuggetsEpisodeTags = parsed?.tags && typeof parsed.tags === 'object' ? parsed.tags : {}
|
||||
})
|
||||
.catch(() => {
|
||||
state.nuggetsEpisodeTags = {}
|
||||
})
|
||||
}
|
||||
+11
-6
@@ -4,7 +4,7 @@ import { loadPodcastWorkflow, laneSeasonOf } from './routes/podcast-workflow.js'
|
||||
// The Spotify (Anchor) RSS feed only lists episodes that are live, so a season + episode number
|
||||
// showing up there means the episode has been published. That drives two things on the public site:
|
||||
// - highlights marked "hold until released" stay hidden until their episode is in the feed
|
||||
// - study lessons with no audio of their own pick it up from the matching feed episode
|
||||
// - highlights and study lessons with no audio of their own pick it up from the matching feed episode
|
||||
|
||||
const SNAPSHOT_TTL_MS = 5 * 60 * 1000
|
||||
|
||||
@@ -44,7 +44,7 @@ export async function applyFeedRelease(content) {
|
||||
|
||||
const links = Array.isArray(content.podcastFeaturedLinks) ? content.podcastFeaturedLinks : []
|
||||
const studies = Array.isArray(content.studies) ? content.studies : []
|
||||
if (!links.some(l => l?.holdUntilReleased) && studies.length === 0) return content
|
||||
if (links.length === 0 && studies.length === 0) return content
|
||||
|
||||
const [index, wf] = await Promise.all([getFeedIndex(), loadPodcastWorkflow()])
|
||||
const seasonA = laneSeasonOf('A', wf, content)
|
||||
@@ -52,11 +52,16 @@ export async function applyFeedRelease(content) {
|
||||
|
||||
const nextLinks = links.flatMap(link => {
|
||||
// General highlights aren't tied to a series, so there's no season to match against
|
||||
if (!link?.holdUntilReleased || link.lane === 'general') return [link]
|
||||
if (!link || link.lane === 'general') return [link]
|
||||
const season = link.lane === 'second' ? seasonB : seasonA
|
||||
const item = season && link.episodeNumber ? index.get(`${season}-${link.episodeNumber}`) : null
|
||||
if (!item) return []
|
||||
return [{ ...link, url: link.url || item.link || '' }]
|
||||
const item = season && link.episodeNumber ? index.get(`${season}-${String(link.episodeNumber).trim()}`) : null
|
||||
if (!item) return link.holdUntilReleased ? [] : [link]
|
||||
// Highlights with no audio of their own pick it up from the matching feed episode
|
||||
return [{
|
||||
...link,
|
||||
url: link.url || item.link || '',
|
||||
embedUrl: link.embedUrl?.trim() ? link.embedUrl : (item.audioUrl || link.embedUrl),
|
||||
}]
|
||||
})
|
||||
|
||||
const studyLane = study => {
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
buildLastNDaysStats,
|
||||
shouldCountHit,
|
||||
recordHit,
|
||||
isKnownSitePath,
|
||||
getStudyCatalog,
|
||||
} from '../study-helpers.js'
|
||||
|
||||
@@ -260,6 +261,7 @@ export function register(app) {
|
||||
const ip = getClientIp(req)
|
||||
if (!pageviewAllowed(ip)) { res.json({ ok: false, reason: 'rate-limited' }); return }
|
||||
const rawPath = typeof req.body?.path === 'string' ? req.body.path : '/'
|
||||
if (!isKnownSitePath(rawPath)) { res.json({ ok: false, reason: 'unknown-path' }); return }
|
||||
const rawReferrer = typeof req.body?.referrer === 'string' ? req.body.referrer : ''
|
||||
recordHit(rawPath, false)
|
||||
queueHitStatsWrite()
|
||||
@@ -391,6 +393,13 @@ export function register(app) {
|
||||
firstHitAt: state.hitStats.firstHitAt,
|
||||
lastHitAt: state.hitStats.lastHitAt,
|
||||
topPaths, topPathsReal, topPathsBot,
|
||||
topUnknownPaths: Object.entries(state.hitStats.byPathUnknown ?? {})
|
||||
.sort((a, b) => b[1] - a[1]).slice(0, 25).map(([path, hits]) => ({ path, hits })),
|
||||
uniqueVisitors7d: new Set(
|
||||
state.visitorStats.recentVisits
|
||||
.filter(v => Date.now() - new Date(v.at).getTime() <= 7 * 24 * 60 * 60 * 1000)
|
||||
.map(v => v.visitorId),
|
||||
).size,
|
||||
last7Days, last7DaysReal, last7DaysBot,
|
||||
last30DaysTotal, last30DaysRealTotal, last30DaysBotTotal,
|
||||
botReasons,
|
||||
|
||||
@@ -29,7 +29,12 @@ BIBLE_BOOKS.forEach((b, index) => {
|
||||
})
|
||||
|
||||
function parseReference(reference) {
|
||||
const stripped = reference.replace(/^[a-z]+/i, '')
|
||||
// Accept a leading book name ("Titus 1:1-2", "1 John 2:3"), en/em dashes and verse-part letters ("1:13a")
|
||||
const stripped = reference
|
||||
.replace(/[–—]/g, '-')
|
||||
.replace(/(\d)[a-z]\b/gi, '$1')
|
||||
.replace(/^\s*(?:[1-3]\s*)?[a-z][a-z .]*?\s*(?=\d+:)/i, '')
|
||||
.trim()
|
||||
const match = stripped.match(/^(\d+):(\d+)(?:-(\d+))?$/)
|
||||
if (!match) return null
|
||||
return {
|
||||
|
||||
@@ -88,15 +88,22 @@ table[align="left"] { float: none !important; margin-left: auto !important; marg
|
||||
</style>
|
||||
</head>`
|
||||
|
||||
const topBar = `
|
||||
<div style="background:#050505;border-bottom:1px solid rgba(184,151,42,0.25);padding:14px 20px;font-family:Georgia,serif">
|
||||
<div style="max-width:640px;margin:0 auto;display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap">
|
||||
<a href="${BASE}/" style="color:#e8d9b5;text-decoration:none;font-size:15px;letter-spacing:0.04em">Verse by Verse with Nate</a>
|
||||
<a href="${BASE}/newsletter" style="color:#B8972A;text-decoration:none;font-size:12px;letter-spacing:0.14em;text-transform:uppercase">← All issues</a>
|
||||
</div></div>`
|
||||
|
||||
const ctaBlock = `
|
||||
<table border="0" width="100%" cellpadding="0" cellspacing="0" role="presentation" align="center">
|
||||
<tbody><tr><td align="center" style="padding:32px 20px 48px;background-color:#080807">
|
||||
<tbody><tr><td align="center" style="padding:40px 20px 56px;background-color:#080807;border-top:1px solid rgba(184,151,42,0.2)">
|
||||
<table width="580" border="0" cellpadding="0" cellspacing="0" role="presentation" style="max-width:580px;width:100%">
|
||||
<tbody><tr><td align="center" style="padding:0">
|
||||
<p style="margin:0 0 16px;font-family:Georgia,serif;font-size:13px;color:#6b6044">
|
||||
<a href="${BASE}/newsletter" style="color:#6b6044;text-decoration:none">← Newsletter Archive</a>
|
||||
</p>
|
||||
<a href="${BASE}/subscribe" style="display:inline-block;padding:12px 32px;font-family:Georgia,serif;font-size:12px;letter-spacing:0.16em;text-transform:uppercase;color:#B8972A;border:1px solid #B8972A;text-decoration:none">Subscribe by Email</a>
|
||||
<tbody><tr><td align="center" style="padding:0;font-family:Georgia,serif">
|
||||
<p style="margin:0 0 8px;font-size:12px;letter-spacing:0.18em;text-transform:uppercase;color:#B8972A">Stay in the Word</p>
|
||||
<p style="margin:0 0 22px;font-size:22px;line-height:1.3;color:#f0e9cc">Get the next issue in your inbox</p>
|
||||
<a href="${BASE}/subscribe" style="display:inline-block;padding:13px 34px;font-size:12px;letter-spacing:0.16em;text-transform:uppercase;color:#0c0c08;background:#B8972A;text-decoration:none;border-radius:4px;font-weight:bold">Subscribe by Email</a>
|
||||
<p style="margin:26px 0 0;font-size:13px"><a href="${BASE}/newsletter" style="color:#8a7e55;text-decoration:none">← Back to the newsletter archive</a></p>
|
||||
</td></tr></tbody></table>
|
||||
</td></tr></tbody></table>
|
||||
</body>`
|
||||
@@ -104,6 +111,7 @@ table[align="left"] { float: none !important; margin-left: auto !important; marg
|
||||
let html = stripUnsubscribeLink(issue.html)
|
||||
html = html.replace(/<title>[\s\S]*?<\/title>/i, '')
|
||||
html = /<\/head>/i.test(html) ? html.replace(/<\/head>/i, metaBlock) : html.replace(/<head[^>]*>/i, m => `${m}${metaBlock.replace('</head>', '')}`)
|
||||
html = html.replace(/<body[^>]*>/i, m => `${m}${topBar}`)
|
||||
html = /<\/body>/i.test(html) ? html.replace(/<\/body>/i, ctaBlock) : `${html}${ctaBlock}`
|
||||
return html
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { parseRssItems } from '../rss-helpers.js'
|
||||
import { state } from '../state.js'
|
||||
import { requireAdminAuth } from '../auth.js'
|
||||
import { queueNuggetsTagsWrite } from '../data.js'
|
||||
|
||||
let cache = null // { url, episodes }
|
||||
let cacheAt = 0
|
||||
@@ -37,12 +39,47 @@ export async function fetchNuggetsEpisodes() {
|
||||
}
|
||||
}
|
||||
|
||||
function withTags(episodes) {
|
||||
return episodes.map(ep => ({ ...ep, tags: state.nuggetsEpisodeTags[ep.audioUrl] ?? [] }))
|
||||
}
|
||||
|
||||
function cleanTags(input) {
|
||||
const list = Array.isArray(input) ? input : []
|
||||
const seen = new Set()
|
||||
const out = []
|
||||
for (const t of list) {
|
||||
const tag = String(t ?? '').trim().replace(/\s+/g, ' ').slice(0, 40)
|
||||
const key = tag.toLowerCase()
|
||||
if (tag && !seen.has(key)) { seen.add(key); out.push(tag) }
|
||||
}
|
||||
return out.slice(0, 12)
|
||||
}
|
||||
|
||||
export function register(app) {
|
||||
app.get('/api/admin/nuggets/episode-tags', requireAdminAuth, async (_req, res) => {
|
||||
try {
|
||||
const episodes = await fetchNuggetsEpisodes()
|
||||
res.json({ episodes: withTags(episodes).map(({ title, pubDate, audioUrl, episode, tags }) => ({ title, pubDate, audioUrl, episode, tags })) })
|
||||
} catch (err) {
|
||||
res.status(502).json({ message: 'Could not load episodes from the feed.' })
|
||||
}
|
||||
})
|
||||
|
||||
app.put('/api/admin/nuggets/episode-tags', requireAdminAuth, (req, res) => {
|
||||
const audioUrl = String(req.body?.audioUrl ?? '')
|
||||
if (!audioUrl) { res.status(400).json({ message: 'audioUrl is required.' }); return }
|
||||
const tags = cleanTags(req.body?.tags)
|
||||
if (tags.length) state.nuggetsEpisodeTags[audioUrl] = tags
|
||||
else delete state.nuggetsEpisodeTags[audioUrl]
|
||||
queueNuggetsTagsWrite()
|
||||
res.json({ ok: true, tags })
|
||||
})
|
||||
|
||||
app.get('/api/nuggets/episodes', async (_req, res) => {
|
||||
const configured = Boolean(feedUrl())
|
||||
try {
|
||||
const episodes = await fetchNuggetsEpisodes()
|
||||
res.json({ episodes: episodes.slice(0, 6), configured })
|
||||
res.json({ episodes: withTags(episodes.slice(0, 6)), configured })
|
||||
} catch (err) {
|
||||
console.error('[nuggets/episodes] RSS fetch error:', err.message)
|
||||
res.json({ episodes: [], configured })
|
||||
@@ -53,7 +90,7 @@ export function register(app) {
|
||||
const configured = Boolean(feedUrl())
|
||||
try {
|
||||
const episodes = await fetchNuggetsEpisodes()
|
||||
res.json({ episodes, configured })
|
||||
res.json({ episodes: withTags(episodes), configured })
|
||||
} catch (err) {
|
||||
console.error('[nuggets/episodes/all] RSS fetch error:', err.message)
|
||||
res.json({ episodes: [], configured })
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
} from '../config.js'
|
||||
import { state } from '../state.js'
|
||||
import { loadSiteContentFile } from '../data.js'
|
||||
import { sanitizeRedirectRules } from '../study-helpers.js'
|
||||
import { sanitizeRedirectRules, isKnownSitePath } from '../study-helpers.js'
|
||||
import { fetchAllEpisodes } from './episodes.js'
|
||||
import { fetchNuggetsEpisodes } from './nuggets.js'
|
||||
import { BIBLE_BOOKS } from '../../shared/bible-books.js'
|
||||
@@ -67,7 +67,7 @@ export function register(app) {
|
||||
const root = canonical.endsWith('/') ? canonical.slice(0, -1) : canonical
|
||||
|
||||
res.type('text/plain').send(
|
||||
['User-agent: *', 'Allow: /', 'Disallow: /salvation', `Sitemap: ${root}/sitemap.xml`].join('\n'),
|
||||
['User-agent: *', 'Allow: /', `Sitemap: ${root}/sitemap.xml`].join('\n'),
|
||||
)
|
||||
})
|
||||
|
||||
@@ -111,6 +111,8 @@ export function register(app) {
|
||||
for (const ep of highlights) {
|
||||
if (ep.id) urls.push(`${root}/episodes/${encodeURIComponent(ep.id)}`)
|
||||
}
|
||||
// The standalone gospel page
|
||||
if (!urls.includes(`${root}/salvation`)) urls.push(`${root}/salvation`)
|
||||
// Newsletter archive + published issues
|
||||
urls.push(`${root}/newsletter`)
|
||||
for (const issue of state.newsletterIssues) {
|
||||
@@ -215,7 +217,8 @@ export function register(app) {
|
||||
if (!sec.id || !sec.reference || !sec.releasedAt) continue
|
||||
if (new Date(sec.releasedAt) > cutoff) continue
|
||||
entries.push({
|
||||
reference: `${bookName} ${sec.reference}`,
|
||||
// Section references often already include the book ("Titus 1:1-2"); only prepend when they don't
|
||||
reference: /^\s*(?:[1-3]\s*)?[A-Za-z]/.test(sec.reference) ? sec.reference.trim() : `${bookName} ${sec.reference}`,
|
||||
sourceType: 'study',
|
||||
sourceTitle: s.title || s.slug,
|
||||
sectionTitle: sec.title || '',
|
||||
@@ -272,6 +275,8 @@ export function register(app) {
|
||||
app.use(async (_req, res) => {
|
||||
try {
|
||||
const html = await readFile(INDEX_FILE, 'utf8')
|
||||
// Unknown URLs still render the app's "Page not found" screen, but with a real 404 status
|
||||
if (!isKnownSitePath(_req.path)) res.status(404)
|
||||
res.type('html').send(injectSeoIntoHtml(html, state.cachedSiteContent))
|
||||
} catch {
|
||||
res.status(503).send('Frontend build not found. Run "npm run build" first.')
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
import { Resend } from 'resend'
|
||||
import { escapeHtml, sanitizeUrl } from '../helpers.js'
|
||||
import { state } from '../state.js'
|
||||
import { getResendFromAddress, getResendInboxAddress, getResendReplyToAddress, getCanonicalBaseUrl, sendResendEmailWithRetry } from '../email.js'
|
||||
|
||||
// A visitor who finished the /salvation page can tell us they prayed to receive Christ.
|
||||
// Nothing is stored on the server: the response is emailed once to the site inbox and that is all.
|
||||
const hits = new Map()
|
||||
// One confirmation per address per hour, so the form can't be used to mail someone repeatedly.
|
||||
const confirmedAt = new Map()
|
||||
const CONFIRM_COOLDOWN_MS = 60 * 60 * 1000
|
||||
|
||||
function mayConfirm(address) {
|
||||
const key = address.toLowerCase()
|
||||
const now = Date.now()
|
||||
const last = confirmedAt.get(key)
|
||||
if (typeof last === 'number' && now - last < CONFIRM_COOLDOWN_MS) return false
|
||||
confirmedAt.set(key, now)
|
||||
if (confirmedAt.size > 2000) {
|
||||
for (const [k, v] of confirmedAt) { if (now - v > CONFIRM_COOLDOWN_MS) confirmedAt.delete(k) }
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function rateLimit(req, res, next) {
|
||||
const ip = req.ip ?? 'unknown'
|
||||
const now = Date.now()
|
||||
const windowMs = 10 * 60 * 1000
|
||||
const entry = hits.get(ip) ?? { count: 0, start: now }
|
||||
if (now - entry.start > windowMs) { entry.count = 0; entry.start = now }
|
||||
entry.count += 1
|
||||
hits.set(ip, entry)
|
||||
if (hits.size > 2000) {
|
||||
for (const [k, v] of hits) { if (now - v.start > windowMs) hits.delete(k) }
|
||||
}
|
||||
if (entry.count > 3) {
|
||||
res.status(429).json({ message: 'Please wait a few minutes before trying again.' })
|
||||
return
|
||||
}
|
||||
next()
|
||||
}
|
||||
|
||||
function clean(value, max) {
|
||||
return typeof value === 'string' ? value.trim().replace(/\s+/g, ' ').slice(0, max) : ''
|
||||
}
|
||||
|
||||
|
||||
// The notification the site owner receives. Styled to match the other admin emails
|
||||
// (dark header, gold accent, cream cards) and written to be acted on, not just read.
|
||||
function buildSalvationEmail({ name, email, message, when }) {
|
||||
const who = name || 'Someone'
|
||||
const subject = name ? `A new decision for Christ: ${name}` : 'A new decision for Christ on your salvation page'
|
||||
const nameLine = name || 'Name not given'
|
||||
const safeName = escapeHtml(nameLine)
|
||||
const safeEmail = escapeHtml(email)
|
||||
const safeWhen = escapeHtml(when)
|
||||
|
||||
const followUp = email
|
||||
? [
|
||||
'Reply to this email within a day or two. A short, warm note is plenty.',
|
||||
'Congratulate them, and ask them to tell you their story.',
|
||||
'Point them to the Gospel of John, a Bible-teaching church, and baptism.',
|
||||
'Invite them to Start Here at versebyversewithnate.us/start-here.',
|
||||
'Pray for them by name.',
|
||||
]
|
||||
: ['They did not leave an email address, so there is no way to reply.', 'Pray for them. God knows exactly who they are.']
|
||||
|
||||
const text = [
|
||||
`A VERDICT HAS COME IN`,
|
||||
``,
|
||||
`${who} pleaded guilty and accepted Christ's pardon on the "The Gospel, in a Courtroom" page and says they prayed to receive Jesus as their Savior.`,
|
||||
``,
|
||||
`"There is joy in the presence of the angels of God over one sinner who repents." (Luke 15:10)`,
|
||||
``,
|
||||
`DETAILS`,
|
||||
`Name: ${nameLine}`,
|
||||
`Email: ${email || 'Not given'}`,
|
||||
`When: ${when}`,
|
||||
``,
|
||||
`THEIR MESSAGE`,
|
||||
message || '(They did not leave a message.)',
|
||||
``,
|
||||
`SUGGESTED FOLLOW-UP`,
|
||||
...followUp.map((t, i) => `${i + 1}. ${t}`),
|
||||
``,
|
||||
`This email is the only record of this response. Nothing is stored on the website, so keep it somewhere safe.`,
|
||||
email ? `Reply directly to this email to reach ${who}.` : '',
|
||||
].filter(l => l !== '').join('\n')
|
||||
|
||||
const row = (label, value, last = false) =>
|
||||
`<tr><td style="width:96px;padding:11px 0;font-family:Arial,sans-serif;font-size:12px;font-weight:700;letter-spacing:0.08em;text-transform:uppercase;color:#8a6d35;${last ? '' : 'border-bottom:1px solid #efe4cc;'}">${label}</td>` +
|
||||
`<td style="padding:11px 0;font-family:Arial,sans-serif;font-size:15px;color:#201a10;${last ? '' : 'border-bottom:1px solid #efe4cc;'}">${value}</td></tr>`
|
||||
|
||||
const steps = followUp
|
||||
.map(t => `<li style="margin:0 0 8px;font-family:Arial,sans-serif;font-size:15px;line-height:1.55;color:#201a10;">${escapeHtml(t)}</li>`)
|
||||
.join('')
|
||||
|
||||
const messageBlock = message
|
||||
? `<tr><td style="padding:0 28px 22px;">
|
||||
<div style="font-family:Arial,sans-serif;font-size:12px;font-weight:700;letter-spacing:0.14em;text-transform:uppercase;color:#8a6d35;margin:0 0 8px;">Their message</div>
|
||||
<div style="background:#fbf7ef;border-left:4px solid #c8860a;border-radius:4px;padding:16px 18px;font-family:Georgia,serif;font-size:16px;line-height:1.7;color:#201a10;white-space:pre-wrap;">${escapeHtml(message)}</div>
|
||||
</td></tr>`
|
||||
: `<tr><td style="padding:0 28px 22px;font-family:Arial,sans-serif;font-size:14px;color:#735a2b;font-style:italic;">They did not leave a message.</td></tr>`
|
||||
|
||||
const replyButton = email
|
||||
? `<tr><td align="center" style="padding:0 28px 26px;">
|
||||
<a href="mailto:${safeEmail}?subject=${encodeURIComponent('Welcome to the family of God')}" style="display:inline-block;background:#c8860a;color:#111111;font-family:Arial,sans-serif;font-size:14px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;text-decoration:none;padding:14px 30px;border-radius:4px;">Reply to ${escapeHtml(who)}</a>
|
||||
</td></tr>`
|
||||
: ''
|
||||
|
||||
const html = `<!doctype html><html><body style="margin:0;padding:0;background:#f5f1e8;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation" style="background:#f5f1e8;"><tr><td align="center" style="padding:28px 14px;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation" style="max-width:640px;background:#ffffff;border:1px solid #e1d3b2;border-radius:14px;overflow:hidden;">
|
||||
<tr><td style="background:#111111;padding:30px 28px 26px;text-align:center;border-bottom:4px solid #c8860a;">
|
||||
<div style="font-family:Arial,sans-serif;font-size:12px;letter-spacing:0.34em;text-transform:uppercase;color:#c8860a;">The Court of Heaven</div>
|
||||
<div style="font-size:40px;line-height:1;margin:14px 0 6px;color:#c8860a;">⚖</div>
|
||||
<h1 style="margin:0;font-family:Georgia,serif;font-size:30px;line-height:1.2;color:#f4ead5;">A Verdict Has Come In</h1>
|
||||
<p style="margin:10px 0 0;font-family:Georgia,serif;font-style:italic;font-size:17px;color:#d9c9a3;">${escapeHtml(who)} pleaded guilty and accepted the pardon.</p>
|
||||
</td></tr>
|
||||
<tr><td style="padding:28px 28px 8px;">
|
||||
<p style="margin:0 0 14px;font-family:Georgia,serif;font-size:17px;line-height:1.7;color:#201a10;">Someone just worked through <em>The Gospel, in a Courtroom</em> on your website, pleaded guilty, and says they prayed to receive Jesus as their Savior.</p>
|
||||
<p style="margin:0 0 20px;font-family:Georgia,serif;font-style:italic;font-size:16px;line-height:1.6;color:#57452b;border-left:3px solid #c8860a;padding-left:14px;">“There is joy in the presence of the angels of God over one sinner who repents.” <span style="font-style:normal;font-size:13px;color:#8a6d35;">Luke 15:10</span></p>
|
||||
</td></tr>
|
||||
<tr><td style="padding:0 28px 22px;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation" style="border-top:2px solid #c8860a;">
|
||||
${row('Name', safeName)}
|
||||
${row('Email', email ? `<a href="mailto:${safeEmail}" style="color:#8f5f05;text-decoration:none;">${safeEmail}</a>` : '<span style="color:#735a2b;font-style:italic;">Not given</span>')}
|
||||
${row('When', safeWhen, true)}
|
||||
</table>
|
||||
</td></tr>
|
||||
${messageBlock}
|
||||
${replyButton}
|
||||
<tr><td style="padding:0 28px 26px;">
|
||||
<div style="background:#f7f2e5;border:1px solid #e8dcc1;border-radius:10px;padding:18px 22px;">
|
||||
<div style="font-family:Arial,sans-serif;font-size:12px;font-weight:700;letter-spacing:0.14em;text-transform:uppercase;color:#8a6d35;margin:0 0 12px;">Suggested follow-up</div>
|
||||
<ol style="margin:0;padding-left:20px;">${steps}</ol>
|
||||
</div>
|
||||
</td></tr>
|
||||
<tr><td style="background:#f7f2e5;border-top:1px solid #e8dcc1;padding:16px 28px;">
|
||||
<p style="margin:0;font-family:Arial,sans-serif;font-size:12px;line-height:1.6;color:#735a2b;"><strong>Keep this email.</strong> It is the only record of this response. Nothing is stored on the website. ${email ? 'Replying to this message goes straight to them.' : ''}</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr></table></body></html>`
|
||||
|
||||
return { subject, text, html }
|
||||
}
|
||||
|
||||
// The warm, one-time confirmation the visitor receives at the address they gave.
|
||||
function buildSalvationConfirmationEmail({ name }) {
|
||||
const base = getCanonicalBaseUrl().replace(/\/$/, '')
|
||||
const greeting = name ? `Hi ${name},` : 'Hi friend,'
|
||||
const subject = 'We received your message. Welcome to the family of God'
|
||||
const steps = [
|
||||
['Read the Gospel of John.', 'Start there, then keep going through the New Testament.'],
|
||||
['Talk to God every day.', 'Prayer is simply talking with him, in your own words.'],
|
||||
['Tell someone.', 'Share your decision with a Christian friend or family member.'],
|
||||
['Find a church.', 'Join a Bible-teaching church, and be baptized as a public sign of your faith (Acts 2:38).'],
|
||||
]
|
||||
|
||||
const text = [
|
||||
greeting,
|
||||
'',
|
||||
'Thank you for letting us know that you prayed to receive Jesus. We are rejoicing with you, and your message has been received.',
|
||||
'Someone from our team will reach out to you personally soon.',
|
||||
'',
|
||||
'"Therefore, there is now no condemnation for those who are in Christ Jesus." (Romans 8:1)',
|
||||
'You are no longer a defendant. You are a child of the Judge.',
|
||||
'',
|
||||
'WHAT TO DO NEXT',
|
||||
...steps.map(([h, b], i) => `${i + 1}. ${h} ${b}`),
|
||||
'',
|
||||
`A good path through the podcast and studies: ${base}/start-here`,
|
||||
`Questions? Ask here: ${base}/contact?source=salvation`,
|
||||
'',
|
||||
'Grace and peace,',
|
||||
'Verse by Verse with Nate',
|
||||
'',
|
||||
`You are receiving this one-time email because this address was entered on ${base}/salvation. If that was not you, you can safely ignore it.`,
|
||||
].join('\n')
|
||||
|
||||
const stepRows = steps
|
||||
.map(([h, b], i) =>
|
||||
`<tr><td valign="top" style="width:34px;padding:0 0 14px;"><div style="width:26px;height:26px;border-radius:13px;background:#c8860a;color:#111;font-family:Arial,sans-serif;font-size:13px;font-weight:700;line-height:26px;text-align:center;">${i + 1}</div></td>` +
|
||||
`<td style="padding:2px 0 14px;font-family:Arial,sans-serif;font-size:15px;line-height:1.55;color:#201a10;"><strong>${escapeHtml(h)}</strong> ${escapeHtml(b)}</td></tr>`)
|
||||
.join('')
|
||||
|
||||
const html = `<!doctype html><html><body style="margin:0;padding:0;background:#f5f1e8;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation" style="background:#f5f1e8;"><tr><td align="center" style="padding:28px 14px;">
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation" style="max-width:600px;background:#ffffff;border:1px solid #e1d3b2;border-radius:14px;overflow:hidden;">
|
||||
<tr><td style="background:#111111;padding:30px 28px 26px;text-align:center;border-bottom:4px solid #c8860a;">
|
||||
<div style="font-family:Arial,sans-serif;font-size:12px;letter-spacing:0.34em;text-transform:uppercase;color:#c8860a;">Verse by Verse with Nate</div>
|
||||
<div style="width:54px;height:54px;border-radius:27px;background:#c8860a;color:#111111;font-family:Arial,sans-serif;font-size:30px;font-weight:700;line-height:54px;margin:16px auto 10px;">✓</div>
|
||||
<h1 style="margin:0;font-family:Georgia,serif;font-size:28px;line-height:1.25;color:#f4ead5;">Your message was received</h1>
|
||||
<p style="margin:10px 0 0;font-family:Georgia,serif;font-style:italic;font-size:17px;color:#d9c9a3;">Welcome to the family of God.</p>
|
||||
</td></tr>
|
||||
<tr><td style="padding:30px 28px 6px;">
|
||||
<p style="margin:0 0 16px;font-family:Georgia,serif;font-size:18px;line-height:1.6;color:#201a10;">${escapeHtml(greeting)}</p>
|
||||
<p style="margin:0 0 16px;font-family:Georgia,serif;font-size:17px;line-height:1.7;color:#201a10;">Thank you for letting us know that you prayed to receive Jesus. We are rejoicing with you, and your message has been received.</p>
|
||||
<p style="margin:0 0 22px;font-family:Georgia,serif;font-size:17px;line-height:1.7;color:#201a10;"><strong>Someone from our team will reach out to you personally soon.</strong></p>
|
||||
</td></tr>
|
||||
<tr><td style="padding:0 28px 26px;">
|
||||
<div style="background:#fbf7ef;border-left:4px solid #c8860a;border-radius:4px;padding:18px 20px;">
|
||||
<p style="margin:0 0 8px;font-family:Georgia,serif;font-style:italic;font-size:17px;line-height:1.6;color:#201a10;">“Therefore, there is now no condemnation for those who are in Christ Jesus.” <span style="font-style:normal;font-size:13px;color:#8a6d35;">Romans 8:1</span></p>
|
||||
<p style="margin:0;font-family:Georgia,serif;font-size:15px;line-height:1.6;color:#57452b;">You are no longer a defendant. You are a child of the Judge.</p>
|
||||
</div>
|
||||
</td></tr>
|
||||
<tr><td style="padding:0 28px 8px;">
|
||||
<div style="font-family:Arial,sans-serif;font-size:12px;font-weight:700;letter-spacing:0.14em;text-transform:uppercase;color:#8a6d35;margin:0 0 14px;">What to do next</div>
|
||||
<table width="100%" cellpadding="0" cellspacing="0" border="0" role="presentation">${stepRows}</table>
|
||||
</td></tr>
|
||||
<tr><td align="center" style="padding:6px 28px 8px;">
|
||||
<a href="${escapeHtml(base)}/start-here" style="display:inline-block;background:#c8860a;color:#111111;font-family:Arial,sans-serif;font-size:14px;font-weight:700;letter-spacing:0.1em;text-transform:uppercase;text-decoration:none;padding:14px 28px;border-radius:4px;">Start Here</a>
|
||||
</td></tr>
|
||||
<tr><td align="center" style="padding:6px 28px 26px;font-family:Arial,sans-serif;font-size:14px;color:#57452b;">
|
||||
Have a question? <a href="${escapeHtml(base)}/contact?source=salvation" style="color:#8f5f05;">Ask us here</a>, or just reply to this email.
|
||||
</td></tr>
|
||||
<tr><td style="padding:0 28px 28px;">
|
||||
<p style="margin:0;font-family:Georgia,serif;font-size:16px;line-height:1.6;color:#201a10;">Grace and peace,<br><strong>Verse by Verse with Nate</strong></p>
|
||||
</td></tr>
|
||||
<tr><td style="background:#f7f2e5;border-top:1px solid #e8dcc1;padding:16px 28px;">
|
||||
<p style="margin:0;font-family:Arial,sans-serif;font-size:12px;line-height:1.6;color:#735a2b;">You are receiving this one-time email because this address was entered at ${escapeHtml(base)}/salvation. If that was not you, you can safely ignore it.</p>
|
||||
</td></tr>
|
||||
</table>
|
||||
</td></tr></table></body></html>`
|
||||
|
||||
return { subject, text, html }
|
||||
}
|
||||
|
||||
export function register(app) {
|
||||
// The /salvation page is static HTML, so it asks the server for the narration URLs set in Admin → Gospel Page.
|
||||
app.get('/api/salvation-audio', (_req, res) => {
|
||||
const c = state.cachedSiteContent ?? {}
|
||||
res.set('Cache-Control', 'public, max-age=300')
|
||||
res.json({
|
||||
url: sanitizeUrl(c.salvationAudioUrl) || '',
|
||||
guiltyUrl: sanitizeUrl(c.salvationAudioGuiltyUrl) || '',
|
||||
notGuiltyUrl: sanitizeUrl(c.salvationAudioNotGuiltyUrl) || '',
|
||||
})
|
||||
})
|
||||
|
||||
app.post('/api/salvation-response', rateLimit, async (req, res) => {
|
||||
const { name, email, message, _honey } = req.body ?? {}
|
||||
if (_honey) { res.json({ ok: true }); return }
|
||||
|
||||
const safeName = clean(name, 100)
|
||||
const safeEmail = clean(email, 200)
|
||||
const safeMessage = typeof message === 'string' ? message.trim().slice(0, 2000) : ''
|
||||
if (safeEmail && !/^[a-zA-Z0-9._%+\-]{1,64}@[a-zA-Z0-9.\-]{1,253}\.[a-zA-Z]{2,}$/.test(safeEmail)) {
|
||||
res.status(400).json({ message: 'That email address does not look right. You can also leave it blank.' })
|
||||
return
|
||||
}
|
||||
|
||||
if (!process.env.RESEND_API_KEY) {
|
||||
console.error('[salvation] RESEND_API_KEY env var not set')
|
||||
res.status(503).json({ message: 'We could not send this right now.' })
|
||||
return
|
||||
}
|
||||
|
||||
const when = new Date().toLocaleString('en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: '2-digit', timeZone: 'America/New_York', timeZoneName: 'short' })
|
||||
const { subject, text, html } = buildSalvationEmail({ name: safeName, email: safeEmail, message: safeMessage, when })
|
||||
|
||||
try {
|
||||
const resend = new Resend(process.env.RESEND_API_KEY)
|
||||
await sendResendEmailWithRetry({
|
||||
resend,
|
||||
context: 'salvation-response',
|
||||
payload: {
|
||||
from: getResendFromAddress(),
|
||||
to: [getResendInboxAddress()],
|
||||
...(safeEmail ? { replyTo: safeEmail } : {}),
|
||||
subject,
|
||||
tags: [{ name: 'flow', value: 'salvation-response' }],
|
||||
text,
|
||||
html,
|
||||
},
|
||||
})
|
||||
|
||||
// Best effort: a failed or skipped confirmation must never turn a delivered decision into an error.
|
||||
let confirmationSent = false
|
||||
if (safeEmail && mayConfirm(safeEmail)) {
|
||||
try {
|
||||
const confirmation = buildSalvationConfirmationEmail({ name: safeName })
|
||||
await sendResendEmailWithRetry({
|
||||
resend,
|
||||
context: 'salvation-confirmation',
|
||||
payload: {
|
||||
from: getResendFromAddress(),
|
||||
to: [safeEmail],
|
||||
replyTo: getResendReplyToAddress(),
|
||||
subject: confirmation.subject,
|
||||
tags: [{ name: 'flow', value: 'salvation-confirmation' }],
|
||||
text: confirmation.text,
|
||||
html: confirmation.html,
|
||||
},
|
||||
})
|
||||
confirmationSent = true
|
||||
} catch (confirmErr) {
|
||||
console.error('[salvation] confirmation email failed:', confirmErr?.message ?? confirmErr)
|
||||
}
|
||||
}
|
||||
res.json({ ok: true, confirmationSent })
|
||||
} catch (err) {
|
||||
console.error('[salvation] email failed:', err?.message ?? err)
|
||||
res.status(502).json({ message: 'We could not send this right now.' })
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { noteEntriesToText } from '../../shared/note-format.js'
|
||||
import { randomUUID, timingSafeEqual } from 'node:crypto'
|
||||
import rateLimit from 'express-rate-limit'
|
||||
import { Document, Packer, Paragraph, HeadingLevel, TextRun } from 'docx'
|
||||
@@ -87,7 +88,7 @@ export function register(app) {
|
||||
const sectionId = dashIndex >= 0 ? noteKey.slice(dashIndex + 2) : noteKey
|
||||
if (!studyEntries[studySlug]) studyEntries[studySlug] = {}
|
||||
studyEntries[studySlug][sectionId] = studyEntries[studySlug][sectionId] || {}
|
||||
studyEntries[studySlug][sectionId].noteText = noteText.trim()
|
||||
studyEntries[studySlug][sectionId].noteText = noteEntriesToText(noteText) || noteText.trim()
|
||||
}
|
||||
|
||||
for (const [studySlug, studyProgress] of Object.entries(progress.byStudy)) {
|
||||
|
||||
@@ -117,7 +117,8 @@ export function register(app) {
|
||||
passwordHash: hashStudyPassword(password),
|
||||
displayName,
|
||||
subscribeNewsletter: subscribe,
|
||||
studyRemindersEnabled: false,
|
||||
studyRemindersEnabled: true,
|
||||
remindersDefaultedAt: now,
|
||||
pendingEmailChange: null,
|
||||
emailVerified: false,
|
||||
pendingEmailVerification: {
|
||||
|
||||
@@ -147,7 +147,11 @@ export function register(app) {
|
||||
return
|
||||
}
|
||||
const rawNote = typeof req.body?.note === 'string' ? req.body.note : ''
|
||||
const note = rawNote.trim().slice(0, MAX_STUDY_NOTE_LENGTH)
|
||||
const note = rawNote.trim()
|
||||
if (note.length > MAX_STUDY_NOTE_LENGTH) {
|
||||
res.status(413).json({ message: 'This lesson\'s notes are too long to save. Please trim some text.' })
|
||||
return
|
||||
}
|
||||
const notes = await loadUserNotes(user.id)
|
||||
|
||||
if (!note) {
|
||||
|
||||
@@ -96,6 +96,9 @@ export const state = {
|
||||
// newsletterIssues: Array<{ id, resendBroadcastId, slug, title, subject, description, html, sentAt, publishedAt, public }>
|
||||
newsletterIssues: [],
|
||||
newsletterIssuesWritePromise: Promise.resolve(),
|
||||
// nuggetsEpisodeTags: { [audioUrl]: string[] } — admin-assigned tags for Nuggets RSS episodes
|
||||
nuggetsEpisodeTags: {},
|
||||
nuggetsEpisodeTagsWritePromise: Promise.resolve(),
|
||||
|
||||
|
||||
auditLog: [],
|
||||
|
||||
@@ -476,6 +476,21 @@ export function normalizeHitPath(pathname) {
|
||||
return pathname
|
||||
}
|
||||
|
||||
// Top-level URL segments the SPA / static pages actually serve. Anything else is a probe or
|
||||
// scanner hit, which must not count as a real visit or add a new key to the per-path stats.
|
||||
const KNOWN_SITE_SEGMENTS = new Set([
|
||||
'start-here', 'study', 'finished', 'episodes', 'nuggets', 'resources', 'downloads', 'about', 'contact',
|
||||
'questions', 'newsletter', 'scripture', 'thanks', 'subscribe', 'certificate', 'host', 'admin', 'preview',
|
||||
'privacy', 'terms', 'salvation', 'qr',
|
||||
])
|
||||
|
||||
const MAX_UNKNOWN_PATHS = 300
|
||||
|
||||
export function isKnownSitePath(pathname) {
|
||||
const first = String(pathname ?? '/').split('/')[1] ?? ''
|
||||
return first === '' || KNOWN_SITE_SEGMENTS.has(first)
|
||||
}
|
||||
|
||||
export function shouldCountHit(req) {
|
||||
if (req.method !== 'GET') return false
|
||||
if (req.path.startsWith('/api/')) return false
|
||||
@@ -580,6 +595,21 @@ export function recordHit(pathname, isBot = false, botReason = null) {
|
||||
state.hitStats.lastHitAt = nowIso
|
||||
state.hitStats.firstHitAt = state.hitStats.firstHitAt ?? nowIso
|
||||
|
||||
if (isBot && botReason === 'unknown-path') {
|
||||
// Probe/scanner URLs: keep a bounded list for the admin view instead of one stats key per URL
|
||||
const unknown = (state.hitStats.byPathUnknown ??= {})
|
||||
const key = safePath.slice(0, 120)
|
||||
if (key in unknown || Object.keys(unknown).length < MAX_UNKNOWN_PATHS) unknown[key] = (unknown[key] ?? 0) + 1
|
||||
else unknown['(other)'] = (unknown['(other)'] ?? 0) + 1
|
||||
state.hitStats.botHits += 1
|
||||
state.hitStats.byPathBot['(unknown)'] = (state.hitStats.byPathBot['(unknown)'] ?? 0) + 1
|
||||
state.hitStats.byDayBot[dayKey] = (state.hitStats.byDayBot[dayKey] ?? 0) + 1
|
||||
state.hitStats.botReasons[botReason] = (state.hitStats.botReasons[botReason] ?? 0) + 1
|
||||
state.hitStats.byPath['(unknown)'] = (state.hitStats.byPath['(unknown)'] ?? 0) + 1
|
||||
state.hitStats.byDay[dayKey] = (state.hitStats.byDay[dayKey] ?? 0) + 1
|
||||
return
|
||||
}
|
||||
|
||||
if (isBot) {
|
||||
state.hitStats.botHits += 1
|
||||
state.hitStats.byPathBot[safePath] = (state.hitStats.byPathBot[safePath] ?? 0) + 1
|
||||
@@ -706,6 +736,23 @@ export function extractResendMessageId(result) {
|
||||
return ''
|
||||
}
|
||||
|
||||
// One-off pass: lesson reminders are now on by default, so switch them on for accounts that
|
||||
// predate the default. Each account is marked as it is handled, so a later opt-out sticks.
|
||||
export async function backfillReminderDefault() {
|
||||
const now = new Date().toISOString()
|
||||
let updated = 0
|
||||
for (const user of state.studyUsers) {
|
||||
if (user.remindersDefaultedAt) continue
|
||||
if (user.studyRemindersEnabled !== true) {
|
||||
user.studyRemindersEnabled = true
|
||||
updated++
|
||||
}
|
||||
user.remindersDefaultedAt = now
|
||||
}
|
||||
if (state.studyUsers.some(user => user.remindersDefaultedAt === now)) queueStudyUsersWrite()
|
||||
return updated
|
||||
}
|
||||
|
||||
// ── Study reminder scheduler ───────────────────────────────────────────────
|
||||
|
||||
export async function scheduleStudyReminders(sendStudyReminderEmail) {
|
||||
|
||||
+32
-1
@@ -67,7 +67,7 @@ export const BIBLE_BOOKS = [
|
||||
{ id: 'TH2', name: '2 Thessalonians', aliases: ['2 thess'] },
|
||||
{ id: 'TI1', name: '1 Timothy', aliases: ['1 tim'] },
|
||||
{ id: 'TI2', name: '2 Timothy', aliases: ['2 tim'] },
|
||||
{ id: 'TIT', name: 'Titus' },
|
||||
{ id: 'TIT', name: 'Titus', aliases: ['tit'] },
|
||||
{ id: 'PHM', name: 'Philemon', aliases: ['philem'] },
|
||||
{ id: 'HEB', name: 'Hebrews', aliases: ['heb'] },
|
||||
{ id: 'JAM', name: 'James', aliases: ['jas'] },
|
||||
@@ -85,3 +85,34 @@ export function bookNumberFor(usfmId) {
|
||||
const index = BIBLE_BOOKS.findIndex(b => b.id === usfmId)
|
||||
return index === -1 ? null : index + 1
|
||||
}
|
||||
|
||||
let referenceBookLookup = null
|
||||
|
||||
/**
|
||||
* Checks a passage reference the way the Scripture Index and passage fetch read it.
|
||||
* `bookHint` is the study's Bible Book field (or slug) and is used when the reference
|
||||
* has no book of its own ("1:1-2"). Returns null when it will work, otherwise a short
|
||||
* message explaining what to change.
|
||||
*/
|
||||
export function checkPassageReference(reference, bookHint) {
|
||||
if (!referenceBookLookup) {
|
||||
referenceBookLookup = new Set()
|
||||
for (const b of BIBLE_BOOKS) {
|
||||
for (const key of [b.name.toLowerCase(), ...(b.aliases ?? [])]) {
|
||||
referenceBookLookup.add(key)
|
||||
referenceBookLookup.add(key.replace(/\s+/g, ''))
|
||||
}
|
||||
}
|
||||
}
|
||||
const clean = String(reference ?? '').replace(/[–—]/g, '-').replace(/(\d)[a-z]\b/gi, '$1').trim()
|
||||
if (!clean) return null
|
||||
const m = clean.match(/^(?:(.*?)\s+)?(\d+):(\d+)(?:-(?:(\d+):)?(\d+))?$/)
|
||||
if (!m) return 'Use the form 1:1-2 (chapter:verse, optional range). It will be listed under "Other references" in the Scripture Index until fixed.'
|
||||
const book = (m[1] ?? String(bookHint ?? '')).toLowerCase().replace(/\.\s*/g, ' ').trim()
|
||||
if (!book || !referenceBookLookup.has(book)) {
|
||||
return m[1]
|
||||
? `"${m[1]}" is not a recognized Bible book name.`
|
||||
: 'Set this study\'s "Bible Book" field (e.g. titus) so this reference can be matched to a book.'
|
||||
}
|
||||
return null
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
export type NoteAnchorId = 'scripture' | 'commentary' | 'questions' | 'general'
|
||||
export interface NoteEntry {
|
||||
id: string
|
||||
anchor: NoteAnchorId
|
||||
html: string
|
||||
updatedAt: string | null
|
||||
}
|
||||
export const NOTE_ANCHORS: NoteAnchorId[]
|
||||
export const NOTE_ANCHOR_LABELS: Record<NoteAnchorId, string>
|
||||
export function newNoteId(): string
|
||||
export function parseNoteEntries(raw: string): NoteEntry[]
|
||||
export function serializeNoteEntries(entries: NoteEntry[]): string
|
||||
export function noteHtmlToText(html: string): string
|
||||
export function noteEntriesToText(raw: string): string
|
||||
@@ -0,0 +1,79 @@
|
||||
// Lesson note storage format, shared by the client and the server.
|
||||
//
|
||||
// Each lesson's notes are stored as one string. Current format (v2):
|
||||
// {"v":2,"entries":[{"id","anchor","html","updatedAt"}]}
|
||||
// Legacy format (v1) was a JSON object of { anchor: html }, and older still was
|
||||
// plain text. Both are still read and are upgraded to v2 on the next save.
|
||||
|
||||
export const NOTE_ANCHORS = ['scripture', 'commentary', 'questions', 'general']
|
||||
|
||||
export const NOTE_ANCHOR_LABELS = {
|
||||
scripture: 'Scripture Text',
|
||||
commentary: 'Commentary',
|
||||
questions: 'Reflection Questions',
|
||||
general: 'General Notes',
|
||||
}
|
||||
|
||||
export function newNoteId() {
|
||||
return `n${Date.now().toString(36)}${Math.random().toString(36).slice(2, 7)}`
|
||||
}
|
||||
|
||||
export function parseNoteEntries(raw) {
|
||||
if (typeof raw !== 'string' || !raw.trim()) return []
|
||||
let parsed = null
|
||||
try {
|
||||
parsed = JSON.parse(raw)
|
||||
} catch {
|
||||
// Legacy plain-text note.
|
||||
return [{ id: newNoteId(), anchor: 'general', html: raw, updatedAt: null }]
|
||||
}
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
return [{ id: newNoteId(), anchor: 'general', html: raw, updatedAt: null }]
|
||||
}
|
||||
if (parsed.v === 2 && Array.isArray(parsed.entries)) {
|
||||
return parsed.entries
|
||||
.filter(e => e && typeof e.html === 'string' && e.html.trim())
|
||||
.map(e => ({
|
||||
id: typeof e.id === 'string' && e.id ? e.id : newNoteId(),
|
||||
anchor: NOTE_ANCHORS.includes(e.anchor) ? e.anchor : 'general',
|
||||
html: e.html,
|
||||
updatedAt: typeof e.updatedAt === 'string' ? e.updatedAt : null,
|
||||
}))
|
||||
}
|
||||
return Object.entries(parsed)
|
||||
.filter(([, html]) => typeof html === 'string' && html.trim())
|
||||
.map(([anchor, html]) => ({
|
||||
id: `legacy-${anchor}`,
|
||||
anchor: NOTE_ANCHORS.includes(anchor) ? anchor : 'general',
|
||||
html,
|
||||
updatedAt: null,
|
||||
}))
|
||||
}
|
||||
|
||||
export function serializeNoteEntries(entries) {
|
||||
const kept = entries.filter(e => e.html && e.html.trim())
|
||||
if (kept.length === 0) return ''
|
||||
return JSON.stringify({ v: 2, entries: kept })
|
||||
}
|
||||
|
||||
export function noteHtmlToText(html) {
|
||||
return String(html)
|
||||
.replace(/<\/(p|li|h[1-6]|blockquote)>/gi, '\n')
|
||||
.replace(/<br\s*\/?>/gi, '\n')
|
||||
.replace(/<[^>]*>/g, '')
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, "'")
|
||||
.replace(/&/g, '&')
|
||||
.replace(/\n{3,}/g, '\n\n')
|
||||
.trim()
|
||||
}
|
||||
|
||||
// Plain-text rendering of a whole lesson's notes (used by the Word export).
|
||||
export function noteEntriesToText(raw) {
|
||||
return parseNoteEntries(raw)
|
||||
.map(e => `${NOTE_ANCHOR_LABELS[e.anchor]}\n${noteHtmlToText(e.html)}`)
|
||||
.join('\n\n')
|
||||
}
|
||||
+172
-3
@@ -1,3 +1,4 @@
|
||||
import { checkPassageReference } from '../shared/bible-books.js'
|
||||
import DOMPurify from 'dompurify'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import { DndContext, closestCenter, PointerSensor, useSensor, useSensors } from '@dnd-kit/core'
|
||||
@@ -616,6 +617,8 @@ export interface AdminStats {
|
||||
topPaths: Array<{ path: string; hits: number }>
|
||||
topPathsReal: Array<{ path: string; hits: number }>
|
||||
topPathsBot: Array<{ path: string; hits: number }>
|
||||
topUnknownPaths?: Array<{ path: string; hits: number }>
|
||||
uniqueVisitors7d?: number
|
||||
last7Days: Array<{ day: string; hits: number }>
|
||||
last7DaysReal: Array<{ day: string; hits: number }>
|
||||
last7DaysBot: Array<{ day: string; hits: number }>
|
||||
@@ -736,11 +739,11 @@ type StringField = Exclude<keyof SiteContent, 'customLinks' | 'customBlocks' | '
|
||||
type AdminView =
|
||||
| 'dashboard'
|
||||
| 'homepage:hero' | 'homepage:share' | 'homepage:prism' | 'homepage:where-to-next'
|
||||
| 'start-here'
|
||||
| 'start-here' | 'salvation'
|
||||
| 'about:show-copy' | 'about:bio' | 'about:testimonials'
|
||||
| 'contact:profile' | 'contact:copy'
|
||||
| 'podcast:current-series' | 'podcast:highlights' | 'podcast:finished-books' | 'podcast:scripts' | 'podcast:workflow' | 'podcast:season-check' | 'podcast:rss'
|
||||
| 'nuggets:settings' | 'nuggets:hosts' | 'nuggets:upload-portal' | 'nuggets:announcement' | 'nuggets:guidelines' | 'nuggets:history' | 'nuggets:workflow'
|
||||
| 'nuggets:settings' | 'nuggets:hosts' | 'nuggets:upload-portal' | 'nuggets:announcement' | 'nuggets:guidelines' | 'nuggets:history' | 'nuggets:workflow' | 'nuggets:tags'
|
||||
| 'downloads' | 'custom-links' | 'content-blocks' | 'books' | 'recommended-resources'
|
||||
| 'inbox'
|
||||
| 'questions' | 'study-comments' | 'analytics' | 'assets' | 'colossians-study' | 'qr-codes'
|
||||
@@ -772,6 +775,7 @@ const ADMIN_NAV: NavGroup[] = [
|
||||
{ kind: 'leaf', view: 'homepage:where-to-next', label: 'Where to Next' },
|
||||
]},
|
||||
{ kind: 'leaf', view: 'start-here', label: 'Start Here' },
|
||||
{ kind: 'leaf', view: 'salvation', label: 'Gospel Page' },
|
||||
{ kind: 'parent', id: 'about', label: 'About', children: [
|
||||
{ kind: 'leaf', view: 'about:show-copy', label: 'Show Copy' },
|
||||
{ kind: 'leaf', view: 'about:bio', label: 'Nate Bio' },
|
||||
@@ -802,6 +806,7 @@ const ADMIN_NAV: NavGroup[] = [
|
||||
{ kind: 'leaf', view: 'nuggets:announcement', label: 'Announcement' },
|
||||
{ kind: 'leaf', view: 'nuggets:guidelines', label: 'Recording Guidelines' },
|
||||
{ kind: 'leaf', view: 'nuggets:workflow', label: 'Episode Workflow' },
|
||||
{ kind: 'leaf', view: 'nuggets:tags', label: 'Episode Tags' },
|
||||
{ kind: 'leaf', view: 'nuggets:history', label: 'Upload History' },
|
||||
]},
|
||||
{ kind: 'leaf', view: 'colossians-study', label: 'Studies' },
|
||||
@@ -879,6 +884,7 @@ const ADMIN_SECTION_LINKS: Partial<Record<AdminView, AdminSectionLink[]>> = {
|
||||
{ id: 'global-header', label: 'Header' },
|
||||
{ id: 'global-platforms', label: 'Platform URLs' },
|
||||
{ id: 'global-banner', label: 'Analytics Banner' },
|
||||
{ id: 'global-verse', label: 'Verse of the Week' },
|
||||
{ id: 'global-welcome-email', label: 'Welcome Email' },
|
||||
],
|
||||
'start-here': [
|
||||
@@ -1022,6 +1028,7 @@ const FIELDS: Array<{ key: StringField; label: string; multiline?: boolean; sect
|
||||
{ key: 'platformCreatorUrl', label: 'Platform — Creator Profile URL', section: 'global' },
|
||||
{ key: 'platformKofiUrl', label: 'Platform — Ko-fi URL', section: 'global' },
|
||||
{ key: 'platformKofiQrUrl', label: 'Platform — Ko-fi QR Code Image URL', section: 'global' },
|
||||
{ key: 'verseOfTheWeek', label: 'Scripture Index — Verse of the Week (optional)', section: 'global' },
|
||||
{ key: 'welcomeEmailSubject', label: 'Welcome Email — Subject', section: 'global' },
|
||||
{ key: 'welcomeEmailGreetingPrefix', label: 'Welcome Email — Greeting Prefix', section: 'global' },
|
||||
{ key: 'welcomeEmailIntro', label: 'Welcome Email — Intro Paragraph', multiline: true, section: 'global' },
|
||||
@@ -1627,6 +1634,115 @@ function NuggetsHistoryAdmin() {
|
||||
)
|
||||
}
|
||||
|
||||
// ── Nuggets Episode Tags admin ─────────────────────────────────────────────
|
||||
interface NuggetsTagEpisode {
|
||||
title: string
|
||||
pubDate: string
|
||||
audioUrl: string
|
||||
episode: string
|
||||
tags: string[]
|
||||
}
|
||||
|
||||
function NuggetsTagsAdmin() {
|
||||
const [episodes, setEpisodes] = useState<NuggetsTagEpisode[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState('')
|
||||
const [drafts, setDrafts] = useState<Record<string, string>>({})
|
||||
const [filter, setFilter] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
fetch('/api/admin/nuggets/episode-tags')
|
||||
.then(r => r.ok ? r.json() : Promise.reject(r.status))
|
||||
.then(d => setEpisodes(Array.isArray(d.episodes) ? d.episodes : []))
|
||||
.catch(() => setError('Could not load episodes. Check the RSS feed URL in Show Settings.'))
|
||||
.finally(() => setLoading(false))
|
||||
}, [])
|
||||
|
||||
const allTags = Array.from(new Set(episodes.flatMap(e => e.tags))).sort((a, b) => a.localeCompare(b))
|
||||
|
||||
async function saveTags(audioUrl: string, tags: string[]) {
|
||||
const prev = episodes
|
||||
setEpisodes(eps => eps.map(e => e.audioUrl === audioUrl ? { ...e, tags } : e))
|
||||
try {
|
||||
const r = await fetch('/api/admin/nuggets/episode-tags', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ audioUrl, tags }),
|
||||
})
|
||||
if (!r.ok) throw new Error()
|
||||
const d = await r.json()
|
||||
setEpisodes(eps => eps.map(e => e.audioUrl === audioUrl ? { ...e, tags: d.tags ?? tags } : e))
|
||||
} catch {
|
||||
setEpisodes(prev)
|
||||
setError('Could not save tags. Please try again.')
|
||||
}
|
||||
}
|
||||
|
||||
function addTags(ep: NuggetsTagEpisode) {
|
||||
const raw = (drafts[ep.audioUrl] ?? '').split(',').map(t => t.trim()).filter(Boolean)
|
||||
if (!raw.length) return
|
||||
setDrafts(d => ({ ...d, [ep.audioUrl]: '' }))
|
||||
saveTags(ep.audioUrl, [...ep.tags, ...raw.filter(t => !ep.tags.some(x => x.toLowerCase() === t.toLowerCase()))])
|
||||
}
|
||||
|
||||
const visible = filter.trim()
|
||||
? episodes.filter(e => `${e.title} ${e.tags.join(' ')}`.toLowerCase().includes(filter.toLowerCase()))
|
||||
: episodes
|
||||
|
||||
return (
|
||||
<section className="admin-panel-section" aria-label="Nuggets episode tags">
|
||||
<div className="admin-panel-head">
|
||||
<h2>Nuggets — Episode Tags</h2>
|
||||
<p>Tag episodes by topic or book. Visitors can filter the Nuggets page by these tags. Type a tag and press Enter (or separate several with commas).</p>
|
||||
</div>
|
||||
{error && <p className="admin-stats-note" role="alert">{error}</p>}
|
||||
{loading ? <p className="admin-stats-note">Loading…</p> : (
|
||||
<>
|
||||
<datalist id="nuggets-tag-suggestions">
|
||||
{allTags.map(t => <option key={t} value={t} />)}
|
||||
</datalist>
|
||||
{episodes.length > 0 && (
|
||||
<div className="admin-field" style={{ maxWidth: 320, marginBottom: 12 }}>
|
||||
<input type="text" placeholder="Filter by title or tag…" value={filter} onChange={e => setFilter(e.target.value)} />
|
||||
</div>
|
||||
)}
|
||||
{visible.length === 0 ? (
|
||||
<p className="admin-stats-note">{episodes.length === 0 ? 'No episodes found in the feed yet.' : 'No results match that filter.'}</p>
|
||||
) : visible.map(ep => (
|
||||
<div key={ep.audioUrl} style={{ padding: '10px 0', borderBottom: '1px solid var(--color-border, #e5e0d5)' }}>
|
||||
<div style={{ fontWeight: 600, marginBottom: 6 }}>
|
||||
{ep.episode ? `Ep. ${ep.episode} — ` : ''}{ep.title}
|
||||
<span style={{ fontWeight: 400, opacity: 0.6, marginLeft: 8, fontSize: '0.8rem' }}>
|
||||
{Number.isNaN(new Date(ep.pubDate).getTime()) ? '' : new Date(ep.pubDate).toLocaleDateString()}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 6, alignItems: 'center' }}>
|
||||
{ep.tags.map(t => (
|
||||
<span key={t} style={{ display: 'inline-flex', alignItems: 'center', gap: 4, background: 'rgba(201,168,76,0.15)', borderRadius: 999, padding: '2px 10px', fontSize: '0.82rem' }}>
|
||||
{t}
|
||||
<button type="button" aria-label={`Remove tag ${t}`} onClick={() => saveTags(ep.audioUrl, ep.tags.filter(x => x !== t))} style={{ border: 'none', background: 'none', cursor: 'pointer', padding: 0, fontSize: '1rem', lineHeight: 1 }}>×</button>
|
||||
</span>
|
||||
))}
|
||||
<input
|
||||
type="text"
|
||||
list="nuggets-tag-suggestions"
|
||||
placeholder="Add tag…"
|
||||
aria-label={`Add tag to ${ep.title}`}
|
||||
value={drafts[ep.audioUrl] ?? ''}
|
||||
onChange={e => setDrafts(d => ({ ...d, [ep.audioUrl]: e.target.value }))}
|
||||
onKeyDown={e => { if (e.key === 'Enter') { e.preventDefault(); addTags(ep) } }}
|
||||
onBlur={() => addTags(ep)}
|
||||
style={{ width: 160 }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
// ── Nuggets Episode Workflow admin ─────────────────────────────────────────
|
||||
type WorkflowStepKey = 'listen' | 'coldOpen' | 'recordColdOpen' | 'edit' | 'spotify'
|
||||
|
||||
@@ -2311,6 +2427,13 @@ export default function AdminPage({ content, onSave, onLogout }: Props) {
|
||||
const [commentsLoaded, setCommentsLoaded] = useState(false)
|
||||
const [commentFilter, setCommentFilter] = useState<'all' | 'pending' | 'approved'>('all')
|
||||
const [commentSearch, setCommentSearch] = useState('')
|
||||
// Load moderation queue as soon as the section is opened; a failed load leaves the manual button available
|
||||
const commentsAutoTried = useRef(false)
|
||||
useEffect(() => {
|
||||
if (adminView !== 'study-comments' || commentsLoaded || commentsAutoTried.current) return
|
||||
commentsAutoTried.current = true
|
||||
void loadStudyComments()
|
||||
}, [adminView, commentsLoaded])
|
||||
|
||||
// Episode scripts state
|
||||
const [scriptsList, setScriptsList] = useState<Array<{ key: string; episodeNumber: string; title: string; filename: string; season: string | null; uploadedAt: string | null; wordCount: number }>>([])
|
||||
@@ -4019,7 +4142,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date())
|
||||
<div className="admin-dashboard-card">
|
||||
<div className="admin-dashboard-card-value">{thisWeekReal.toLocaleString()}</div>
|
||||
<div className="admin-dashboard-card-label">Real Visits (7 Days)</div>
|
||||
<div className="admin-dashboard-card-sub">{thisWeekHits.toLocaleString()} total · {stats?.visitors?.uniqueVisitors?.toLocaleString() ?? '—'} unique all time</div>
|
||||
<div className="admin-dashboard-card-sub">{thisWeekHits.toLocaleString()} total · {stats?.uniqueVisitors7d?.toLocaleString() ?? '—'} unique this week · {stats?.visitors?.uniqueVisitors?.toLocaleString() ?? '—'} all time (consented)</div>
|
||||
<button type="button" className="admin-dashboard-card-action" onClick={() => navigateTo('analytics')}>Full Analytics →</button>
|
||||
</div>
|
||||
<div className="admin-dashboard-card">
|
||||
@@ -6183,6 +6306,10 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date())
|
||||
<div className="admin-field">
|
||||
<label htmlFor={`sl-reference-${activeLesson.id}`}>Passage Reference</label>
|
||||
<input id={`sl-reference-${activeLesson.id}`} type="text" value={activeLesson.reference} placeholder="1:1-2" onChange={e => updateStudySection(activeStudy.id, activeLesson.id, 'reference', e.target.value)} />
|
||||
{(() => {
|
||||
const refProblem = checkPassageReference(activeLesson.reference, activeStudy.bibleBook?.trim() || activeStudy.slug)
|
||||
return refProblem ? <p className="admin-field-warning" role="alert" style={{ color: '#e0a030', fontSize: '0.85rem', margin: '0.35rem 0 0' }}>⚠ {refProblem}</p> : null
|
||||
})()}
|
||||
</div>
|
||||
<div className="admin-field">
|
||||
<label htmlFor={`sl-title-${activeLesson.id}`}>Section Title</label>
|
||||
@@ -6311,6 +6438,19 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date())
|
||||
</div>
|
||||
))}
|
||||
|
||||
</>}
|
||||
{tabOf('global', 'global-footer') === 'global-verse' && <>
|
||||
<div className="admin-panel-subhead" id="global-verse"><h3>Verse of the Week</h3></div>
|
||||
<div className="admin-field">
|
||||
<label htmlFor="field-verseOfTheWeek">Verse of the Week (optional)</label>
|
||||
<input id="field-verseOfTheWeek" type="text" placeholder="Titus 2:11-12" value={(form.verseOfTheWeek as string) ?? ''} onChange={e => handleChange('verseOfTheWeek', e.target.value)} />
|
||||
<p className="admin-field-hint">Shown at the top of the Scripture Index. Leave blank and the site picks a different covered passage each week automatically. Use a full reference with the book name.</p>
|
||||
{(() => {
|
||||
const vowProblem = checkPassageReference(String(form.verseOfTheWeek ?? ''), '')
|
||||
return vowProblem ? <p className="admin-field-warning" role="alert" style={{ color: '#e0a030', fontSize: '0.85rem', margin: '0.35rem 0 0' }}>⚠ {vowProblem}</p> : null
|
||||
})()}
|
||||
</div>
|
||||
|
||||
</>}
|
||||
{tabOf('global', 'global-footer') === 'global-welcome-email' && <>
|
||||
<div className="admin-panel-subhead" id="global-welcome-email"><h3>Welcome Email</h3></div>
|
||||
@@ -6626,6 +6766,7 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date())
|
||||
{/* NUGGETS UPLOAD HISTORY */}
|
||||
{adminView === 'nuggets:workflow' && <NuggetsWorkflowAdmin />}
|
||||
{adminView === 'nuggets:history' && <NuggetsHistoryAdmin />}
|
||||
{adminView === 'nuggets:tags' && <NuggetsTagsAdmin />}
|
||||
|
||||
{/* STUDY COMMENTS */}
|
||||
{adminView === 'study-comments' && (() => {
|
||||
@@ -6910,6 +7051,34 @@ const [dashboardNow, setDashboardNow] = useState(() => new Date())
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* GOSPEL PAGE (/salvation) */}
|
||||
{adminView === 'salvation' && (
|
||||
<section className="admin-panel-section" aria-label="Gospel page">
|
||||
<div className="admin-panel-head">
|
||||
<h2>Gospel Page</h2>
|
||||
<p>Settings for <a href="/salvation" target="_blank" rel="noopener noreferrer">/salvation</a>, The Gospel in a Courtroom.</p>
|
||||
</div>
|
||||
<div className="admin-panel-subhead">
|
||||
<h3>Audio narration</h3>
|
||||
<p>A choose-your-path audio version. Listeners hear The Case, then choose Guilty or Not guilty and hear the matching track. Leave the first field blank to hide the player. If the two plea tracks are blank, the plea buttons just select the plea on the page.</p>
|
||||
</div>
|
||||
{([
|
||||
['salvationAudioUrl', '1. The Case (MP3)'],
|
||||
['salvationAudioGuiltyUrl', '2. Guilty: next steps and prayer (MP3)'],
|
||||
['salvationAudioNotGuiltyUrl', '3. Not guilty: what it means (MP3)'],
|
||||
] as const).map(([key, label]) => (
|
||||
<div className="admin-field" key={key}>
|
||||
<label htmlFor={`field-${key}`}>{label}</label>
|
||||
<input id={`field-${key}`} type="text" placeholder="https://…/salvation-case.mp3" value={form[key] ?? ''} onChange={e => handleChange(key, e.target.value)} />
|
||||
{form[key]?.trim() && <audio controls preload="none" src={form[key].trim()} style={{ width: '100%', marginTop: 8 }} />}
|
||||
</div>
|
||||
))}
|
||||
<p className="admin-stats-note">
|
||||
To make the files: put your ElevenLabs key and voice in your local <code>.env</code>, try <code>node --env-file=.env scripts/generate-salvation-audio.mjs --sample</code> first, then run it without <code>--sample</code> to make all three. Upload the MP3s in Asset Manager and paste their URLs here, then Save and Publish.
|
||||
</p>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{/* LEGAL */}
|
||||
{adminView === 'legal' && (
|
||||
<section className="admin-panel-section" aria-label="Legal Pages">
|
||||
|
||||
+312
-1
@@ -13275,7 +13275,20 @@ a.study-track-card:hover {
|
||||
}
|
||||
|
||||
.header-nav--open {
|
||||
max-height: 660px;
|
||||
max-height: calc(100dvh - var(--site-header-h, 64px));
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.nav-dropdown-label {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.nav-dropdown-caret {
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
margin: -0.8rem 0;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.nav-dropdown-trigger {
|
||||
@@ -13718,6 +13731,31 @@ a.study-track-card:hover {
|
||||
.si-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
|
||||
.si-verse-btn { margin-left: auto; font: inherit; font-size: 0.8rem; background: none; border: 0; padding: 0; cursor: pointer; color: var(--brand-muted); text-decoration: underline; }
|
||||
.si-verse-btn:hover { color: var(--brand-gold); }
|
||||
.si-vow { margin-bottom: 1rem; padding: 1.1rem 1.25rem; border: 1px solid var(--brand-gold-dark); border-radius: 12px; background: radial-gradient(ellipse at top left, rgba(201, 168, 76, 0.12), transparent 70%), var(--brand-black-3); }
|
||||
.si-vow-eyebrow { margin: 0 0 0.25rem; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brand-gold); }
|
||||
.si-vow-ref { margin: 0 0 0.5rem; font-family: var(--brand-font-heading); font-size: 1.6rem; font-weight: 600; line-height: 1.15; }
|
||||
.si-vow-text { margin: 0 0 0.75rem; font-style: italic; line-height: 1.65; color: var(--brand-muted); }
|
||||
.si-top { margin-bottom: 1rem; padding: 0.9rem 1rem; background: var(--brand-black-3); border: 1px solid var(--brand-border); border-radius: 12px; }
|
||||
.si-top-title { margin: 0 0 0.6rem; font-family: var(--brand-font-heading); font-size: 1.15rem; font-weight: 600; }
|
||||
.si-top-list { display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
||||
.si-top-item { display: inline-flex; align-items: baseline; gap: 0.5rem; font: inherit; font-size: 0.88rem; padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--brand-border); background: transparent; color: var(--brand-warm-white); cursor: pointer; }
|
||||
.si-top-item:hover { border-color: var(--brand-gold-dark); }
|
||||
.si-top-ref { font-weight: 700; color: var(--brand-gold-light); }
|
||||
.si-top-count { font-size: 0.75rem; color: var(--brand-muted); }
|
||||
.si-print-title { display: none; }
|
||||
@media print {
|
||||
.site > *:not(.si-main) { display: none !important; }
|
||||
.si-main { padding: 0; }
|
||||
.si-main, .si-group, .si-top { background: #fff !important; color: #000 !important; }
|
||||
.si-print-title { display: block; font-size: 1.6rem; margin: 0 0 1rem; color: #000; }
|
||||
.si-toolbar, .si-books, .si-meta, .si-top, .si-vow, .si-verse-btn, .si-verse, .si-chev { display: none !important; }
|
||||
.si-group { border: 0; border-bottom: 1px solid #999; break-inside: avoid-page; border-radius: 0; }
|
||||
.si-group-head { padding: 0.5rem 0; color: #000; }
|
||||
.si-ref { color: #000; }
|
||||
.si-chip { border: 0; padding: 0; color: #000; }
|
||||
.si-chip-kind { color: #444; }
|
||||
.si-chip-label { white-space: normal; overflow: visible; }
|
||||
}
|
||||
.si-verse { margin: 0.5rem 0 0; padding-left: 0.9rem; border-left: 2px solid var(--brand-gold-dark); font-size: 0.95rem; line-height: 1.65; font-style: italic; color: var(--brand-muted); }
|
||||
|
||||
@media (max-width: 600px) {
|
||||
@@ -13908,3 +13946,276 @@ a.study-track-card:hover {
|
||||
.home-feature--image { background-size: cover; background-position: center; }
|
||||
.home-feature--image h3 { text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
|
||||
.home-feature--image p { color: #d9ceb0; }
|
||||
|
||||
/* ── Newsletter page ── */
|
||||
.nl-top { padding: 3rem 0 1rem; }
|
||||
.nl-top-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1.5rem; align-items: stretch; }
|
||||
.nl-top .home-connect-card--newsletter { margin: 0; }
|
||||
.nl-featured {
|
||||
display: flex; flex-direction: column; gap: 0.9rem; padding: 2rem;
|
||||
background: linear-gradient(145deg, #17170f, #0c0c08);
|
||||
border: 1px solid rgba(201, 168, 76, 0.3); border-radius: 16px;
|
||||
text-decoration: none; color: inherit;
|
||||
transition: transform 160ms ease, border-color 160ms ease;
|
||||
}
|
||||
a.nl-featured:hover { transform: translateY(-2px); border-color: rgba(201, 168, 76, 0.6); }
|
||||
.nl-featured-tag { align-self: flex-start; font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: #c9a84c; border: 1px solid rgba(201, 168, 76, 0.4); border-radius: 999px; padding: 0.25rem 0.7rem; }
|
||||
.nl-featured-title { font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.2; color: #f0e9cc; margin: 0; }
|
||||
.nl-featured-desc { color: #a89a6a; margin: 0; line-height: 1.6; }
|
||||
.nl-featured-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
|
||||
.nl-date { font-size: 0.85rem; color: #8a7e55; }
|
||||
.nl-read { color: #c9a84c; font-weight: 600; font-size: 0.9rem; }
|
||||
.nl-archive { padding: 2rem 0 4rem; }
|
||||
.nl-archive-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
|
||||
.nl-archive-head .section-heading { margin: 0; }
|
||||
.nl-search { flex: 0 1 260px; padding: 0.6rem 1rem; border-radius: 999px; border: 1px solid rgba(201, 168, 76, 0.3); background: #1a1a12; color: #f0e9cc; font-size: 0.95rem; outline: none; }
|
||||
.nl-search:focus { border-color: rgba(201, 168, 76, 0.7); }
|
||||
.nl-year { margin-top: 2rem; }
|
||||
.nl-year-label { font-size: 0.85rem; letter-spacing: 0.18em; color: #c9a84c; margin: 0 0 0.9rem; padding-bottom: 0.5rem; border-bottom: 1px solid rgba(201, 168, 76, 0.18); }
|
||||
.nl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
|
||||
.nl-card {
|
||||
display: flex; flex-direction: column; gap: 0.5rem; padding: 1.2rem 1.3rem;
|
||||
background: #111; border: 1px solid rgba(201, 168, 76, 0.18); border-radius: 14px;
|
||||
text-decoration: none; color: inherit;
|
||||
transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
|
||||
}
|
||||
.nl-card:hover { transform: translateY(-2px); background: rgba(201, 168, 76, 0.06); border-color: rgba(201, 168, 76, 0.32); }
|
||||
.nl-card-title { font-size: 1.1rem; font-weight: 600; color: #f0e9cc; line-height: 1.3; }
|
||||
.nl-card-desc { margin: 0; color: #a89a6a; font-size: 0.9rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.nl-card .nl-read { margin-top: auto; padding-top: 0.4rem; }
|
||||
@media (max-width: 800px) { .nl-top-grid { grid-template-columns: 1fr; } .nl-featured { padding: 1.5rem; } }
|
||||
|
||||
/* ── Nuggets page ── */
|
||||
.nug-hero { padding: 3.5rem 0 1rem; border-bottom: 1px solid rgba(201, 168, 76, 0.15); background: radial-gradient(ellipse at top left, rgba(201, 168, 76, 0.08), transparent 60%); }
|
||||
.nug-hero-inner { display: flex; gap: 2.5rem; align-items: center; flex-wrap: wrap; padding-bottom: 2.5rem; }
|
||||
.nug-hero-art { width: 220px; height: 220px; object-fit: cover; border-radius: 18px; border: 1px solid rgba(201, 168, 76, 0.3); box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45); flex-shrink: 0; }
|
||||
.nug-hero-body { flex: 1; min-width: 260px; }
|
||||
.nug-hero-title { font-family: var(--brand-font-heading); font-size: clamp(2rem, 5vw, 3.2rem); color: #f0e9cc; margin: 0.2rem 0 0.4rem; line-height: 1.1; }
|
||||
.nug-hero-tagline { font-size: 1.15rem; color: #c9a84c; margin: 0 0 1rem; }
|
||||
.nug-latest { margin: 0 0 3rem; padding: 2rem; border-color: rgba(201, 168, 76, 0.4); background: linear-gradient(145deg, #17170f, #0c0c08); }
|
||||
.nug-list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
|
||||
.nug-list-head .section-heading { margin: 0; }
|
||||
.nug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
|
||||
.nug-card { display: flex; flex-direction: column; gap: 0.5rem; padding: 1.25rem 1.3rem; background: #111; border: 1px solid rgba(201, 168, 76, 0.18); border-radius: 14px; transition: border-color 160ms ease; }
|
||||
.nug-card:hover { border-color: rgba(201, 168, 76, 0.4); }
|
||||
.nug-card-meta { margin: 0; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: #8a7e55; }
|
||||
.nug-card-title { margin: 0; font-size: 1.1rem; line-height: 1.3; color: #f0e9cc; }
|
||||
.nug-card-desc { margin: 0; color: #a89a6a; font-size: 0.9rem; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
|
||||
.nug-card > :last-child { margin-top: auto; }
|
||||
.nug-more { text-align: center; margin-top: 1.75rem; }
|
||||
.nug-hosts { margin-top: 4rem; padding-top: 2.5rem; border-top: 1px solid rgba(201, 168, 76, 0.15); }
|
||||
.nug-hosts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
|
||||
.nug-host-card { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.2rem; background: #111; border: 1px solid rgba(201, 168, 76, 0.18); border-radius: 14px; text-decoration: none; transition: transform 160ms ease, border-color 160ms ease; }
|
||||
.nug-host-card:hover { transform: translateY(-2px); border-color: rgba(201, 168, 76, 0.45); }
|
||||
.nug-host-img { width: 64px; height: 64px; object-fit: cover; border-radius: 50%; border: 2px solid rgba(201, 168, 76, 0.35); flex-shrink: 0; }
|
||||
.nug-host-name { display: block; font-family: var(--brand-font-heading); font-size: 1.05rem; color: #e8d9b5; }
|
||||
.nug-host-role { display: block; font-size: 0.85rem; color: #a89a6a; margin-top: 0.15rem; }
|
||||
@media (max-width: 640px) { .nug-hero-art { width: 150px; height: 150px; } .nug-latest { padding: 1.25rem; } .nug-grid { grid-template-columns: 1fr; } }
|
||||
.nug-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
|
||||
.nug-tag { font: inherit; font-size: 0.85rem; color: #c9a84c; background: transparent; border: 1px solid rgba(201, 168, 76, 0.35); border-radius: 999px; padding: 0.3rem 0.9rem; cursor: pointer; transition: background 140ms ease, color 140ms ease; }
|
||||
.nug-tag:hover { background: rgba(201, 168, 76, 0.12); }
|
||||
.nug-tag--active, .nug-tag--active:hover { background: #c9a84c; color: #0c0c08; border-color: #c9a84c; }
|
||||
.nug-tag--small { font-size: 0.74rem; padding: 0.15rem 0.6rem; }
|
||||
.nug-card-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }
|
||||
|
||||
/* ── Episode detail ── */
|
||||
.ed-hero { padding: 2.5rem 0 2rem; background: radial-gradient(ellipse at top left, rgba(201, 168, 76, 0.09), transparent 60%); border-bottom: 1px solid rgba(201, 168, 76, 0.15); }
|
||||
.ed-hero-inner { }
|
||||
.ed-title { font-family: var(--brand-font-heading); font-size: clamp(1.9rem, 4.5vw, 3rem); line-height: 1.12; color: #f0e9cc; margin: 0.2rem 0 0.8rem; }
|
||||
.ed-summary { font-size: 1.1rem; line-height: 1.65; color: #a89a6a; margin: 0 0 1.5rem; }
|
||||
.ed-player { margin-bottom: 1rem; }
|
||||
.ed-listen { display: inline-block; }
|
||||
.ed-body { padding: 2.5rem 0 4rem; }
|
||||
.ed-body-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(240px, 1fr); gap: 2.5rem; align-items: start; }
|
||||
.ed-body-grid--single { grid-template-columns: minmax(0, 760px); justify-content: center; }
|
||||
.ed-block { margin-bottom: 2.25rem; }
|
||||
.ed-heading { font-family: var(--brand-font-heading); font-size: 1.5rem; color: #e8d9b5; margin: 0 0 0.8rem; }
|
||||
.ed-text { color: #c9bf9a; line-height: 1.75; margin: 0; }
|
||||
.ed-quote { margin: 0 0 1rem; padding: 0.4rem 0 0.4rem 1.1rem; border-left: 3px solid #c9a84c; color: #e8d9b5; font-style: italic; line-height: 1.6; }
|
||||
.ed-questions { margin: 0; padding-left: 1.3rem; color: #c9bf9a; line-height: 1.65; display: grid; gap: 0.7rem; }
|
||||
.ed-questions li::marker { color: #c9a84c; font-weight: 700; }
|
||||
.ed-side { display: grid; gap: 1rem; position: sticky; top: 5rem; }
|
||||
.ed-card { background: #111; border: 1px solid rgba(201, 168, 76, 0.18); border-radius: 14px; padding: 1.1rem 1.25rem; }
|
||||
.ed-side-heading { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: #c9a84c; margin: 0 0 0.8rem; font-family: inherit; }
|
||||
.ed-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
|
||||
.ed-chip { font-size: 0.85rem; color: #e8d9b5; border: 1px solid rgba(201, 168, 76, 0.35); border-radius: 999px; padding: 0.25rem 0.8rem; }
|
||||
.ed-list { margin: 0; padding-left: 1.1rem; color: #c9bf9a; line-height: 1.55; display: grid; gap: 0.4rem; font-size: 0.92rem; }
|
||||
@media (max-width: 800px) { .ed-body-grid { grid-template-columns: 1fr; } .ed-side { position: static; } }
|
||||
|
||||
/* ── Host detail ── */
|
||||
.hd-hero { padding: 2.5rem 0 2rem; background: radial-gradient(ellipse at top left, rgba(201, 168, 76, 0.09), transparent 60%); border-bottom: 1px solid rgba(201, 168, 76, 0.15); }
|
||||
.hd-hero-inner { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; }
|
||||
.hd-photo { width: 180px; height: 180px; object-fit: cover; border-radius: 50%; border: 3px solid rgba(201, 168, 76, 0.4); box-shadow: 0 10px 36px rgba(0, 0, 0, 0.45); flex-shrink: 0; }
|
||||
.hd-hero-body { flex: 1; min-width: 240px; }
|
||||
.hd-name { font-family: var(--brand-font-heading); font-size: clamp(2rem, 5vw, 3rem); color: #f0e9cc; margin: 0.2rem 0 0; line-height: 1.1; }
|
||||
.hd-body { padding: 2.5rem 0 4rem; }
|
||||
.hd-body-inner { }
|
||||
.hd-bio { font-size: 1.08rem; line-height: 1.75; color: #c9bf9a; margin: 0 0 1.25rem; }
|
||||
.hd-listen { margin-top: 2rem; padding: 1.4rem 1.5rem; background: #111; border: 1px solid rgba(201, 168, 76, 0.2); border-radius: 14px; }
|
||||
.hd-listen .eyebrow { margin-bottom: 0.8rem; }
|
||||
.hd-others { margin-top: 2.5rem; }
|
||||
.hd-back { display: inline-block; margin-top: 2.5rem; }
|
||||
@media (max-width: 640px) { .hd-photo { width: 120px; height: 120px; } }
|
||||
|
||||
/* ── Finished series page ── */
|
||||
.fsp-hero { padding: 2.5rem 0 2.25rem; background: radial-gradient(ellipse at top left, rgba(201, 168, 76, 0.09), transparent 60%); border-bottom: 1px solid rgba(201, 168, 76, 0.15); }
|
||||
.fsp-hero-inner { display: flex; gap: 2.5rem; align-items: center; flex-wrap: wrap; }
|
||||
.fsp-hero-body { flex: 1; min-width: 260px; }
|
||||
.fsp-title { font-family: var(--brand-font-heading); font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; color: #f0e9cc; margin: 0.2rem 0 0.8rem; }
|
||||
.fsp-desc { color: #a89a6a; line-height: 1.65; margin: 0 0 1.4rem; max-width: 60ch; }
|
||||
.fsp-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }
|
||||
.fsp-episodes { padding-top: 2rem; padding-bottom: 4rem; }
|
||||
|
||||
/* ── Centered utility pages (thanks, subscribe, 404, legal) ── */
|
||||
.cp-main { padding: 3.5rem 1.25rem 4.5rem; background: radial-gradient(ellipse at top, rgba(201, 168, 76, 0.1), transparent 55%); display: flex; justify-content: center; }
|
||||
.cp-card { width: min(640px, 100%); background: #121212; border: 1px solid rgba(201, 168, 76, 0.24); border-radius: 18px; box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5); padding: 2.5rem 2rem; text-align: center; }
|
||||
.cp-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: rgba(201, 168, 76, 0.14); border: 1px solid rgba(201, 168, 76, 0.5); color: #c9a84c; font-size: 1.6rem; margin-bottom: 1rem; }
|
||||
.cp-404 { font-family: var(--brand-font-heading); font-size: clamp(4rem, 14vw, 6.5rem); line-height: 1; margin: 0 0 0.25rem; color: #c9a84c; opacity: 0.85; }
|
||||
.cp-title { font-family: var(--brand-font-heading); font-size: clamp(1.9rem, 5vw, 2.7rem); color: #f0e9cc; margin: 0.2rem 0 0.8rem; line-height: 1.15; }
|
||||
.cp-text { color: #a89a6a; line-height: 1.7; margin: 0 auto 1.5rem; max-width: 46ch; }
|
||||
.cp-text code { color: #e8d9b5; background: rgba(201, 168, 76, 0.1); padding: 0.1rem 0.4rem; border-radius: 4px; word-break: break-all; }
|
||||
.cp-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin: 1.5rem 0 0; }
|
||||
.cp-note { font-size: 0.85rem; color: #8a7e55; margin: 1.25rem 0 0; }
|
||||
.cp-note a { color: #c9a84c; }
|
||||
.cp-form { display: grid; gap: 1rem; text-align: left; margin-top: 0.5rem; }
|
||||
.cp-form label { display: grid; gap: 0.35rem; font-size: 0.85rem; color: #c9bf9a; }
|
||||
.cp-form input { padding: 0.7rem 1rem; border-radius: 8px; border: 1px solid rgba(201, 168, 76, 0.3); background: #1a1a12; color: #f0e9cc; font-size: 1rem; outline: none; }
|
||||
.cp-form input:focus { border-color: rgba(201, 168, 76, 0.7); }
|
||||
.cp-form .btn-primary { justify-content: center; }
|
||||
.cp-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
|
||||
.cp-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem; margin-top: 1.25rem; text-align: left; }
|
||||
.cp-link-card { display: grid; gap: 0.2rem; padding: 0.9rem 1rem; background: #17170f; border: 1px solid rgba(201, 168, 76, 0.2); border-radius: 12px; text-decoration: none; transition: transform 160ms ease, border-color 160ms ease; }
|
||||
.cp-link-card:hover { transform: translateY(-2px); border-color: rgba(201, 168, 76, 0.5); }
|
||||
.cp-link-card strong { color: #e8d9b5; }
|
||||
.cp-link-card span { color: #8a7e55; font-size: 0.82rem; }
|
||||
.cp-legal { max-width: 760px; padding-top: 2.5rem; padding-bottom: 4rem; }
|
||||
.cp-legal p { color: #c9bf9a; line-height: 1.8; margin: 0 0 1.1rem; }
|
||||
@media (max-width: 520px) { .cp-card { padding: 1.75rem 1.25rem; } .cp-form-row { grid-template-columns: 1fr; } }
|
||||
|
||||
/* ── Study discussion hub ── */
|
||||
.sdh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
|
||||
.sdh-card { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.4rem; background: #111; border: 1px solid rgba(201, 168, 76, 0.2); border-radius: 14px; text-decoration: none; transition: transform 160ms ease, border-color 160ms ease; }
|
||||
.sdh-card:hover { transform: translateY(-2px); border-color: rgba(201, 168, 76, 0.5); }
|
||||
.sdh-card h3 { margin: 0; font-family: var(--brand-font-heading); font-size: 1.35rem; color: #f0e9cc; }
|
||||
.sdh-card p { margin: 0; color: #a89a6a; line-height: 1.55; font-size: 0.95rem; }
|
||||
.sdh-badge { align-self: flex-start; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: #8a7e55; border: 1px solid rgba(201, 168, 76, 0.25); border-radius: 999px; padding: 0.2rem 0.65rem; }
|
||||
.sdh-badge--on { color: #c9a84c; border-color: rgba(201, 168, 76, 0.6); }
|
||||
.sdh-go { margin-top: auto; padding-top: 0.5rem; color: #c9a84c; font-weight: 600; font-size: 0.9rem; }
|
||||
|
||||
/* ── Study overview ── */
|
||||
.si-hero { padding: 2.5rem 0 2.25rem; background: radial-gradient(ellipse at top left, rgba(201, 168, 76, 0.1), transparent 60%); border-bottom: 1px solid rgba(201, 168, 76, 0.15); }
|
||||
.si-hero-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2.5rem; align-items: center; }
|
||||
.si-title { font-family: var(--brand-font-heading); font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; color: #f0e9cc; margin: 0.2rem 0 0.8rem; }
|
||||
.si-desc { color: #a89a6a; line-height: 1.65; margin: 0 0 1.1rem; max-width: 62ch; }
|
||||
.si-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.4rem; }
|
||||
.si-chips span { font-size: 0.8rem; color: #c9bf9a; border: 1px solid rgba(201, 168, 76, 0.25); border-radius: 999px; padding: 0.2rem 0.75rem; }
|
||||
.si-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }
|
||||
.si-progress { display: flex; align-items: center; gap: 1.1rem; padding: 1.2rem 1.5rem; background: #111; border: 1px solid rgba(201, 168, 76, 0.25); border-radius: 16px; }
|
||||
.si-ring { --pct: 0%; width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(#c9a84c var(--pct), rgba(201, 168, 76, 0.15) 0); position: relative; }
|
||||
.si-ring::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: #111; }
|
||||
.si-ring span { position: relative; font-weight: 700; color: #e8d9b5; }
|
||||
.si-progress-big { margin: 0; font-family: var(--brand-font-heading); font-size: 1.6rem; color: #f0e9cc; }
|
||||
.si-progress-sub { margin: 0; color: #a89a6a; font-size: 0.9rem; }
|
||||
.si-notice { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 1.5rem; padding: 1rem 1.25rem; background: #17170f; border: 1px solid rgba(201, 168, 76, 0.3); border-radius: 12px; color: #a89a6a; }
|
||||
.si-notice strong { color: #e8d9b5; }
|
||||
.si-notice .btn-primary { margin-left: auto; }
|
||||
.si-lessons { padding: 2rem 0 4rem; }
|
||||
.si-chapter { margin-bottom: 1.25rem; }
|
||||
.si-chapter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; cursor: pointer; padding: 0.6rem 0; border-bottom: 1px solid rgba(201, 168, 76, 0.18); list-style: none; }
|
||||
.si-chapter-head::-webkit-details-marker { display: none; }
|
||||
.si-chapter-head h2 { margin: 0; font-family: var(--brand-font-heading); font-size: 1.4rem; color: #e8d9b5; }
|
||||
.si-chapter-head span { font-size: 0.85rem; color: #8a7e55; }
|
||||
.si-list { display: grid; gap: 0.7rem; margin-top: 1rem; }
|
||||
.si-row { display: flex; gap: 1rem; align-items: center; padding: 1rem 1.2rem; background: #111; border: 1px solid rgba(201, 168, 76, 0.18); border-radius: 14px; text-decoration: none; transition: transform 160ms ease, border-color 160ms ease; }
|
||||
.si-row:hover { transform: translateY(-1px); border-color: rgba(201, 168, 76, 0.5); }
|
||||
.si-row--disabled { opacity: 0.55; cursor: default; }
|
||||
.si-row--disabled:hover { transform: none; border-color: rgba(201, 168, 76, 0.18); }
|
||||
.si-row--done { border-color: rgba(127, 212, 138, 0.35); }
|
||||
.si-num { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(201, 168, 76, 0.45); color: #c9a84c; font-weight: 700; }
|
||||
.si-row--done .si-num { background: rgba(127, 212, 138, 0.15); border-color: #7fd48a; color: #7fd48a; }
|
||||
.si-row-body { flex: 1; min-width: 0; }
|
||||
.si-row-top { display: flex; flex-wrap: wrap; gap: 0.4rem 0.7rem; align-items: center; }
|
||||
.si-row-top h3 { margin: 0; font-size: 1.1rem; color: #f0e9cc; }
|
||||
.si-ref { margin: 0.15rem 0 0; font-size: 0.8rem; letter-spacing: 0.06em; color: #c9a84c; }
|
||||
.si-summary { margin: 0.35rem 0 0; color: #a89a6a; font-size: 0.92rem; line-height: 1.5; }
|
||||
.si-arrow { color: #c9a84c; font-size: 1.2rem; }
|
||||
@media (max-width: 800px) { .si-hero-inner { grid-template-columns: 1fr; } .si-progress { justify-self: start; } }
|
||||
.si-focus { margin: 0.4rem 0 0; font-size: 0.85rem; font-style: italic; color: #8a7e55; line-height: 1.45; }
|
||||
.si-focus span { font-style: normal; color: #c9a84c; }
|
||||
|
||||
/* ── Study lesson page ── */
|
||||
.section-study-classroom { padding-top: 2rem; }
|
||||
.study-classroom-shell { grid-template-columns: minmax(0, 1fr) 320px; gap: 2.5rem; }
|
||||
.sl-head { padding-bottom: 1.5rem; margin-bottom: 0.5rem; border-bottom: 1px solid rgba(201, 168, 76, 0.18); }
|
||||
.sl-head-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: center; margin: 0.4rem 0 0.6rem; }
|
||||
.sl-lesson-pill { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: #0c0c08; background: #c9a84c; border-radius: 999px; padding: 0.2rem 0.75rem; font-weight: 700; }
|
||||
.sl-ref { font-size: 0.85rem; letter-spacing: 0.08em; color: #c9a84c; }
|
||||
.sl-done { font-size: 0.8rem; color: #7fd48a; border: 1px solid rgba(127, 212, 138, 0.5); border-radius: 999px; padding: 0.15rem 0.65rem; }
|
||||
.sl-title { font-family: var(--brand-font-heading); font-size: clamp(2rem, 4.5vw, 2.9rem); line-height: 1.12; color: #f0e9cc; margin: 0 0 0.7rem; }
|
||||
.sl-summary { font-size: 1.1rem; line-height: 1.65; color: #a89a6a; max-width: 62ch; margin: 0 0 1.1rem; }
|
||||
.sl-progress { display: grid; gap: 0.4rem; max-width: 420px; font-size: 0.8rem; color: #8a7e55; }
|
||||
.sl-progress .study-lesson-progress-bar { height: 5px; margin: 0; }
|
||||
.study-classroom-main .study-class-block { margin-top: 1.5rem; padding: 1.6rem 1.75rem; border-radius: 16px; background: #111; border-color: rgba(201, 168, 76, 0.2); }
|
||||
.study-classroom-main .study-class-block h2 { font-size: 1.5rem; color: #e8d9b5; padding-right: 5rem; }
|
||||
.study-classroom-main .study-detail-copy { font-size: 1.08rem; line-height: 1.85; color: #cfc6a4; margin-bottom: 1.1rem; max-width: 68ch; }
|
||||
.study-classroom-main .study-detail-copy:last-child { margin-bottom: 0; }
|
||||
.study-classroom-main .study-detail-copy--scripture { font-family: var(--brand-font-heading); font-size: 1.2rem; line-height: 1.9; color: #f0e9cc; padding-left: 1.1rem; border-left: 3px solid rgba(201, 168, 76, 0.55); }
|
||||
.study-classroom-main .study-detail-list--questions { padding-left: 0; list-style: none; counter-reset: q; display: grid; gap: 1.25rem; }
|
||||
.study-classroom-main .study-question-item { counter-increment: q; position: relative; padding-left: 2.6rem; }
|
||||
.study-classroom-main .study-question-item::before { content: counter(q); position: absolute; left: 0; top: 0; width: 1.9rem; height: 1.9rem; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(201, 168, 76, 0.5); color: #c9a84c; font-weight: 700; font-size: 0.85rem; }
|
||||
.study-classroom-main .study-question-text { font-size: 1.02rem; color: #e8d9b5; }
|
||||
.study-classroom-sidebar { top: 5rem; }
|
||||
.study-class-side-block { border-radius: 14px; background: #111; border-color: rgba(201, 168, 76, 0.2); }
|
||||
.study-class-side-block h3 { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: #c9a84c; font-family: inherit; }
|
||||
.sl-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2rem; }
|
||||
.sl-pager-link { display: grid; gap: 0.25rem; padding: 1rem 1.25rem; background: #111; border: 1px solid rgba(201, 168, 76, 0.22); border-radius: 14px; text-decoration: none; transition: border-color 160ms ease, transform 160ms ease; }
|
||||
a.sl-pager-link:hover { border-color: rgba(201, 168, 76, 0.6); transform: translateY(-1px); }
|
||||
.sl-pager-link span { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: #8a7e55; }
|
||||
.sl-pager-link strong { color: #e8d9b5; font-weight: 600; }
|
||||
.sl-pager-link--next { text-align: right; }
|
||||
.sl-pager-link--wait { opacity: 0.7; }
|
||||
@media (max-width: 960px) {
|
||||
.study-classroom-shell { grid-template-columns: 1fr; }
|
||||
.study-classroom-sidebar { position: static; }
|
||||
}
|
||||
@media (max-width: 560px) {
|
||||
.study-classroom-main .study-class-block { padding: 1.2rem 1.1rem; }
|
||||
.sl-pager { grid-template-columns: 1fr; }
|
||||
.sl-pager-link--next { text-align: left; }
|
||||
}
|
||||
#root .ed-heading { font-size: 1.5rem; }
|
||||
.ed-hero-inner > * { max-width: 760px; }
|
||||
#root .ed-side .ed-side-heading { font-size: 0.75rem; letter-spacing: 0.14em; text-transform: uppercase; color: #c9a84c; margin: 0 0 0.8rem; font-family: inherit; font-weight: 600; line-height: 1.2; }
|
||||
.auth-card--center .study-signup-form { text-align: left; }
|
||||
.cp-main--bare { min-height: 100vh; align-items: center; }
|
||||
|
||||
/* ── Start Here: gospel callout ── */
|
||||
.start-gospel { max-width: 760px; margin: 2.5rem auto 0; padding: 1.75rem 1.9rem; text-align: center; background: linear-gradient(145deg, #17170f, #0c0c08); border: 1px solid rgba(201, 168, 76, 0.35); border-radius: 16px; }
|
||||
.start-gospel h2 { font-family: var(--brand-font-heading); font-size: 1.7rem; color: #f0e9cc; margin: 0.3rem 0 0.7rem; }
|
||||
.start-gospel p { color: #a89a6a; line-height: 1.7; margin: 0 auto 1.2rem; max-width: 56ch; }
|
||||
.start-gospel .eyebrow { margin-bottom: 0; color: #c9a84c; }
|
||||
.header-nav-link { white-space: nowrap; }
|
||||
|
||||
.note-card-footer { padding: 0.35rem 0.9rem; font-size: 0.75rem; color: #7a7060; text-align: right; border-top: 1px solid rgba(201, 168, 76, 0.14); }
|
||||
.notes-reader-meta { margin: 0.25rem 0 1rem; font-size: 0.82rem; color: #7a7060; }
|
||||
.notes-copy-btn { background: none; border: 0; padding: 0; color: #c9a84c; cursor: pointer; font: inherit; text-decoration: underline; }
|
||||
.notes-copy-btn:hover { color: #e3c46a; }
|
||||
|
||||
.notes-other-matches { margin-top: 1rem; }
|
||||
.notes-export-btn { margin-top: 1rem; width: 100%; }
|
||||
|
||||
.note-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
|
||||
.note-card-delete { background: none; border: 0; padding: 0; color: #b5654f; cursor: pointer; font: inherit; }
|
||||
.note-card-delete:hover { text-decoration: underline; }
|
||||
.note-entry-list { list-style: none; margin: 0 0 0.75rem; padding: 0; display: grid; gap: 0.4rem; }
|
||||
.note-entry { width: 100%; text-align: left; background: rgba(201, 168, 76, 0.06); border: 1px solid rgba(201, 168, 76, 0.18); border-radius: 8px; padding: 0.45rem 0.65rem; cursor: pointer; color: inherit; font: inherit; display: grid; gap: 0.1rem; }
|
||||
.note-entry:hover, .note-entry--active { border-color: #c9a84c; background: rgba(201, 168, 76, 0.14); }
|
||||
.note-entry-label { font-size: 0.72rem; color: #c9a84c; text-transform: uppercase; letter-spacing: 0.04em; }
|
||||
.note-entry-snippet { font-size: 0.85rem; color: #b8ad92; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.note-add-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.75rem; font-size: 0.8rem; color: #7a7060; }
|
||||
.note-add-chip { background: none; border: 1px solid rgba(201, 168, 76, 0.35); border-radius: 999px; padding: 0.2rem 0.6rem; color: #c9a84c; cursor: pointer; font: inherit; font-size: 0.78rem; }
|
||||
.note-add-chip:hover { background: rgba(201, 168, 76, 0.12); }
|
||||
.notes-sort { display: flex; gap: 0.4rem; margin: 0.6rem 0; }
|
||||
.notes-sort-btn { flex: 1; background: none; border: 1px solid rgba(201, 168, 76, 0.25); border-radius: 6px; padding: 0.3rem 0.4rem; color: #b8ad92; cursor: pointer; font: inherit; font-size: 0.78rem; }
|
||||
.notes-sort-btn--active { border-color: #c9a84c; color: #c9a84c; background: rgba(201, 168, 76, 0.1); }
|
||||
.notes-block-date { font-weight: 400; color: #7a7060; font-size: 0.75rem; }
|
||||
+563
-362
File diff suppressed because it is too large.
Load diff
@@ -28,6 +28,7 @@ const TYPE_LABEL: Record<string, string> = {
|
||||
community: 'Community Question',
|
||||
testimony: 'Testimony',
|
||||
topic: 'Topic Request',
|
||||
gospel: 'Gospel Courtroom Question',
|
||||
general: 'General Message',
|
||||
}
|
||||
const KIND_LABEL: Record<Kind, string> = { email: 'Email', newsletter: 'Newsletter signup', download: 'Download request', message: 'Contact form' }
|
||||
|
||||
@@ -308,7 +308,7 @@ export function AnalyticsPanel({
|
||||
<article>
|
||||
<h3>Unique Visitors</h3>
|
||||
<p>{stats.visitors.uniqueVisitors.toLocaleString()}</p>
|
||||
<small>Tracked with consent</small>
|
||||
<small>{stats.uniqueVisitors7d != null ? `${stats.uniqueVisitors7d.toLocaleString()} this week · ` : ''}Tracked with consent</small>
|
||||
</article>
|
||||
<article>
|
||||
<h3>Returning Rate</h3>
|
||||
@@ -399,6 +399,23 @@ export function AnalyticsPanel({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="admin-analytics-grid" style={{ marginTop: '1rem' }}>
|
||||
<div className="admin-analytics-card admin-analytics-card--wide">
|
||||
<h3 className="admin-analytics-card-title">Probed URLs (not real pages)</h3>
|
||||
{(stats.topUnknownPaths ?? []).length === 0 ? (
|
||||
<p className="admin-stats-note">No probe traffic recorded yet. Requests for URLs that are not site pages (like /.env or /wp-login) are listed here and counted as bots.</p>
|
||||
) : (
|
||||
<ul className="admin-bot-reason-list">
|
||||
{(stats.topUnknownPaths ?? []).map(row => (
|
||||
<li key={row.path} className="admin-bot-reason-item">
|
||||
<span style={{ wordBreak: 'break-all' }}>{row.path}</span>
|
||||
<strong>{row.hits.toLocaleString()}</strong>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="admin-analytics-grid" style={{ marginTop: '1rem' }}>
|
||||
<div className="admin-analytics-card admin-analytics-card--wide">
|
||||
<h3 className="admin-analytics-card-title">Top Pages — Real vs Bot ({rangeLabel})</h3>
|
||||
|
||||
@@ -15,6 +15,7 @@ interface ContactFields {
|
||||
|
||||
const TYPES: { value: string; label: string; hint: string; placeholder: string }[] = [
|
||||
{ value: 'question', label: 'Bible question', hint: 'Ask anything about Scripture. Answers are posted on the Q&A page.', placeholder: 'What would you like to know?' },
|
||||
{ value: 'gospel', label: 'Gospel courtroom', hint: 'A question about the gospel courtroom: the Judge, the accuser, the charges, the Substitute, the pardon or your plea. It goes to Nate privately and is not posted publicly.', placeholder: 'What would you like to ask about the courtroom, the verdict or the pardon?' },
|
||||
{ value: 'community', label: 'Community question', hint: 'A question about a study discussion or the community.', placeholder: 'What’s on your mind?' },
|
||||
{ value: 'testimony', label: 'Testimony', hint: 'Share what God is doing in your life. Every one is read.', placeholder: 'Tell your story…' },
|
||||
{ value: 'topic', label: 'Topic request', hint: 'Suggest a passage or topic for a future episode.', placeholder: 'Which passage or topic?' },
|
||||
@@ -32,7 +33,7 @@ export default function ContactForm() {
|
||||
lastName: '',
|
||||
email: '',
|
||||
message: '',
|
||||
messageType: source === 'community' ? 'community' : 'question',
|
||||
messageType: source === 'community' ? 'community' : source === 'salvation' ? 'gospel' : 'question',
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -5,14 +5,17 @@ import { useEffect } from 'react'
|
||||
interface NoteCardProps {
|
||||
anchorLabel: string
|
||||
html: string
|
||||
updatedAt?: string | null
|
||||
onDelete?: () => void
|
||||
autoSaveMsg?: string
|
||||
onChange: (html: string) => void
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
export function NoteCard({ anchorLabel, html, autoSaveMsg, onChange, onClose }: NoteCardProps) {
|
||||
export function NoteCard({ anchorLabel, html, updatedAt, onDelete, autoSaveMsg, onChange, onClose }: NoteCardProps) {
|
||||
const editor = useEditor({
|
||||
extensions: [StarterKit],
|
||||
shouldRerenderOnTransaction: true,
|
||||
content: html || '<p></p>',
|
||||
onUpdate({ editor }) {
|
||||
const next = editor.getHTML()
|
||||
@@ -32,6 +35,8 @@ export function NoteCard({ anchorLabel, html, autoSaveMsg, onChange, onClose }:
|
||||
|
||||
if (!editor) return null
|
||||
|
||||
const wordCount = editor.getText().split(/\s+/).filter(Boolean).length
|
||||
|
||||
return (
|
||||
<div className="note-card">
|
||||
<div className="note-card-header">
|
||||
@@ -71,6 +76,27 @@ export function NoteCard({ anchorLabel, html, autoSaveMsg, onChange, onClose }:
|
||||
aria-label="Numbered list"
|
||||
title="Numbered list"
|
||||
>1.</button>
|
||||
<button
|
||||
type="button"
|
||||
className={`note-tool${editor.isActive('heading', { level: 3 }) ? ' note-tool--active' : ''}`}
|
||||
onMouseDown={e => { e.preventDefault(); editor.chain().focus().toggleHeading({ level: 3 }).run() }}
|
||||
aria-label="Heading"
|
||||
title="Heading"
|
||||
>H</button>
|
||||
<button
|
||||
type="button"
|
||||
className={`note-tool${editor.isActive('blockquote') ? ' note-tool--active' : ''}`}
|
||||
onMouseDown={e => { e.preventDefault(); editor.chain().focus().toggleBlockquote().run() }}
|
||||
aria-label="Quote"
|
||||
title="Quote"
|
||||
>❝</button>
|
||||
<button
|
||||
type="button"
|
||||
className={`note-tool${editor.isActive('strike') ? ' note-tool--active' : ''}`}
|
||||
onMouseDown={e => { e.preventDefault(); editor.chain().focus().toggleStrike().run() }}
|
||||
aria-label="Strikethrough"
|
||||
title="Strikethrough"
|
||||
><s>S</s></button>
|
||||
<div className="note-tool-divider" />
|
||||
<button
|
||||
type="button"
|
||||
@@ -91,6 +117,19 @@ export function NoteCard({ anchorLabel, html, autoSaveMsg, onChange, onClose }:
|
||||
</div>
|
||||
|
||||
<EditorContent editor={editor} className="note-card-editor" />
|
||||
<div className="note-card-footer">
|
||||
{onDelete && (
|
||||
<button
|
||||
type="button"
|
||||
className="note-card-delete"
|
||||
onClick={() => { if (window.confirm('Delete this note?')) onDelete() }}
|
||||
>Delete note</button>
|
||||
)}
|
||||
<span>
|
||||
{updatedAt ? `Edited ${new Date(updatedAt).toLocaleString('en-US', { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' })} · ` : ''}
|
||||
{wordCount.toLocaleString()} {wordCount === 1 ? 'word' : 'words'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -285,6 +285,10 @@ export interface SiteContent {
|
||||
shareQrImageUrl: string
|
||||
// ── PRISM Video ──
|
||||
prismVideoUrl: string
|
||||
// Audio narration of the /salvation page (served to the static page via /api/salvation-audio)
|
||||
salvationAudioUrl: string
|
||||
salvationAudioGuiltyUrl: string
|
||||
salvationAudioNotGuiltyUrl: string
|
||||
prismEyebrow: string
|
||||
prismHeading: string
|
||||
prismIntro: string
|
||||
@@ -315,6 +319,7 @@ export interface SiteContent {
|
||||
platformCreatorUrl: string
|
||||
platformKofiUrl?: string
|
||||
platformKofiQrUrl?: string
|
||||
verseOfTheWeek?: string
|
||||
// ── Welcome Email ──
|
||||
welcomeEmailSubject: string
|
||||
welcomeEmailGreetingPrefix: string
|
||||
@@ -528,6 +533,9 @@ export const DEFAULTS: SiteContent = {
|
||||
shareP: 'Scan the QR code or text the show link to a friend who needs encouragement today.',
|
||||
shareQrImageUrl: '/images/qr-code.jpg',
|
||||
prismVideoUrl: 'https://files.versebyversewithnate.us/images/PRISM.mp4',
|
||||
salvationAudioUrl: '',
|
||||
salvationAudioGuiltyUrl: '',
|
||||
salvationAudioNotGuiltyUrl: '',
|
||||
prismEyebrow: 'Featured Video',
|
||||
prismHeading: 'PRISM',
|
||||
prismIntro:
|
||||
@@ -564,6 +572,7 @@ export const DEFAULTS: SiteContent = {
|
||||
platformCreatorUrl: 'https://creators.spotify.com/pod/profile/nmemmert/',
|
||||
platformKofiUrl: 'https://ko-fi.com/versebyversewithnate',
|
||||
platformKofiQrUrl: '/images/kofi-qr.png',
|
||||
verseOfTheWeek: '',
|
||||
welcomeEmailSubject: 'Welcome to Verse by Verse with Nate',
|
||||
welcomeEmailGreetingPrefix: 'Glad you\'re here',
|
||||
welcomeEmailIntro: 'Thanks for subscribing to Verse by Verse with Nate - a Bible teaching podcast where we slow down, dig into the text, and pull out the nuggets God has for us word by word.',
|
||||
|
||||
+396
-246
@@ -9,6 +9,8 @@ import { Breadcrumbs } from './components/Breadcrumbs'
|
||||
import { StudyCertificate } from './components/StudyCertificate'
|
||||
import { EpisodeAudioPlayer } from './components/EpisodeAudioPlayer'
|
||||
import { NoteCard } from './components/NoteCard'
|
||||
import { NOTE_ANCHORS, NOTE_ANCHOR_LABELS, newNoteId, parseNoteEntries, serializeNoteEntries, noteHtmlToText } from '../shared/note-format.js'
|
||||
import type { NoteAnchorId, NoteEntry } from '../shared/note-format.js'
|
||||
import { StudySectionComments } from './components/StudySectionComments'
|
||||
|
||||
type Props = { content: SiteContent }
|
||||
@@ -240,31 +242,16 @@ function getReleaseDateDisplay(section: StudySection): string {
|
||||
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })
|
||||
}
|
||||
|
||||
function isFutureDate(iso: string) {
|
||||
return new Date(iso).getTime() > Date.now()
|
||||
}
|
||||
|
||||
function getNoteId(studySlug: string, sectionId: string) {
|
||||
return `${studySlug}--${sectionId}`
|
||||
}
|
||||
|
||||
type NoteAnchorId = 'scripture' | 'commentary' | 'questions' | 'general'
|
||||
const ANCHOR_LABELS: Record<string, string> = NOTE_ANCHOR_LABELS
|
||||
|
||||
const ANCHOR_LABELS: Record<string, string> = {
|
||||
scripture: 'Scripture Text',
|
||||
commentary: 'Commentary',
|
||||
questions: 'Reflection Questions',
|
||||
general: 'General Notes',
|
||||
}
|
||||
|
||||
function parseNoteMap(raw: string): Record<string, string> {
|
||||
if (!raw?.trim()) return {}
|
||||
try {
|
||||
const parsed = JSON.parse(raw)
|
||||
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
||||
return parsed as Record<string, string>
|
||||
}
|
||||
} catch {
|
||||
// Not valid JSON — treat the raw string as legacy plain-text notes.
|
||||
}
|
||||
return { general: raw }
|
||||
}
|
||||
|
||||
function getDisplayName(auth: StudyAuthState) {
|
||||
return auth.displayName?.trim() || auth.username.split('@')[0] || 'student'
|
||||
@@ -1020,7 +1007,7 @@ export function StudyLandingPage({ content }: Props) {
|
||||
<ul className="study-track-facts">
|
||||
{variant === 'planned' ? (
|
||||
<li>
|
||||
{study.startsAt && new Date(study.startsAt).getTime() > Date.now()
|
||||
{study.startsAt && isFutureDate(study.startsAt)
|
||||
? `Starts ${new Date(study.startsAt).toLocaleDateString('en-US', { weekday: 'long', month: 'long', day: 'numeric' })}`
|
||||
: 'Preparing lesson structure and media'}
|
||||
</li>
|
||||
@@ -1269,7 +1256,7 @@ export function StudySignupPage() {
|
||||
<p className="eyebrow">Free Student Account</p>
|
||||
<h2 className="auth-aside-title">Make every lesson your own.</h2>
|
||||
<ul className="auth-benefits">
|
||||
<li><span aria-hidden="true">📝</span><div><strong>Notes on every lesson</strong><p>Up to 500 notes across all tracks, each holding about 2,000 words.</p></div></li>
|
||||
<li><span aria-hidden="true">📝</span><div><strong>Notes on every lesson</strong><p>Up to 3,000 lesson notes across all tracks, each holding tens of thousands of words, with rich formatting.</p></div></li>
|
||||
<li><span aria-hidden="true">✅</span><div><strong>Track your progress</strong><p>Pick up exactly where you left off, on any device.</p></div></li>
|
||||
<li><span aria-hidden="true">🔒</span><div><strong>Private to you</strong><p>Your notes are tied to your account. Nobody else can read them.</p></div></li>
|
||||
<li><span aria-hidden="true">⚡</span><div><strong>Free, no ads</strong><p>Just an email and password. You stay signed in for 30 days.</p></div></li>
|
||||
@@ -1501,8 +1488,9 @@ export function StudyResetPasswordPage() {
|
||||
}, [token, newPassword, confirmPassword])
|
||||
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Reset password">
|
||||
<div className="thanks-card study-signup-page-card">
|
||||
<main className="auth-page" aria-label="Reset password">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Free Student Account</p>
|
||||
<h1>Reset Your Password</h1>
|
||||
|
||||
@@ -1549,6 +1537,7 @@ export function StudyResetPasswordPage() {
|
||||
<Link to="/study/signup" className="btn-secondary">Back to Sign In</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -1574,18 +1563,15 @@ export function StudyVerifyEmailPage() {
|
||||
}, [token])
|
||||
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Verify email">
|
||||
<div className="thanks-card study-signup-page-card">
|
||||
<main className="auth-page" aria-label="Verify email">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
{status === 'ok' && <span className="cp-icon" aria-hidden="true">✓</span>}
|
||||
<p className="eyebrow">Free Student Account</p>
|
||||
<h1>Verify Your Email</h1>
|
||||
<h1>{status === 'ok' ? 'Email Verified' : status === 'error' ? 'Verification Problem' : 'Verifying Your Email'}</h1>
|
||||
|
||||
{status === 'checking' && <p style={{ color: '#b09e79' }}>Verifying…</p>}
|
||||
{status === 'ok' && (
|
||||
<>
|
||||
<p className="study-signup-success">Your email address is verified.</p>
|
||||
<p style={{ color: '#b09e79', marginBottom: '1.5rem', fontSize: '0.95rem' }}>Thanks for confirming — you're all set.</p>
|
||||
</>
|
||||
)}
|
||||
{status === 'checking' && <p>Checking your link…</p>}
|
||||
{status === 'ok' && <p className="study-signup-success">Your email address is verified. You’re all set.</p>}
|
||||
{status === 'error' && <p className="study-signup-error">{message}</p>}
|
||||
|
||||
<div className="study-signup-actions" style={{ marginTop: '1.5rem' }}>
|
||||
@@ -1593,6 +1579,7 @@ export function StudyVerifyEmailPage() {
|
||||
<Link to="/study" className="btn-secondary">Back to Studies</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -1660,12 +1647,16 @@ export function ColossiansStudyIndexPage({ content }: Props) {
|
||||
|
||||
if (!study) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Study not found">
|
||||
<div className="thanks-card">
|
||||
<p className="eyebrow">Study Hub</p>
|
||||
<h1>Study not found</h1>
|
||||
<p>The study you requested is not available yet.</p>
|
||||
<Link to="/study" className="btn-primary">Back to Studies</Link>
|
||||
<main className="auth-page" aria-label="Study not found">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Study Hub</p>
|
||||
<h1>Study not found</h1>
|
||||
<p>The study you requested is not available yet.</p>
|
||||
<div className="study-signup-actions">
|
||||
<Link to="/study" className="btn-primary">Back to Studies</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -1707,108 +1698,89 @@ export function ColossiansStudyIndexPage({ content }: Props) {
|
||||
|
||||
const studyGuide = getStudyGuideLink(content, study)
|
||||
|
||||
const pct = sections.length > 0 ? Math.round((completedCount / sections.length) * 100) : 0
|
||||
|
||||
return (
|
||||
<main className="study-index-page" aria-label={`${study.title} study`}>
|
||||
<section className="section-study-course-hero">
|
||||
<div className="section-inner study-course-hero-inner">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title }]} />
|
||||
<p className="eyebrow">Online Bible Class</p>
|
||||
<h1>{study.title}</h1>
|
||||
<p className="study-course-hero-copy">{study.description}</p>
|
||||
<div className="study-course-meta">
|
||||
<span>{releasedSections.length} of {sections.length} lessons available</span>
|
||||
<span>Text + commentary + discussion</span>
|
||||
<span>Student notes enabled</span>
|
||||
{isSelfPaced && <span>Finished study — go at your own pace</span>}
|
||||
</div>
|
||||
{allLessonsDone && (
|
||||
<p className="study-completed-banner" role="status">🎉 You've completed this study. Your lessons, notes and certificate are yours to keep.</p>
|
||||
)}
|
||||
{enrolled && !progressLoading && sections.length > 0 && (
|
||||
<div className="study-progress" role="group" aria-label="Your progress">
|
||||
<div className="study-progress-label">
|
||||
<span>Your progress</span>
|
||||
<strong>{completedCount} of {sections.length} lessons completed</strong>
|
||||
</div>
|
||||
<div className="study-progress-track" role="progressbar" aria-valuemin={0} aria-valuemax={sections.length} aria-valuenow={completedCount}>
|
||||
<div className="study-progress-fill" style={{ width: `${Math.round((completedCount / sections.length) * 100)}%` }} />
|
||||
</div>
|
||||
<section className="si-hero">
|
||||
<div className="section-inner si-hero-inner">
|
||||
<div className="si-hero-main">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title }]} />
|
||||
<p className="eyebrow">Online Bible Class</p>
|
||||
<h1 className="si-title">{study.title}</h1>
|
||||
<p className="si-desc">{study.description}</p>
|
||||
<div className="si-chips">
|
||||
<span>{releasedSections.length} of {sections.length} lessons available</span>
|
||||
<span>Commentary + discussion</span>
|
||||
<span>Personal notes</span>
|
||||
{isSelfPaced && <span>Self-paced</span>}
|
||||
</div>
|
||||
)}
|
||||
<div className="study-course-hero-actions">
|
||||
{enrolled && resumeSection && <Link to={`/study/${study.slug}/${resumeSection.id}`} className="btn-primary">{allLessonsDone ? 'Review Lessons' : hasStarted ? 'Resume Where You Left Off' : 'Start Class'}</Link>}
|
||||
{!auth.authenticated && <Link to="/study/signup" className="btn-primary">Sign In to Enroll</Link>}
|
||||
{auth.authenticated && !enrolled && (
|
||||
<button type="button" className="btn-primary" disabled={enrolling} onClick={enrollInStudy}>
|
||||
{enrolling ? 'Enrolling...' : 'Enroll in This Study'}
|
||||
</button>
|
||||
)}
|
||||
{studyGuide && (studyGuide.downloadUrl
|
||||
? <a href={studyGuide.downloadUrl} target="_blank" rel="noopener noreferrer" download className="btn-secondary">📄 Download Study Guide</a>
|
||||
: <Link to={`/downloads/${studyGuide.pageId}`} className="btn-secondary">📄 Get the Study Guide</Link>)}
|
||||
{allLessonsDone && <Link to="/study/account" className="btn-secondary">🏅 My Certificate</Link>}
|
||||
{enrolled && <Link to={`/study/${study.slug}/notes`} className="btn-secondary">My Notes</Link>}
|
||||
{enrolled && studyStatus !== 'planned' && <Link to={`/study/${study.slug}/community`} className="btn-secondary">Community</Link>}
|
||||
{auth.authenticated && <Link to="/study/account" className="btn-secondary">My Account</Link>}
|
||||
<div className="si-actions">
|
||||
{enrolled && resumeSection && <Link to={`/study/${study.slug}/${resumeSection.id}`} className="btn-primary">{allLessonsDone ? 'Review lessons' : hasStarted ? 'Resume where you left off' : 'Start class'}</Link>}
|
||||
{!auth.authenticated && <Link to="/study/signup" className="btn-primary">Sign in to enroll</Link>}
|
||||
{auth.authenticated && !enrolled && (
|
||||
<button type="button" className="btn-primary" disabled={enrolling} onClick={enrollInStudy}>
|
||||
{enrolling ? 'Enrolling…' : 'Enroll in this study'}
|
||||
</button>
|
||||
)}
|
||||
{enrolled && <Link to={`/study/${study.slug}/notes`} className="btn-secondary">My notes</Link>}
|
||||
{enrolled && studyStatus !== 'planned' && <Link to={`/study/${study.slug}/community`} className="btn-secondary">Community</Link>}
|
||||
{studyGuide && (studyGuide.downloadUrl
|
||||
? <a href={studyGuide.downloadUrl} target="_blank" rel="noopener noreferrer" download className="btn-secondary">Study guide</a>
|
||||
: <Link to={`/downloads/${studyGuide.pageId}`} className="btn-secondary">Study guide</Link>)}
|
||||
{allLessonsDone && <Link to="/study/account" className="btn-secondary">My certificate</Link>}
|
||||
</div>
|
||||
{enrollMessage && <p className="study-note-status" role="status">{enrollMessage}</p>}
|
||||
</div>
|
||||
{enrollMessage && <p className="study-note-status" style={{ marginTop: '0.75rem' }}>{enrollMessage}</p>}
|
||||
|
||||
{enrolled && !progressLoading && sections.length > 0 && (
|
||||
<aside className="si-progress" aria-label="Your progress">
|
||||
<div className="si-ring" style={{ ['--pct' as string]: `${pct}%` }}>
|
||||
<span>{pct}%</span>
|
||||
</div>
|
||||
<div>
|
||||
<p className="si-progress-big">{completedCount} of {sections.length}</p>
|
||||
<p className="si-progress-sub">{allLessonsDone ? 'Study complete 🎉' : 'lessons completed'}</p>
|
||||
</div>
|
||||
</aside>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{auth.checked && auth.authenticated && !enrolled && (
|
||||
<section className="section-study-module" aria-label="Enrollment required">
|
||||
<div className="section-inner">
|
||||
<article className="study-module-row study-module-row--disabled" aria-disabled="true">
|
||||
<div className="study-module-row-left">
|
||||
<p className="study-module-lesson">Enrollment Required</p>
|
||||
<h3>Enroll before entering lessons</h3>
|
||||
<p>You must enroll in this study before opening lessons or notes.</p>
|
||||
<div style={{ marginTop: '0.75rem' }}>
|
||||
<button type="button" className="btn-primary" disabled={enrolling} onClick={enrollInStudy}>
|
||||
{enrolling ? 'Enrolling...' : `Enroll in ${study.title}`}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<section className="section-inner si-notice" aria-label="Enrollment required">
|
||||
<strong>Enroll to open the lessons.</strong>
|
||||
<span>Enrollment is free and lets you save notes and track progress.</span>
|
||||
<button type="button" className="btn-primary" disabled={enrolling} onClick={enrollInStudy}>
|
||||
{enrolling ? 'Enrolling…' : `Enroll in ${study.title}`}
|
||||
</button>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{sections.length === 0 && (
|
||||
<section className="section-study-module">
|
||||
<div className="section-inner">
|
||||
<article className="study-module-row study-module-row--disabled" aria-disabled="true">
|
||||
<div className="study-module-row-left">
|
||||
<p className="study-module-lesson">Planned</p>
|
||||
<h3>Lessons are being prepared</h3>
|
||||
<p>Use the admin Studies editor to add section lessons and publish when ready.</p>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<section className="section-inner si-notice">
|
||||
<strong>Lessons are being prepared.</strong>
|
||||
<span>Check back soon.</span>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{sections.length > 0 && (
|
||||
<section className="section-study-module" aria-label="Course lessons">
|
||||
<section className="si-lessons" aria-label="Course lessons">
|
||||
<div className="section-inner">
|
||||
<div className="study-module-header">
|
||||
<p>Course Lessons</p>
|
||||
<h2>{study.title}</h2>
|
||||
</div>
|
||||
{chaptersWithLessons.map(({ chapter }) => {
|
||||
const chapterSections = sections.filter(item => item.chapter === chapter)
|
||||
const chapterDone = chapterSections.filter(item => studyProgress.completedSectionIds.includes(item.id)).length
|
||||
return (
|
||||
<details className="study-chapter" key={chapter} open={chaptersWithLessons.length === 1 || chapter === resumeChapter}>
|
||||
<summary className="study-chapter-head">
|
||||
<h3>Chapter {chapter}</h3>
|
||||
<details className="si-chapter" key={chapter} open={chaptersWithLessons.length === 1 || chapter === resumeChapter}>
|
||||
<summary className="si-chapter-head">
|
||||
<h2>Chapter {chapter}</h2>
|
||||
<span>
|
||||
{enrolled && !progressLoading
|
||||
? `${chapterDone} of ${chapterSections.length} completed`
|
||||
: `${chapterSections.length} ${chapterSections.length === 1 ? 'lesson' : 'lessons'}`}
|
||||
</span>
|
||||
</summary>
|
||||
<div className="study-module-list">
|
||||
<div className="si-list">
|
||||
{chapterSections.map(section => {
|
||||
const sectionIdx = sections.indexOf(section)
|
||||
const lessonNumber = sectionIdx + 1
|
||||
@@ -1819,34 +1791,30 @@ export function ColossiansStudyIndexPage({ content }: Props) {
|
||||
const completed = studyProgress.completedSectionIds.includes(section.id)
|
||||
const lockedByProgress = enrolled && !isSelfPaced && !coming && sectionIdx > 0 && !prevCompleted && !completed
|
||||
const isDisabled = coming || !enrolled || lockedByProgress
|
||||
const done = completed && enrolled
|
||||
|
||||
return (
|
||||
<Link key={section.id} to={isDisabled ? '#' : `/study/${study.slug}/${section.id}`} className={`study-module-row${isDisabled ? ' study-module-row--disabled' : ''}${coming ? ' study-module-row--coming' : ''}${completed && enrolled ? ' study-module-row--done' : ''}`} aria-disabled={isDisabled || undefined} onClick={e => isDisabled && e.preventDefault()}>
|
||||
<div className="study-module-row-left">
|
||||
<div className="study-lesson-meta">
|
||||
<p className="study-module-lesson">Lesson {lessonNumber}</p>
|
||||
<Link
|
||||
key={section.id}
|
||||
to={isDisabled ? '#' : `/study/${study.slug}/${section.id}`}
|
||||
className={`si-row${isDisabled ? ' si-row--disabled' : ''}${done ? ' si-row--done' : ''}`}
|
||||
aria-disabled={isDisabled || undefined}
|
||||
onClick={e => isDisabled && e.preventDefault()}
|
||||
>
|
||||
<span className="si-num" aria-hidden="true">{done ? '✓' : lessonNumber}</span>
|
||||
<div className="si-row-body">
|
||||
<div className="si-row-top">
|
||||
<h3>{section.title}</h3>
|
||||
{isNew && <span className="lesson-badge lesson-badge--new">New</span>}
|
||||
{coming && <span className="lesson-badge lesson-badge--coming">Coming {getReleaseDateDisplay(section)}</span>}
|
||||
{!coming && !enrolled && <span className="lesson-badge lesson-badge--enroll">Enroll to open</span>}
|
||||
{lockedByProgress && <span className="lesson-badge lesson-badge--locked">Finish the previous lesson first</span>}
|
||||
{enrolled && !lockedByProgress && completed && (
|
||||
<span className="lesson-badge lesson-badge--done">
|
||||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" aria-hidden="true">
|
||||
<circle cx="6.5" cy="6.5" r="6" stroke="currentColor" strokeWidth="1.2" />
|
||||
<path d="M3.5 6.5l2 2 3.5-3.5" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />
|
||||
</svg>
|
||||
Completed
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<h3>{section.title}</h3>
|
||||
<p>{section.summary}</p>
|
||||
</div>
|
||||
<div className="study-module-row-right">
|
||||
<p className="study-section-reference">{section.reference}</p>
|
||||
<p className="study-module-focus">Focus question</p>
|
||||
<p>{getPrimaryQuestion(section)}</p>
|
||||
{section.reference && <p className="si-ref">{section.reference}</p>}
|
||||
{section.summary && <p className="si-summary">{section.summary}</p>}
|
||||
<p className="si-focus"><span>Focus:</span> {getPrimaryQuestion(section)}</p>
|
||||
</div>
|
||||
{!isDisabled && <span className="si-arrow" aria-hidden="true">→</span>}
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
@@ -1881,8 +1849,8 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
const [enrollBusy, setEnrollBusy] = useState(false)
|
||||
const [enrollMessage, setEnrollMessage] = useState('')
|
||||
|
||||
const [noteMap, setNoteMap] = useState<Record<string, string>>({})
|
||||
const [openAnchor, setOpenAnchor] = useState<NoteAnchorId | null>(null)
|
||||
const [noteEntries, setNoteEntries] = useState<NoteEntry[]>([])
|
||||
const [activeNoteId, setActiveNoteId] = useState<string | null>(null)
|
||||
const [noteLoading, setNoteLoading] = useState(false)
|
||||
const [noteMessage, setNoteMessage] = useState('')
|
||||
const noteMapDirtyRef = useRef(false)
|
||||
@@ -1901,12 +1869,13 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
const [bsbPassage, setBsbPassage] = useState<string | null>(null)
|
||||
const [bsbPassageLoading, setBsbPassageLoading] = useState(false)
|
||||
|
||||
const savedNoteCount = Object.values(noteMap).filter(v => v?.trim()).length
|
||||
const lessonAudioEmbedUrl = useMemo(() => {
|
||||
const trimmed = section?.audioEmbedUrl?.trim() ?? ''
|
||||
if (!trimmed) return ''
|
||||
return /^https?:\/\//i.test(trimmed) ? trimmed : ''
|
||||
}, [section?.audioEmbedUrl])
|
||||
const activeEntry = noteEntries.find(e => e.id === activeNoteId) ?? null
|
||||
const openAnchor: NoteAnchorId | null = activeEntry?.anchor ?? null
|
||||
const savedEntries = noteEntries.filter(e => e.html.trim())
|
||||
const savedNoteCount = savedEntries.length
|
||||
const hasNoteOn = (anchor: NoteAnchorId) => savedEntries.some(e => e.anchor === anchor)
|
||||
const audioEmbedTrimmed = section?.audioEmbedUrl?.trim() ?? ''
|
||||
const lessonAudioEmbedUrl = /^https?:\/\//i.test(audioEmbedTrimmed) ? audioEmbedTrimmed : ''
|
||||
|
||||
const currentStudySlug = study?.slug ?? 'colossians'
|
||||
const noteId = section?.id ? getNoteId(currentStudySlug, section.id) : ''
|
||||
@@ -1987,7 +1956,8 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
|
||||
useEffect(() => {
|
||||
if (!auth.authenticated || !noteId || !isEnrolled) {
|
||||
setNoteMap({})
|
||||
setNoteEntries([])
|
||||
setActiveNoteId(null)
|
||||
noteMapDirtyRef.current = false
|
||||
return
|
||||
}
|
||||
@@ -1999,7 +1969,8 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
readJson<{ note: string }>(`/api/study-notes/${encodeURIComponent(noteId)}`)
|
||||
.then(data => {
|
||||
if (cancelled) return
|
||||
setNoteMap(parseNoteMap(data.note ?? ''))
|
||||
setNoteEntries(parseNoteEntries(data.note ?? ''))
|
||||
setActiveNoteId(null)
|
||||
noteMapDirtyRef.current = false
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -2043,16 +2014,39 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateNote(anchor: NoteAnchorId, html: string) {
|
||||
function updateNoteEntry(id: string, html: string) {
|
||||
noteMapDirtyRef.current = true
|
||||
setNoteMap(prev => ({ ...prev, [anchor]: html }))
|
||||
setNoteEntries(prev => prev.map(e => e.id === id ? { ...e, html, updatedAt: new Date().toISOString() } : e))
|
||||
}
|
||||
|
||||
function addNoteEntry(anchor: NoteAnchorId, html = '') {
|
||||
const entry: NoteEntry = { id: newNoteId(), anchor, html, updatedAt: html ? new Date().toISOString() : null }
|
||||
if (html) noteMapDirtyRef.current = true
|
||||
setNoteEntries(prev => [...prev, entry])
|
||||
setActiveNoteId(entry.id)
|
||||
}
|
||||
|
||||
function deleteNoteEntry(id: string) {
|
||||
noteMapDirtyRef.current = true
|
||||
setNoteEntries(prev => prev.filter(e => e.id !== id))
|
||||
setActiveNoteId(null)
|
||||
}
|
||||
|
||||
function toggleAnchorNote(anchor: NoteAnchorId) {
|
||||
if (openAnchor === anchor) {
|
||||
setActiveNoteId(null)
|
||||
return
|
||||
}
|
||||
const existing = [...noteEntries].reverse().find(e => e.anchor === anchor)
|
||||
if (existing) setActiveNoteId(existing.id)
|
||||
else addNoteEntry(anchor)
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!openAnchor) return
|
||||
function onKeyDown(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape') setOpenAnchor(null)
|
||||
if (e.key === 'Escape') setActiveNoteId(null)
|
||||
}
|
||||
document.addEventListener('keydown', onKeyDown)
|
||||
return () => document.removeEventListener('keydown', onKeyDown)
|
||||
@@ -2068,16 +2062,18 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
await readJson<{ ok: boolean }>(`/api/study-notes/${encodeURIComponent(noteId)}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ note: JSON.stringify(noteMap) }),
|
||||
body: JSON.stringify({ note: serializeNoteEntries(noteEntries) }),
|
||||
})
|
||||
setNoteMessage('')
|
||||
setAutoSaveMsg('Auto-saved.')
|
||||
setTimeout(() => setAutoSaveMsg(''), 3000)
|
||||
} catch {
|
||||
} catch (err) {
|
||||
noteMapDirtyRef.current = true
|
||||
setNoteMessage(err instanceof Error ? err.message : 'Unable to save your note.')
|
||||
}
|
||||
}, 2000)
|
||||
return () => clearTimeout(timer)
|
||||
}, [noteMap, noteId, auth.authenticated, noteLoading])
|
||||
}, [noteEntries, noteId, auth.authenticated, noteLoading])
|
||||
|
||||
useEffect(() => {
|
||||
if (!auth.authenticated || !isEnrolled || !study || !section?.id) {
|
||||
@@ -2128,12 +2124,14 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
|
||||
function appendSelectedTextToNotes(selectedText: string, anchor: NoteAnchorId = 'general') {
|
||||
if (!selectedText.trim()) return
|
||||
const existing = noteMap[anchor] ?? ''
|
||||
const appended = existing
|
||||
? `${existing}<p>${selectedText.trim()}</p>`
|
||||
: `<p>${selectedText.trim()}</p>`
|
||||
updateNote(anchor, appended)
|
||||
setOpenAnchor(anchor)
|
||||
const safe = selectedText.trim().replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
||||
const latest = [...noteEntries].reverse().find(e => e.anchor === anchor)
|
||||
if (latest) {
|
||||
updateNoteEntry(latest.id, `${latest.html}<p>${safe}</p>`)
|
||||
setActiveNoteId(latest.id)
|
||||
} else {
|
||||
addNoteEntry(anchor, `<p>${safe}</p>`)
|
||||
}
|
||||
}
|
||||
|
||||
function handleLessonContentContextMenu(e: React.MouseEvent<HTMLDivElement>) {
|
||||
@@ -2208,12 +2206,14 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
|
||||
if (!study || !section) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Section not found">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Section not found">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Study Hub</p>
|
||||
<h1>Section not found</h1>
|
||||
<p>The section you requested is not available yet.</p>
|
||||
<Link to="/study" className="btn-primary">Back to Studies</Link>
|
||||
<div className="study-signup-actions"><Link to="/study" className="btn-primary">Back to Studies</Link></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -2222,12 +2222,14 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
if (!sectionIsReleased) {
|
||||
const releaseDateDisplay = getReleaseDateDisplay(section)
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Lesson not yet available">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Lesson not yet available">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">{study.title}</p>
|
||||
<h1>Lesson Coming Soon</h1>
|
||||
<p>{releaseDateDisplay ? `This lesson will be available on ${releaseDateDisplay}.` : 'This lesson will be available soon.'}</p>
|
||||
<Link to={`/study/${study.slug}`} className="btn-primary">Back to Lessons</Link>
|
||||
<div className="study-signup-actions"><Link to={`/study/${study.slug}`} className="btn-primary">Back to Lessons</Link></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -2235,11 +2237,13 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
|
||||
if (!auth.checked) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Loading">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Loading">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">{study.title}</p>
|
||||
<p>Loading lesson...</p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -2320,17 +2324,24 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
<section className="section-study-classroom" onContextMenu={handleLessonContentContextMenu}>
|
||||
<div className="section-inner study-classroom-shell">
|
||||
<div className="study-classroom-main">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title, href: `/study/${study.slug}` }, { label: `Lesson ${lessonNumber}` }]} />
|
||||
<Link to={`/study/${study.slug}`} className="study-detail-back">Back to {study.title}</Link>
|
||||
<p className="study-lesson-label">Lesson {lessonNumber} of {sections.length}</p>
|
||||
{sections.length > 0 && (
|
||||
<div className="study-lesson-progress-bar" role="progressbar" aria-valuenow={completedSectionIds.length} aria-valuemax={sections.length} aria-label={`${completedSectionIds.length} of ${sections.length} lessons completed`}>
|
||||
<div className="study-lesson-progress-fill" style={{ width: `${Math.round((completedSectionIds.length / sections.length) * 100)}%` }} />
|
||||
<header className="sl-head">
|
||||
<Breadcrumbs items={[{ label: 'Home', href: '/' }, { label: 'Studies', href: '/study' }, { label: study.title, href: `/study/${study.slug}` }, { label: `Lesson ${lessonNumber}` }]} />
|
||||
<div className="sl-head-meta">
|
||||
<span className="sl-lesson-pill">Lesson {lessonNumber} of {sections.length}</span>
|
||||
{section.reference && <span className="sl-ref">{section.reference}</span>}
|
||||
{lessonCompleted && <span className="sl-done">✓ Completed</span>}
|
||||
</div>
|
||||
)}
|
||||
<h1>{section.title}</h1>
|
||||
<p className="study-detail-reference">{section.reference}</p>
|
||||
<p className="study-detail-summary">{section.summary}</p>
|
||||
<h1 className="sl-title">{section.title}</h1>
|
||||
{section.summary && <p className="sl-summary">{section.summary}</p>}
|
||||
{sections.length > 0 && (
|
||||
<div className="sl-progress" aria-label={`${completedSectionIds.length} of ${sections.length} lessons completed`}>
|
||||
<div className="study-lesson-progress-bar" role="progressbar" aria-valuenow={completedSectionIds.length} aria-valuemax={sections.length}>
|
||||
<div className="study-lesson-progress-fill" style={{ width: `${Math.round((completedSectionIds.length / sections.length) * 100)}%` }} />
|
||||
</div>
|
||||
<span>{completedSectionIds.length} of {sections.length} lessons completed in {study.title}</span>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
|
||||
{lessonAudioEmbedUrl && (
|
||||
<article className="study-class-block">
|
||||
@@ -2357,10 +2368,10 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
{isEnrolled && (
|
||||
<button
|
||||
type="button"
|
||||
className={`note-anchor-btn${noteMap['scripture']?.trim() ? ' note-anchor-btn--has-note' : ''}${openAnchor === 'scripture' ? ' note-anchor-btn--open' : ''}`}
|
||||
onClick={() => setOpenAnchor(curr => curr === 'scripture' ? null : 'scripture')}
|
||||
className={`note-anchor-btn${hasNoteOn('scripture') ? ' note-anchor-btn--has-note' : ''}${openAnchor === 'scripture' ? ' note-anchor-btn--open' : ''}`}
|
||||
onClick={() => toggleAnchorNote('scripture')}
|
||||
aria-pressed={openAnchor === 'scripture'}
|
||||
>{noteMap['scripture']?.trim() ? '✎ Note' : '+ Note'}</button>
|
||||
>{hasNoteOn('scripture') ? '✎ Note' : '+ Note'}</button>
|
||||
)}
|
||||
<h2>Scripture Text</h2>
|
||||
{bsbPassageLoading
|
||||
@@ -2380,10 +2391,10 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
{isEnrolled && (
|
||||
<button
|
||||
type="button"
|
||||
className={`note-anchor-btn${noteMap['commentary']?.trim() ? ' note-anchor-btn--has-note' : ''}${openAnchor === 'commentary' ? ' note-anchor-btn--open' : ''}`}
|
||||
onClick={() => setOpenAnchor(curr => curr === 'commentary' ? null : 'commentary')}
|
||||
className={`note-anchor-btn${hasNoteOn('commentary') ? ' note-anchor-btn--has-note' : ''}${openAnchor === 'commentary' ? ' note-anchor-btn--open' : ''}`}
|
||||
onClick={() => toggleAnchorNote('commentary')}
|
||||
aria-pressed={openAnchor === 'commentary'}
|
||||
>{noteMap['commentary']?.trim() ? '✎ Note' : '+ Note'}</button>
|
||||
>{hasNoteOn('commentary') ? '✎ Note' : '+ Note'}</button>
|
||||
)}
|
||||
<h2>Instructor Commentary</h2>
|
||||
{section.commentary.split(/\n{2,}/).map((para, i) => (
|
||||
@@ -2399,10 +2410,10 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
{isEnrolled && (
|
||||
<button
|
||||
type="button"
|
||||
className={`note-anchor-btn${noteMap['questions']?.trim() ? ' note-anchor-btn--has-note' : ''}${openAnchor === 'questions' ? ' note-anchor-btn--open' : ''}`}
|
||||
onClick={() => setOpenAnchor(curr => curr === 'questions' ? null : 'questions')}
|
||||
className={`note-anchor-btn${hasNoteOn('questions') ? ' note-anchor-btn--has-note' : ''}${openAnchor === 'questions' ? ' note-anchor-btn--open' : ''}`}
|
||||
onClick={() => toggleAnchorNote('questions')}
|
||||
aria-pressed={openAnchor === 'questions'}
|
||||
>{noteMap['questions']?.trim() ? '✎ Note' : '+ Note'}</button>
|
||||
>{hasNoteOn('questions') ? '✎ Note' : '+ Note'}</button>
|
||||
)}
|
||||
<h2>Reflection Questions</h2>
|
||||
<ol className="study-detail-list study-detail-list--questions">
|
||||
@@ -2544,6 +2555,31 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
</p>
|
||||
<StudySectionComments studySlug={currentStudySlug} sectionId={section.id} isEnrolled={isEnrolled} />
|
||||
</article>}
|
||||
|
||||
<nav className="sl-pager" aria-label="Lesson navigation">
|
||||
{previousSection ? (
|
||||
<Link to={`/study/${study.slug}/${previousSection.id}`} className="sl-pager-link">
|
||||
<span>← Previous lesson</span>
|
||||
<strong>{previousSection.title}</strong>
|
||||
</Link>
|
||||
) : <span />}
|
||||
{nextSection && isSectionReleased(nextSection) && lessonCompleted ? (
|
||||
<Link to={`/study/${study.slug}/${nextSection.id}`} className="sl-pager-link sl-pager-link--next">
|
||||
<span>Next lesson →</span>
|
||||
<strong>{nextSection.title}</strong>
|
||||
</Link>
|
||||
) : nextSection ? (
|
||||
<div className="sl-pager-link sl-pager-link--next sl-pager-link--wait">
|
||||
<span>Next lesson</span>
|
||||
<strong>{!isSectionReleased(nextSection) ? `Available ${getReleaseDateDisplay(nextSection)}` : 'Complete this lesson to continue'}</strong>
|
||||
</div>
|
||||
) : (
|
||||
<Link to={`/study/${study.slug}`} className="sl-pager-link sl-pager-link--next">
|
||||
<span>Finished</span>
|
||||
<strong>Back to all lessons →</strong>
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<aside className="study-classroom-sidebar" aria-label="Lesson tools">
|
||||
@@ -2599,20 +2635,52 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
||||
<>
|
||||
{noteLoading ? (
|
||||
<p style={{ color: '#7a7060', fontSize: '0.85rem' }}>Loading notes…</p>
|
||||
) : openAnchor ? (
|
||||
<NoteCard
|
||||
anchorLabel={ANCHOR_LABELS[openAnchor] ?? 'Notes'}
|
||||
html={noteMap[openAnchor] ?? ''}
|
||||
autoSaveMsg={autoSaveMsg}
|
||||
onChange={html => updateNote(openAnchor as NoteAnchorId, html)}
|
||||
onClose={() => setOpenAnchor(null)}
|
||||
/>
|
||||
) : (
|
||||
<p style={{ fontSize: '0.85rem', color: '#5a5040', lineHeight: 1.55 }}>
|
||||
{savedNoteCount > 0
|
||||
? `${savedNoteCount} note${savedNoteCount !== 1 ? 's' : ''} saved. Click a section's Note button to edit.`
|
||||
: 'Click the Note button on Scripture, Commentary, or Reflection Questions to write notes here.'}
|
||||
</p>
|
||||
<>
|
||||
{savedEntries.length > 0 && (
|
||||
<ul className="note-entry-list" aria-label="Notes on this lesson">
|
||||
{savedEntries.map(entry => (
|
||||
<li key={entry.id}>
|
||||
<button
|
||||
type="button"
|
||||
className={`note-entry${entry.id === activeNoteId ? ' note-entry--active' : ''}`}
|
||||
onClick={() => setActiveNoteId(entry.id === activeNoteId ? null : entry.id)}
|
||||
>
|
||||
<span className="note-entry-label">{ANCHOR_LABELS[entry.anchor]}{entry.updatedAt ? ` · ${formatRelativeTime(entry.updatedAt)}` : ''}</span>
|
||||
<span className="note-entry-snippet">{noteHtmlToText(entry.html).slice(0, 70)}</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{activeEntry && (
|
||||
<NoteCard
|
||||
key={activeEntry.id}
|
||||
anchorLabel={ANCHOR_LABELS[activeEntry.anchor] ?? 'Notes'}
|
||||
html={activeEntry.html}
|
||||
updatedAt={activeEntry.updatedAt}
|
||||
autoSaveMsg={autoSaveMsg}
|
||||
onChange={html => updateNoteEntry(activeEntry.id, html)}
|
||||
onDelete={() => deleteNoteEntry(activeEntry.id)}
|
||||
onClose={() => setActiveNoteId(null)}
|
||||
/>
|
||||
)}
|
||||
{isEnrolled && (
|
||||
<div className="note-add-row">
|
||||
<span>Add a note on:</span>
|
||||
{NOTE_ANCHORS.map(anchor => (
|
||||
<button key={anchor} type="button" className="note-add-chip" onClick={() => addNoteEntry(anchor)}>
|
||||
+ {ANCHOR_LABELS[anchor]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{!activeEntry && savedEntries.length === 0 && (
|
||||
<p style={{ fontSize: '0.85rem', color: '#5a5040', lineHeight: 1.55 }}>
|
||||
Click the Note button on Scripture, Commentary, or Reflection Questions, or use the buttons above, to write notes here.
|
||||
</p>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
{autoSaveMsg && <p style={{ fontSize: '0.82rem', color: '#7a9c6a', marginTop: '0.35rem' }}>{autoSaveMsg}</p>}
|
||||
{noteMessage && <p className="study-note-status" style={{ marginTop: '0.35rem' }}>{noteMessage}</p>}
|
||||
@@ -2708,6 +2776,7 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
const [message, setMessage] = useState('')
|
||||
const [activeNoteTab, setActiveNoteTab] = useState('')
|
||||
const [noteQuery, setNoteQuery] = useState('')
|
||||
const [noteSort, setNoteSort] = useState<'lesson' | 'recent'>('lesson')
|
||||
|
||||
usePageMeta(
|
||||
study ? `My Notes | ${study.title}` : 'My Study Notes',
|
||||
@@ -2760,12 +2829,14 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
|
||||
if (!study) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Study not found">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Study not found">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Study Hub</p>
|
||||
<h1>Study not found</h1>
|
||||
<p>The study you requested is not available yet.</p>
|
||||
<Link to="/study" className="btn-primary">Back to Studies</Link>
|
||||
<div className="study-signup-actions"><Link to="/study" className="btn-primary">Back to Studies</Link></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -2787,8 +2858,10 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
: []
|
||||
|
||||
const stripHtml = (html: string) => DOMPurify.sanitize(html, { ALLOWED_TAGS: [] }).replace(/\s+/g, ' ').trim()
|
||||
const noteText = (raw: string) => Object.values(parseNoteMap(raw)).map(value => stripHtml(value ?? '')).filter(Boolean).join(' · ')
|
||||
const noteText = (raw: string) => parseNoteEntries(raw).map(e => stripHtml(e.html)).filter(Boolean).join(' · ')
|
||||
const lastEdited = (raw: string) => parseNoteEntries(raw).reduce((max, e) => (e.updatedAt && e.updatedAt > max ? e.updatedAt : max), '')
|
||||
const sorted = [...entries].sort((a, b) => {
|
||||
if (noteSort === 'recent') return lastEdited(b.note).localeCompare(lastEdited(a.note))
|
||||
const aNum = a.section ? getLessonNumber(study.sections, a.section.id) : 0
|
||||
const bNum = b.section ? getLessonNumber(study.sections, b.section.id) : 0
|
||||
return aNum - bNum
|
||||
@@ -2799,6 +2872,34 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
: sorted
|
||||
const active = visible.find(item => item.sectionId === activeNoteTab) ?? visible[0]
|
||||
|
||||
const otherStudyMatches = queryText
|
||||
? enrolledStudies
|
||||
.filter(s2 => s2.slug !== study.slug)
|
||||
.flatMap(s2 => {
|
||||
const p2 = `${s2.slug}--`
|
||||
return Object.entries(notes)
|
||||
.filter(([key]) => key.startsWith(p2))
|
||||
.map(([key, note]) => ({ study: s2, section: s2.sections.find(sec => sec.id === key.slice(p2.length)), note }))
|
||||
.filter(item => item.section && `${item.section.title} ${item.section.reference ?? ''} ${noteText(item.note)}`.toLowerCase().includes(queryText))
|
||||
})
|
||||
: []
|
||||
|
||||
function downloadStudyNotesMarkdown() {
|
||||
const body = sorted.map(({ section, sectionId, note }) => {
|
||||
const blocks = parseNoteEntries(note)
|
||||
.map(e => `### ${ANCHOR_LABELS[e.anchor]}${e.updatedAt ? ` (${new Date(e.updatedAt).toLocaleDateString('en-US')})` : ''}\n\n${stripHtml(e.html)}`)
|
||||
.join('\n\n')
|
||||
return `## ${section?.title ?? sectionId}${section?.reference ? ` (${section.reference})` : ''}\n\n${blocks}`
|
||||
}).join('\n\n---\n\n')
|
||||
const blob = new Blob([`# ${study!.title} — My Notes\n\n${body}\n`], { type: 'text/markdown' })
|
||||
const url = URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = `${study!.slug}-notes-${new Date().toISOString().slice(0, 10)}.md`
|
||||
a.click()
|
||||
URL.revokeObjectURL(url)
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="notes-page" aria-label="My study notes">
|
||||
<div className="notes-shell">
|
||||
@@ -2872,8 +2973,12 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
value={noteQuery}
|
||||
onChange={e => setNoteQuery(e.target.value)}
|
||||
/>
|
||||
<div className="notes-sort" role="group" aria-label="Sort notes">
|
||||
<button type="button" className={noteSort === 'lesson' ? 'notes-sort-btn notes-sort-btn--active' : 'notes-sort-btn'} onClick={() => setNoteSort('lesson')}>Lesson order</button>
|
||||
<button type="button" className={noteSort === 'recent' ? 'notes-sort-btn notes-sort-btn--active' : 'notes-sort-btn'} onClick={() => setNoteSort('recent')}>Recently edited</button>
|
||||
</div>
|
||||
{visible.length === 0 ? (
|
||||
<p className="notes-empty-text">No notes match “{noteQuery.trim()}”.</p>
|
||||
<p className="notes-empty-text">No notes match “{noteQuery.trim()}” in this study.</p>
|
||||
) : (
|
||||
<ul className="notes-list" role="tablist" aria-label="Lesson notes">
|
||||
{visible.map(({ sectionId, section, note }) => {
|
||||
@@ -2891,7 +2996,7 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
<span className="notes-item-number" aria-hidden="true">{lessonNumber || '•'}</span>
|
||||
<span className="notes-item-body">
|
||||
<strong>{section?.title ?? 'Saved note'}</strong>
|
||||
<small>{section?.reference ?? ''}</small>
|
||||
<small>{section?.reference ?? ''}{lastEdited(note) ? ` · edited ${formatRelativeTime(lastEdited(note))}` : ''}</small>
|
||||
<span className="notes-item-snippet">{noteText(note).slice(0, 110)}</span>
|
||||
</span>
|
||||
</button>
|
||||
@@ -2900,20 +3005,55 @@ export function ColossiansStudyNotesPage({ content }: Props) {
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
{otherStudyMatches.length > 0 && (
|
||||
<div className="notes-other-matches">
|
||||
<p className="notes-reader-label">Also in your other studies</p>
|
||||
<ul className="notes-list">
|
||||
{otherStudyMatches.map(({ study: s2, section, note }) => (
|
||||
<li key={`${s2.slug}-${section!.id}`}>
|
||||
<Link className="notes-item" to={`/study/${s2.slug}/notes`}>
|
||||
<span className="notes-item-body">
|
||||
<strong>{section!.title}</strong>
|
||||
<small>{s2.title}</small>
|
||||
<span className="notes-item-snippet">{noteText(note).slice(0, 110)}</span>
|
||||
</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
<button type="button" className="btn-secondary notes-export-btn" onClick={downloadStudyNotesMarkdown}>Download notes (.md)</button>
|
||||
</aside>
|
||||
|
||||
{active && (
|
||||
<article className="notes-reader" aria-label="Note">
|
||||
<p className="notes-reader-label">{active.section ? `Lesson ${getLessonNumber(study.sections, active.section.id)}` : 'Saved note'}{active.section?.reference ? ` · ${active.section.reference}` : ''}</p>
|
||||
<h2>{active.section?.title ?? active.sectionId}</h2>
|
||||
<p className="notes-reader-meta">
|
||||
{noteText(active.note).split(/\s+/).filter(Boolean).length.toLocaleString()} words
|
||||
{' · '}
|
||||
<button
|
||||
type="button"
|
||||
className="notes-copy-btn"
|
||||
onClick={() => {
|
||||
const text = parseNoteEntries(active.note)
|
||||
.map(e => `${ANCHOR_LABELS[e.anchor]}\n${stripHtml(e.html)}`)
|
||||
.join('\n\n')
|
||||
navigator.clipboard?.writeText(text).then(() => setMessage('Note copied to clipboard.'), () => setMessage('Unable to copy this note.'))
|
||||
}}
|
||||
>Copy note</button>
|
||||
</p>
|
||||
{(() => {
|
||||
const anchorMap = parseNoteMap(active.note)
|
||||
const blocks = Object.entries(anchorMap).filter(([, html]) => html?.trim())
|
||||
const blocks = parseNoteEntries(active.note)
|
||||
if (blocks.length === 0) return <p className="notes-empty-text">No notes saved for this lesson yet.</p>
|
||||
return blocks.map(([key, html]) => (
|
||||
<section className="notes-block" key={key}>
|
||||
<h3>{ANCHOR_LABELS[key] ?? key}</h3>
|
||||
<div className="study-note-rich-content" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(html) }} />
|
||||
return blocks.map(entry => (
|
||||
<section className="notes-block" key={entry.id}>
|
||||
<h3>
|
||||
{ANCHOR_LABELS[entry.anchor]}
|
||||
{entry.updatedAt && <small className="notes-block-date"> · edited {new Date(entry.updatedAt).toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}</small>}
|
||||
</h3>
|
||||
<div className="study-note-rich-content" dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(entry.html) }} />
|
||||
</section>
|
||||
))
|
||||
})()}
|
||||
@@ -4133,12 +4273,14 @@ export function StudyQuizPage({ content }: Props) {
|
||||
|
||||
if (!study || !section) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Discussion questions not found">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Discussion questions not found">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Reflection Questions</p>
|
||||
<h1>Discussion questions not found</h1>
|
||||
<p>The reflection questions you requested are not available.</p>
|
||||
<Link to="/study" className="btn-primary">Back to Studies</Link>
|
||||
<div className="study-signup-actions"><Link to="/study" className="btn-primary">Back to Studies</Link></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -4150,20 +4292,24 @@ export function StudyQuizPage({ content }: Props) {
|
||||
|
||||
if (!auth.checked) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Loading reflection questions">
|
||||
<div className="thanks-card"><p>Loading reflection questions...</p></div>
|
||||
<main className="auth-page" aria-label="Loading reflection questions">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center"><p>Loading reflection questions...</p></div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
if (!auth.authenticated) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Sign in required">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Sign in required">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Reflection Questions</p>
|
||||
<h1>Sign In Required</h1>
|
||||
<p>You need to sign in before you can view and save your discussion answers.</p>
|
||||
<Link to="/study/signup" className="btn-primary">Sign In</Link>
|
||||
<div className="study-signup-actions"><Link to="/study/signup" className="btn-primary">Sign In</Link></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -4171,12 +4317,14 @@ export function StudyQuizPage({ content }: Props) {
|
||||
|
||||
if (!isEnrolled) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Enrollment required">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Enrollment required">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Reflection Questions</p>
|
||||
<h1>Enroll to Access Reflection Questions</h1>
|
||||
<p>Please enroll in {study.title} to open the reflection questions for this lesson.</p>
|
||||
<Link to={`/study/${study.slug}`} className="btn-primary">Go to Study</Link>
|
||||
<div className="study-signup-actions"><Link to={`/study/${study.slug}`} className="btn-primary">Go to Study</Link></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -4312,20 +4460,24 @@ export function StudyDiscussionHubPage({ content }: Props) {
|
||||
|
||||
if (!auth.checked) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Loading">
|
||||
<div className="thanks-card"><p>Loading...</p></div>
|
||||
<main className="auth-page" aria-label="Loading">
|
||||
<div className="auth-shell auth-shell--single"><div className="auth-card auth-card--center"><p>Loading…</p></div></div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
if (!auth.authenticated) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Sign in required">
|
||||
<div className="thanks-card">
|
||||
<p className="eyebrow">Study Discussion</p>
|
||||
<h1>Sign In Required</h1>
|
||||
<p>Create a free student account to see and join the conversation with other students.</p>
|
||||
<Link to="/study/signup" className="btn-primary" style={{ marginTop: '1rem', display: 'inline-block' }}>Sign In</Link>
|
||||
<main className="auth-page" aria-label="Sign in required">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Study Discussion</p>
|
||||
<h1>Sign In Required</h1>
|
||||
<p>Create a free student account to see and join the conversation with other students.</p>
|
||||
<div className="study-signup-actions">
|
||||
<Link to="/study/signup" className="btn-primary">Create Account or Sign In</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
@@ -4344,22 +4496,16 @@ export function StudyDiscussionHubPage({ content }: Props) {
|
||||
{openDiscussionStudies.length === 0 ? (
|
||||
<p className="study-detail-copy">There are no studies open for discussion yet. Check back when the next one starts.</p>
|
||||
) : (
|
||||
<div className="study-module-list">
|
||||
<div className="sdh-grid">
|
||||
{openDiscussionStudies.map(study => {
|
||||
const enrolled = isEnrolledInStudy(auth, study.slug)
|
||||
return (
|
||||
<article key={study.slug} className="study-module-row">
|
||||
<div className="study-module-row-left">
|
||||
<p className="study-module-lesson">{enrolled ? 'Enrolled' : 'Study track'}</p>
|
||||
<h3>{study.title}</h3>
|
||||
<p>{study.description || 'Join the discussion for this study track.'}</p>
|
||||
</div>
|
||||
<div className="study-module-row-right" style={{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end' }}>
|
||||
<Link to={`/study/${study.slug}/community`} className="btn-primary">
|
||||
{enrolled ? 'Open Discussion' : 'View Discussion'}
|
||||
</Link>
|
||||
</div>
|
||||
</article>
|
||||
<Link key={study.slug} to={`/study/${study.slug}/community`} className="sdh-card">
|
||||
<span className={`sdh-badge${enrolled ? ' sdh-badge--on' : ''}`}>{enrolled ? 'Enrolled' : 'Open to all students'}</span>
|
||||
<h3>{study.title}</h3>
|
||||
<p>{study.description || 'Join the discussion for this study track.'}</p>
|
||||
<span className="sdh-go">{enrolled ? 'Open discussion →' : 'View discussion →'}</span>
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
@@ -4389,20 +4535,24 @@ export function StudyCommunityPage({ content }: Props) {
|
||||
|
||||
if (!auth.checked) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Loading">
|
||||
<div className="thanks-card"><p>Loading...</p></div>
|
||||
<main className="auth-page" aria-label="Loading">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center"><p>Loading...</p></div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
if (!auth.authenticated) {
|
||||
return (
|
||||
<main className="thanks-page" aria-label="Sign in required">
|
||||
<div className="thanks-card">
|
||||
<main className="auth-page" aria-label="Sign in required">
|
||||
<div className="auth-shell auth-shell--single">
|
||||
<div className="auth-card auth-card--center">
|
||||
<p className="eyebrow">Study Discussion</p>
|
||||
<h1>Sign In Required</h1>
|
||||
<p>Create a free student account to see and join the conversation.</p>
|
||||
<Link to="/study/signup" className="btn-primary" style={{ marginTop: '1rem', display: 'inline-block' }}>Sign In</Link>
|
||||
<div className="study-signup-actions"><Link to="/study/signup" className="btn-primary">Sign In</Link></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { isKnownSitePath } from '../server/study-helpers.js'
|
||||
|
||||
test('real site pages are known paths', () => {
|
||||
for (const p of ['/', '/study', '/study/titus/titus-abc', '/episodes/123', '/salvation', '/scripture', '/privacy']) {
|
||||
assert.equal(isKnownSitePath(p), true, p)
|
||||
}
|
||||
})
|
||||
|
||||
test('scanner and probe paths are not known paths', () => {
|
||||
for (const p of ['/.env', '/.git/config', '/wp-login', '/actuator/health', '/cgi-bin/x', '/random-path-123']) {
|
||||
assert.equal(isKnownSitePath(p), false, p)
|
||||
}
|
||||
})
|
||||
|
||||
import { checkPassageReference } from '../shared/bible-books.js'
|
||||
|
||||
test('passage reference check accepts what the index can read and flags what it cannot', () => {
|
||||
assert.equal(checkPassageReference('Titus 1:1-2', ''), null)
|
||||
assert.equal(checkPassageReference('1:10–13a', 'titus'), null)
|
||||
assert.match(checkPassageReference('1:1-2', ''), /Bible Book/)
|
||||
assert.match(checkPassageReference('Foo 1:1', 'titus'), /not a recognized/)
|
||||
assert.match(checkPassageReference('chapter one', 'titus'), /Use the form/)
|
||||
})
|
||||
@@ -0,0 +1,32 @@
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { parseNoteEntries, serializeNoteEntries, noteEntriesToText } from '../shared/note-format.js'
|
||||
|
||||
test('legacy anchor map upgrades to entries and round-trips as v2', () => {
|
||||
const entries = parseNoteEntries(JSON.stringify({ scripture: '<p>a</p>', general: '', commentary: '<p>b</p>' }))
|
||||
assert.deepEqual(entries.map(e => e.anchor), ['scripture', 'commentary'])
|
||||
const again = parseNoteEntries(serializeNoteEntries(entries))
|
||||
assert.equal(again.length, 2)
|
||||
assert.equal(JSON.parse(serializeNoteEntries(entries)).v, 2)
|
||||
})
|
||||
|
||||
test('plain-text legacy notes become a general entry', () => {
|
||||
const entries = parseNoteEntries('just some text')
|
||||
assert.equal(entries.length, 1)
|
||||
assert.equal(entries[0].anchor, 'general')
|
||||
})
|
||||
|
||||
test('multiple entries per anchor are kept and empty ones dropped', () => {
|
||||
const raw = serializeNoteEntries([
|
||||
{ id: '1', anchor: 'general', html: '<p>one</p>', updatedAt: '2026-01-01T00:00:00.000Z' },
|
||||
{ id: '2', anchor: 'general', html: '<p>two</p>', updatedAt: null },
|
||||
{ id: '3', anchor: 'general', html: ' ', updatedAt: null },
|
||||
])
|
||||
assert.equal(parseNoteEntries(raw).length, 2)
|
||||
assert.equal(serializeNoteEntries([]), '')
|
||||
})
|
||||
|
||||
test('plain-text export strips markup', () => {
|
||||
const text = noteEntriesToText(serializeNoteEntries([{ id: '1', anchor: 'scripture', html: '<p>Hi & bye</p>', updatedAt: null }]))
|
||||
assert.equal(text, 'Scripture Text\nHi & bye')
|
||||
})
|
||||
+2
-7
@@ -25,10 +25,10 @@ export default defineConfig({
|
||||
navigateFallback: '/index.html',
|
||||
// Allowlist-only approach: SW only serves index.html for known SPA routes.
|
||||
// Everything else (admin-configured redirects, /spotify, /apple, /amazon,
|
||||
// feed.xml, robots.txt, etc.) goes to the server so server-side redirects work.
|
||||
// feed.xml, robots.txt, the static /salvation page, etc.) goes to the server so server-side redirects work.
|
||||
navigateFallbackAllowlist: [
|
||||
/^\/$/, // exact root
|
||||
/^\/(start-here|about|contact|resources|thanks|preview|privacy|terms|salvation)(\/.*)?$/,
|
||||
/^\/(start-here|about|contact|resources|thanks|preview|privacy|terms)(\/.*)?$/,
|
||||
/^\/(study|studys|episodes|finished|downloads|subscribe|certificate)(\/.*)?$/,
|
||||
/^\/(questions|admin|email|contacts|calendar)(\/.*)?$/,
|
||||
],
|
||||
@@ -47,11 +47,6 @@ export default defineConfig({
|
||||
},
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'react-simple-maps': 'react-simple-maps/dist/index.es.js',
|
||||
},
|
||||
},
|
||||
server: {
|
||||
proxy: {
|
||||
'/api': 'http://localhost:4173',
|
||||
|
||||
Reference in new issue
Block a user