199 lines
11 KiB
JavaScript
199 lines
11 KiB
JavaScript
const fs = require('fs')
|
||
const path = require('path')
|
||
|
||
const musicLandLogoBase64 = fs.readFileSync(path.join(__dirname, '../assets/musicLandLogo.png'), {
|
||
encoding: 'base64',
|
||
})
|
||
const musicLandLogoSrc = `data:image/png;base64,${musicLandLogoBase64}`
|
||
|
||
function basicTemplate({ title = '', content = '', button = null }) {
|
||
const btn = button?.url
|
||
? `<p><a href="${button.url}" style="display:inline-block;padding:10px 16px;background:#6C5CE7;color:#fff;border-radius:8px;text-decoration:none">${
|
||
button?.label || 'Ouvrir'
|
||
}</a></p>`
|
||
: ''
|
||
return `<!doctype html><html lang="fr" style="background-color:#0b0b10"><head>
|
||
<meta charset="utf-8" />
|
||
<meta name="color-scheme" content="dark" />
|
||
<meta name="supported-color-schemes" content="dark" />
|
||
<style>
|
||
:root { color-scheme: dark; supported-color-schemes: dark; }
|
||
body { margin:0 !important; background-color:#0b0b10 !important; }
|
||
body, .email-surface { background-color:#0b0b10 !important; color:#ffffff !important; }
|
||
u + .body .email-surface { background-color:#0b0b10 !important; color:#ffffff !important; }
|
||
u + .body .email-content,
|
||
[data-ogsc] .email-content,
|
||
[data-ogsb] .email-content { background-color:#151520 !important; color:#ffffff !important; }
|
||
u + .body .email-content *,
|
||
[data-ogsc] .email-content *,
|
||
[data-ogsb] .email-content * { color:#ffffff !important; }
|
||
</style>
|
||
</head><body class="body" data-ogsc="dark" data-ogsb="dark" bgcolor="#0b0b10" style="margin:0;padding:0;background-color:#0b0b10!important;color:#ffffff!important;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;line-height:1.5">
|
||
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="email-surface" style="border-collapse:collapse;background-color:#0b0b10">
|
||
<tr>
|
||
<td align="center" style="padding:40px 16px">
|
||
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#151520" class="email-content" style="max-width:640px;border-radius:12px;background-color:#151520;border:1px solid rgba(255,255,255,0.08);box-shadow:0 12px 40px rgba(0,0,0,0.35);overflow:hidden">
|
||
<tr>
|
||
<td bgcolor="#151520" style="padding:24px;background-color:#151520;color:#ffffff">
|
||
<div style="text-align:center;margin-bottom:20px;color:#ffffff">
|
||
<img src="${musicLandLogoSrc}" alt="MusicLand" style="height:40px" />
|
||
</div>
|
||
<h2 style="margin:0 0 16px;font-size:24px;color:#ffffff!important">${title}</h2>
|
||
<div style="color:rgba(255,255,255,0.9)!important">${content}</div>
|
||
${btn}
|
||
<hr style="margin:24px 0;border:none;border-top:1px solid rgba(255,255,255,0.1)" />
|
||
<p style="color:rgba(255,255,255,0.45);font-size:12px;margin:0">musicland</p>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</body></html>`
|
||
}
|
||
|
||
function cleanEmailName(firstName) {
|
||
return typeof firstName === 'string' ? firstName.replace(/[\r\n]+/g, ' ').trim() : ''
|
||
}
|
||
|
||
function escapeHtml(value) {
|
||
return value
|
||
.replace(/&/g, '&')
|
||
.replace(/</g, '<')
|
||
.replace(/>/g, '>')
|
||
.replace(/"/g, '"')
|
||
.replace(/'/g, ''')
|
||
}
|
||
|
||
function getWelcomeLanguage(preferredLanguage) {
|
||
return preferredLanguage === 'en' ? 'en' : 'fr'
|
||
}
|
||
|
||
function welcomeEmailSubject({ firstName = '', preferredLanguage = 'fr' } = {}) {
|
||
const language = getWelcomeLanguage(preferredLanguage)
|
||
const cleanFirstName = cleanEmailName(firstName)
|
||
const subject = language === 'en' ? 'Welcome to Musicland' : 'Bienvenue à MusicLand'
|
||
return cleanFirstName ? `${subject}, ${cleanFirstName}` : subject
|
||
}
|
||
|
||
function welcomeTemplate({ firstName = '', preferredLanguage = 'fr' } = {}) {
|
||
const language = getWelcomeLanguage(preferredLanguage)
|
||
const cleanFirstName = cleanEmailName(firstName)
|
||
const safeFirstName = escapeHtml(cleanFirstName)
|
||
const greeting =
|
||
language === 'en'
|
||
? safeFirstName
|
||
? `Hi ${safeFirstName},`
|
||
: 'Hi,'
|
||
: safeFirstName
|
||
? `Salut ${safeFirstName},`
|
||
: 'Salut,'
|
||
const content =
|
||
language === 'en'
|
||
? `
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
That’s it, you’ve got your pass to MusicLand. Welcome to the land of song!
|
||
</p>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
You’re about to embark on an extraordinary adventure!
|
||
</p>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
You’ll write your own lyrics, add a melody, shoot your music video… and upload your song to the MusicLand streaming platform.
|
||
</p>
|
||
<p style="margin:0 0 10px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
Three areas await you:
|
||
</p>
|
||
<ul style="margin:0 0 16px;padding-left:22px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
<li style="margin-bottom:8px">The Songwriting Area: Céline will help you write original lyrics.</li>
|
||
<li style="margin-bottom:8px">The Studio: Malik will turn it into beautiful music.</li>
|
||
<li>The Video Studio: With Théo, you’ll direct your first music video.</li>
|
||
</ul>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
And don’t worry, you don’t need to know how to sing, you don’t need any musical or technical skills, and you’ll be blown away by the result.
|
||
</p>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
See you soon in the halls of MusicLand,
|
||
</p>
|
||
<p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
And… Feel the good vibe!
|
||
</p>
|
||
<p style="margin:0;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
<strong>The MusicLand Team</strong>
|
||
</p>`
|
||
: `
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
Ça y est : tu as ton pass pour MusicLand. Bienvenue au pays de la chanson !
|
||
</p>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
Tu vas vivre une aventure extraordinaire!
|
||
</p>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
Tu vas écrire tes paroles, habiller ta mélodie, tourner ton clip… et déposer <strong>ta</strong> chanson sur la plateforme de streaming de MusicLand.
|
||
</p>
|
||
<p style="margin:0 0 10px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
Trois espaces t'attendent:
|
||
</p>
|
||
<ul style="margin:0 0 16px;padding-left:22px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
<li style="margin-bottom:8px">L'espace Écriture: Céline va t’aider à composer un texte original.</li>
|
||
<li style="margin-bottom:8px">Le studio: Malik va le sublimer en musique.</li>
|
||
<li>Le studio vidéo: avec Théo tu réaliseras ton premier clip vidéo.</li>
|
||
</ul>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
Et rassure toi, tu n’as pas besoin de savoir chanter, tu n'as besoin d’aucune compétence musicale ou technique et tu vas être bluffé par le résultat.
|
||
</p>
|
||
<p style="margin:0 0 16px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
À très vite dans les allées de MusicLand,
|
||
</p>
|
||
<p style="margin:0 0 24px;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
And… Feel the good vibe!
|
||
</p>
|
||
<p style="margin:0;font-size:16px;line-height:1.6;color:#ffffff!important">
|
||
<strong>L'équipe MusicLand</strong>
|
||
</p>`
|
||
|
||
return `<!doctype html><html lang="${language}" style="background-color:#0b0b10"><head>
|
||
<meta charset="utf-8" />
|
||
<meta name="color-scheme" content="dark" />
|
||
<meta name="supported-color-schemes" content="dark" />
|
||
<style>
|
||
:root { color-scheme: dark; supported-color-schemes: dark; }
|
||
body { margin:0 !important; background-color:#0b0b10 !important; }
|
||
body, .email-surface { background-color:#0b0b10 !important; color:#ffffff !important; }
|
||
u + .body .email-surface { background-color:#0b0b10 !important; color:#ffffff !important; }
|
||
u + .body .email-content,
|
||
[data-ogsc] .email-content,
|
||
[data-ogsb] .email-content { background-color:#151520 !important; color:#ffffff !important; }
|
||
u + .body .email-content *,
|
||
[data-ogsc] .email-content *,
|
||
[data-ogsb] .email-content * { color:#ffffff !important; }
|
||
</style>
|
||
</head><body class="body" data-ogsc="dark" data-ogsb="dark" bgcolor="#0b0b10" style="margin:0;padding:0;background-color:#0b0b10!important;color:#ffffff!important;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;line-height:1.5">
|
||
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" class="email-surface" style="border-collapse:collapse;background-color:#0b0b10">
|
||
<tr>
|
||
<td align="center" style="padding:40px 16px">
|
||
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" bgcolor="#151520" class="email-content" style="max-width:640px;border-radius:16px;overflow:hidden;background-color:#151520;border:1px solid rgba(255,255,255,0.08);box-shadow:0 12px 40px rgba(0,0,0,0.35)">
|
||
<tr>
|
||
<td bgcolor="#151520" style="padding:32px 28px;background-color:#151520;color:#ffffff">
|
||
<div style="text-align:center;margin-bottom:24px;color:#ffffff">
|
||
<img
|
||
src="${musicLandLogoSrc}"
|
||
alt="MusicLand"
|
||
style="display:block;margin:0 auto;width:180px;max-width:100%;height:auto"
|
||
/>
|
||
</div>
|
||
<p style="margin:0 0 12px;font-size:16px;letter-spacing:0.2px;color:#ffffff!important">${greeting}</p>
|
||
${content}
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
<p style="margin:32px 0 0;text-align:center;font-size:12px;color:rgba(255,255,255,0.6)">minuit.app · Paris, France</p>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</body></html>`
|
||
}
|
||
|
||
exports.basicTemplate = basicTemplate
|
||
exports.welcomeEmailSubject = welcomeEmailSubject
|
||
exports.welcomeTemplate = welcomeTemplate
|