diff --git a/client/package.json b/client/package.json index 296df39..6da981d 100644 --- a/client/package.json +++ b/client/package.json @@ -13,6 +13,7 @@ "generate:flyer:png": "node ../scripts/generate-beta-flyer.mjs --png", "generate:flyer:all": "node ../scripts/generate-beta-flyer.mjs --all", "generate:flyer:setup": "playwright install chromium", + "generate:sharepic": "node ../scripts/generate-sharepic.mjs", "translate:locales": "node ../scripts/translate-locales.mjs", "translate:flyer": "node ../scripts/translate-flyer.mjs", "validate:i18n": "node ../scripts/validate-i18n-keys.mjs" diff --git a/docs/marketing/kapteins-daagbok-sharepic.png b/docs/marketing/kapteins-daagbok-sharepic.png new file mode 100644 index 0000000..6ae02ce Binary files /dev/null and b/docs/marketing/kapteins-daagbok-sharepic.png differ diff --git a/docs/marketing/sharepic.html b/docs/marketing/sharepic.html new file mode 100644 index 0000000..5bb713a --- /dev/null +++ b/docs/marketing/sharepic.html @@ -0,0 +1,292 @@ + + + + + Kapteins Daagbok — Sharepic + + + + + + +
+
+
+
+ +
+

Kapteins Daagbok

+

Digitales Yacht-Logbuch

+
+
+

+ Führe dein Bordlogbuch modern & digital: Reisetage, GPS-Tracks, Crew- und Schiffsdaten — + Ende-zu-Ende-verschlüsselt, als App installierbar und auch offline auf See nutzbar. +

+
+ kapteins-daagbok.eu +
+
+
+
+
Top Features Kostenlos & Werbefrei
+
    +
  • + + Nautisches Logbuch-Format & Streckenstatistik +
  • +
  • + + Offline-first PWA — läuft auf allen Smartphones & Tablets +
  • +
  • + + Ende-zu-Ende Verschlüsselung (Zero-Knowledge) +
  • +
  • + + Einfache passwortlose Passkey-Anmeldung +
  • +
  • + + GPS-Track-Upload & automatische NMEA-Erfassung +
  • +
  • + + Crew-Einladung zur gemeinsamen Logbuch-Arbeit +
  • +
+
+
+
+ + + diff --git a/scripts/generate-sharepic.mjs b/scripts/generate-sharepic.mjs new file mode 100755 index 0000000..f8301e8 --- /dev/null +++ b/scripts/generate-sharepic.mjs @@ -0,0 +1,84 @@ +#!/usr/bin/env node +/** + * Generates the sharepic PNG from docs/marketing/sharepic.html + * + * Usage: + * node scripts/generate-sharepic.mjs + */ + +import { execSync } from 'node:child_process' +import { dirname, resolve } from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' +import { createRequire } from 'node:module' + +const __dirname = dirname(fileURLToPath(import.meta.url)) +const repoRoot = resolve(__dirname, '..') +const clientDir = resolve(repoRoot, 'client') +const marketingDir = resolve(repoRoot, 'docs/marketing') +const htmlPath = resolve(marketingDir, 'sharepic.html') +const pngPath = resolve(marketingDir, 'kapteins-daagbok-sharepic.png') + +const require = createRequire(resolve(clientDir, 'package.json')) + +function isMissingBrowserError(err) { + const msg = err instanceof Error ? err.message : String(err) + return msg.includes("Executable doesn't exist") || msg.includes('browserType.launch') +} + +async function ensurePlaywrightChromium(playwright) { + try { + const browser = await playwright.chromium.launch({ headless: true }) + await browser.close() + return + } catch (err) { + if (!isMissingBrowserError(err)) throw err + } + + console.log('Playwright Chromium fehlt — installiere Browser (einmalig)…') + execSync('npx playwright install chromium', { + cwd: clientDir, + stdio: 'inherit' + }) +} + +function loadPlaywright() { + try { + return require('playwright') + } catch { + console.error('Fehlende Abhängigkeit: "npm install -D playwright" in client/ ausführen.') + process.exit(1) + } +} + +async function main() { + const playwright = loadPlaywright() + await ensurePlaywrightChromium(playwright) + + console.log('Generating sharepic from HTML...') + const browser = await playwright.chromium.launch({ headless: true }) + + try { + const context = await browser.newContext({ + viewport: { width: 1200, height: 630 }, + deviceScaleFactor: 2 // High-DPI for crisp text + }) + const page = await context.newPage() + + // Wait for fonts/images to load fully + await page.goto(pathToFileURL(htmlPath).href, { waitUntil: 'networkidle' }) + + // Take a screenshot of the viewport + await page.screenshot({ + path: pngPath, + type: 'png' + }) + console.log('Sharepic PNG written successfully to:', pngPath) + } finally { + await browser.close() + } +} + +main().catch((err) => { + console.error('Error generating sharepic:', err) + process.exit(1) +})