feat: unified landing page with auth-aware gate + /dashboard.php
Removes the logged-in vs logged-out page bifurcation. index.php now always renders the public landing (tools overview, hero, trust section) with auth-conditional nav/hero CTAs and a two-column member/register gate shown only to unauthenticated visitors. Authenticated workbench extracted to new dashboard.php. Adds 8 new i18n keys across all 4 languages and new CSS for auth-nav, hero CTA, two-column gate, and register buttons. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -35,7 +35,8 @@ if (isset($_GET['sso']) && !dbnToolsIsAuthenticated()) {
|
||||
$_SESSION['dbn_tools_user_email'] = (string)$tokenData['email'];
|
||||
$_SESSION['dbn_tools_user_role'] = 'sso';
|
||||
$_SESSION['dbn_tools_tier'] = (string)($tokenData['tier'] ?? 'free');
|
||||
header('Location: ' . $returnPath);
|
||||
// Send to workbench directly after SSO; honour a specific return path if set
|
||||
header('Location: ' . ($returnPath === '/' ? '/dashboard.php' : $returnPath));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -43,9 +44,12 @@ if (isset($_GET['sso']) && !dbnToolsIsAuthenticated()) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$tools = dbnToolsLaunchedTools($uiLang);
|
||||
$langPath = '/';
|
||||
$toolsLogin = 'https://dobetternorge.no/tools-login.php?return=' . urlencode($returnPath);
|
||||
$isAuthed = dbnToolsIsAuthenticated();
|
||||
$userEmail = $isAuthed ? (string)($_SESSION['dbn_tools_user_email'] ?? '') : '';
|
||||
$tools = dbnToolsLaunchedTools($uiLang);
|
||||
$langPath = '/';
|
||||
$toolsLogin = 'https://dobetternorge.no/tools-login.php?return=' . urlencode($returnPath);
|
||||
$registerUrl = 'https://dobetternorge.no/register.php';
|
||||
|
||||
require_once __DIR__ . '/includes/tool-svgs.php';
|
||||
?>
|
||||
@@ -68,65 +72,12 @@ require_once __DIR__ . '/includes/tool-svgs.php';
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;600;700&family=Roboto:wght@300;400;500;700&family=IBM+Plex+Mono:wght@400;700&display=swap">
|
||||
<link rel="stylesheet" href="assets/css/tools.css">
|
||||
</head>
|
||||
<body data-authenticated="<?= dbnToolsIsAuthenticated() ? 'true' : 'false' ?>" class="<?= dbnToolsIsAuthenticated() ? 'lt-app' : 'lt-landing' ?>">
|
||||
<body data-authenticated="<?= $isAuthed ? 'true' : 'false' ?>" class="lt-landing">
|
||||
<script>
|
||||
window.DBN_TOOLS_AUTHENTICATED = <?= dbnToolsIsAuthenticated() ? 'true' : 'false' ?>;
|
||||
window.DBN_TOOLS_AUTHENTICATED = <?= $isAuthed ? 'true' : 'false' ?>;
|
||||
window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
||||
</script>
|
||||
|
||||
<?php if (dbnToolsIsAuthenticated()): ?>
|
||||
<main id="appShell" class="app-shell dashboard-shell">
|
||||
<header class="topbar">
|
||||
<div>
|
||||
<p class="eyebrow"><?= htmlspecialchars(dbnToolsT('brand_line', $uiLang)) ?></p>
|
||||
<h1><?= htmlspecialchars(dbnToolsT('dashboard_title', $uiLang)) ?></h1>
|
||||
<div class="case-no">
|
||||
<span class="pulse"></span>
|
||||
<span>family-legal</span>
|
||||
<span class="case-sep">.</span>
|
||||
<span><?= htmlspecialchars(dbnToolsT('retention', $uiLang)) ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<nav class="shell-lang-switcher" aria-label="Language">
|
||||
<?php foreach (dbnToolsSupportedLanguages() as $langCode): ?>
|
||||
<a href="<?= htmlspecialchars($langPath . '?lang=' . $langCode) ?>" class="<?= $langCode === $uiLang ? 'is-active' : '' ?>"><?= htmlspecialchars(dbnToolsLanguageLabel($langCode)) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
<span id="healthPill" class="status-pill"><?= htmlspecialchars(dbnToolsT('session_active', $uiLang)) ?></span>
|
||||
<button id="healthButton" class="secondary-button" type="button"><?= htmlspecialchars(dbnToolsT('health', $uiLang)) ?></button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="manifesto dashboard-manifesto">
|
||||
<div class="manifesto-copy">
|
||||
<p class="manifesto-eyebrow"><?= htmlspecialchars(dbnToolsT('dashboard_eyebrow', $uiLang)) ?></p>
|
||||
<h2 class="manifesto-title"><?= htmlspecialchars(dbnToolsT('manifesto_title', $uiLang)) ?></h2>
|
||||
<p class="manifesto-sub"><?= htmlspecialchars(dbnToolsT('dashboard_sub', $uiLang)) ?></p>
|
||||
</div>
|
||||
<div class="manifesto-stats" aria-label="Headline statistics">
|
||||
<div class="manifesto-stat"><strong>23</strong><span><?= htmlspecialchars(dbnToolsT('stat_echr', $uiLang)) ?></span></div>
|
||||
<div class="manifesto-stat"><strong>64%</strong><span><?= htmlspecialchars(dbnToolsT('stat_loss', $uiLang)) ?></span></div>
|
||||
<div class="manifesto-stat"><strong>1,731</strong><span><?= htmlspecialchars(dbnToolsT('stat_tribunal', $uiLang)) ?></span></div>
|
||||
<div class="manifesto-stat"><strong>20+</strong><span><?= htmlspecialchars(dbnToolsT('stat_pending', $uiLang)) ?></span></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="disclaimer" role="note"><?= htmlspecialchars(dbnToolsT('disclaimer', $uiLang)) ?></div>
|
||||
|
||||
<section class="tool-dashboard-grid" aria-label="Available tools">
|
||||
<?php foreach ($tools as $slug => $item): ?>
|
||||
<a class="dashboard-tool-card" href="<?= htmlspecialchars($item['url']) ?>">
|
||||
<span class="dashboard-tool-card__icon"><?= htmlspecialchars($item['icon']) ?></span>
|
||||
<span class="dashboard-tool-card__badge"><?= htmlspecialchars($item['badge']) ?></span>
|
||||
<h2><?= htmlspecialchars($item['label']) ?></h2>
|
||||
<p><?= htmlspecialchars($item['description']) ?></p>
|
||||
<strong><?= htmlspecialchars(dbnToolsT('open_tool', $uiLang)) ?></strong>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</section>
|
||||
</main>
|
||||
<?php else: ?>
|
||||
<main id="publicLanding" class="dbn-public-tools">
|
||||
|
||||
<header class="lt-nav">
|
||||
@@ -143,7 +94,14 @@ window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
||||
<a href="<?= htmlspecialchars($langPath . '?lang=' . $langCode . '&return=' . urlencode($returnPath)) ?>" class="<?= $langCode === $uiLang ? 'is-active' : '' ?>"><?= htmlspecialchars(dbnToolsLanguageLabel($langCode)) ?></a>
|
||||
<?php endforeach; ?>
|
||||
</nav>
|
||||
<?php if ($isAuthed): ?>
|
||||
<div class="lt-auth-nav">
|
||||
<span class="lt-auth-nav__email"><?= htmlspecialchars($userEmail) ?></span>
|
||||
<a href="/dashboard.php" class="lt-nav__cta lt-nav__cta--enter"><?= htmlspecialchars(dbnToolsT('enter_workbench', $uiLang)) ?> →</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<a href="#access" class="lt-nav__cta"><?= htmlspecialchars(dbnToolsT('primary_access', $uiLang)) ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -170,7 +128,15 @@ window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
||||
<span>Legal passages indexed</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($isAuthed): ?>
|
||||
<div class="lt-hero__auth-cta">
|
||||
<span class="lt-hero__auth-check" aria-hidden="true">✓</span>
|
||||
<span class="lt-hero__auth-label"><?= htmlspecialchars(dbnToolsT('signed_in_as', $uiLang)) ?> <?= htmlspecialchars($userEmail) ?></span>
|
||||
<a href="/dashboard.php" class="lt-hero__enter-btn"><?= htmlspecialchars(dbnToolsT('enter_workbench', $uiLang)) ?> →</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<a href="#tools" class="lt-hero__cta-link">Explore tools ↓</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -195,6 +161,11 @@ window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php if ($isAuthed): ?>
|
||||
<div class="lt-tools__enter-strip">
|
||||
<a href="/dashboard.php" class="lt-access-btn"><?= htmlspecialchars(dbnToolsT('enter_workbench', $uiLang)) ?> →</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
|
||||
<section class="lt-trust">
|
||||
@@ -214,31 +185,53 @@ window.DBN_TOOLS_LANG = <?= json_encode($uiLang, JSON_UNESCAPED_UNICODE) ?>;
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="access" class="lt-access" aria-labelledby="ltAccessTitle">
|
||||
<div class="lt-access__inner">
|
||||
<p class="lt-access__eyebrow">Do Better Norge</p>
|
||||
<h2 class="lt-access__title" id="ltAccessTitle"><?= htmlspecialchars(dbnToolsT('primary_access', $uiLang)) ?></h2>
|
||||
<p class="lt-access__note"><?= htmlspecialchars(dbnToolsT('member_note', $uiLang)) ?></p>
|
||||
<a class="lt-access-btn" href="<?= htmlspecialchars($toolsLogin) ?>"><?= htmlspecialchars(dbnToolsT('primary_access', $uiLang)) ?></a>
|
||||
<p class="gate-copy"><a href="https://dobetternorge.no/register.php"><?= htmlspecialchars(dbnToolsT('register', $uiLang)) ?></a></p>
|
||||
<details class="fallback-login">
|
||||
<summary><?= htmlspecialchars(dbnToolsT('secondary_access', $uiLang)) ?></summary>
|
||||
<form id="passcodeForm" class="passcode-form">
|
||||
<label for="loginEmail"><?= htmlspecialchars(dbnToolsT('email', $uiLang)) ?></label>
|
||||
<input id="loginEmail" name="email" type="email" autocomplete="username email" required>
|
||||
<label for="loginPassword"><?= htmlspecialchars(dbnToolsT('password', $uiLang)) ?></label>
|
||||
<div class="passcode-row">
|
||||
<input id="loginPassword" name="password" type="password" autocomplete="current-password" required>
|
||||
<button type="submit"><?= htmlspecialchars(dbnToolsT('sign_in', $uiLang)) ?></button>
|
||||
</div>
|
||||
<p id="gateStatus" class="form-status" role="status" aria-live="polite"></p>
|
||||
</form>
|
||||
</details>
|
||||
<?php if (!$isAuthed): ?>
|
||||
<section id="access" class="lt-access lt-gate" aria-labelledby="ltGateTitle">
|
||||
<div class="lt-gate__grid">
|
||||
|
||||
<div class="lt-gate__card lt-gate__card--member">
|
||||
<p class="lt-gate__card-eyebrow">Do Better Norge</p>
|
||||
<h2 class="lt-gate__card-title" id="ltGateTitle"><?= htmlspecialchars(dbnToolsT('member_card_title', $uiLang)) ?></h2>
|
||||
<p class="lt-gate__card-note"><?= htmlspecialchars(dbnToolsT('member_card_note', $uiLang)) ?></p>
|
||||
<a class="lt-access-btn" href="<?= htmlspecialchars($toolsLogin) ?>"><?= htmlspecialchars(dbnToolsT('primary_access', $uiLang)) ?></a>
|
||||
<details class="fallback-login">
|
||||
<summary><?= htmlspecialchars(dbnToolsT('secondary_access', $uiLang)) ?></summary>
|
||||
<form id="passcodeForm" class="passcode-form">
|
||||
<label for="loginEmail"><?= htmlspecialchars(dbnToolsT('email', $uiLang)) ?></label>
|
||||
<input id="loginEmail" name="email" type="email" autocomplete="username email" required>
|
||||
<label for="loginPassword"><?= htmlspecialchars(dbnToolsT('password', $uiLang)) ?></label>
|
||||
<div class="passcode-row">
|
||||
<input id="loginPassword" name="password" type="password" autocomplete="current-password" required>
|
||||
<button type="submit"><?= htmlspecialchars(dbnToolsT('sign_in', $uiLang)) ?></button>
|
||||
</div>
|
||||
<p id="gateStatus" class="form-status" role="status" aria-live="polite"></p>
|
||||
</form>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<div class="lt-gate__card lt-gate__card--register">
|
||||
<p class="lt-gate__card-eyebrow">Free membership</p>
|
||||
<h2 class="lt-gate__card-title"><?= htmlspecialchars(dbnToolsT('register_card_title', $uiLang)) ?></h2>
|
||||
<p class="lt-gate__card-note"><?= htmlspecialchars(dbnToolsT('register_card_note', $uiLang)) ?></p>
|
||||
<a class="lt-register-btn lt-register-btn--google" href="<?= htmlspecialchars($registerUrl . '?method=google') ?>">
|
||||
<svg width="18" height="18" viewBox="0 0 18 18" fill="none" aria-hidden="true" focusable="false">
|
||||
<path d="M17.64 9.205c0-.639-.057-1.252-.164-1.841H9v3.481h4.844a4.14 4.14 0 0 1-1.796 2.716v2.259h2.908c1.702-1.567 2.684-3.875 2.684-6.615Z" fill="#4285F4"/>
|
||||
<path d="M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.584-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18Z" fill="#34A853"/>
|
||||
<path d="M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.996 8.996 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332Z" fill="#FBBC05"/>
|
||||
<path d="M9 3.58c1.321 0 2.508.454 3.44 1.345l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 6.29C4.672 4.163 6.656 3.58 9 3.58Z" fill="#EA4335"/>
|
||||
</svg>
|
||||
<?= htmlspecialchars(dbnToolsT('register_google', $uiLang)) ?>
|
||||
</a>
|
||||
<a class="lt-register-btn lt-register-btn--email" href="<?= htmlspecialchars($registerUrl) ?>">
|
||||
<?= htmlspecialchars(dbnToolsT('register_email', $uiLang)) ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
</main>
|
||||
<?php endif; ?>
|
||||
<?php require_once __DIR__ . '/includes/footer.php'; ?>
|
||||
<script src="assets/js/tools.js" defer></script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user