131 lines
5.6 KiB
Plaintext
131 lines
5.6 KiB
Plaintext
<!-- views/inicio.ejs -->
|
|
<!doctype html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta http-equiv="x-ua-compatible" content="IE=edge" />
|
|
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
|
<title>Inicio • SuiteCoffee</title>
|
|
<style>
|
|
:root { --bg:#0b0b0c; --card:#141519; --text:#e7e9ee; --muted:#a5acb8; --accent:#6ee7b7; --border:#232733; }
|
|
* { box-sizing: border-box; }
|
|
body { margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji","Segoe UI Emoji"; background: var(--bg); color: var(--text); }
|
|
.wrap { max-width: 960px; margin: 48px auto; padding: 0 20px; }
|
|
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
|
|
h1 { font-size: 26px; margin: 0 0 8px; }
|
|
p.lead { color: var(--muted); margin: 0 0 20px; }
|
|
h2 { margin: 24px 0 10px; font-size: 18px; color: var(--accent); }
|
|
table { width: 100%; border-collapse: collapse; overflow: hidden; border-radius: 12px; border: 1px solid var(--border); }
|
|
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
|
|
th { color: var(--muted); font-weight: 600; letter-spacing: .02em; }
|
|
tbody tr:last-child td { border-bottom: 0; }
|
|
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }
|
|
.grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
|
|
@media (min-width: 900px) { .grid { grid-template-columns: 1fr 1fr; } }
|
|
.muted { color: var(--muted); }
|
|
.pill { display:inline-block; padding:2px 8px; border:1px solid var(--border); border-radius:999px; color:var(--muted); font-size:12px; }
|
|
.k { color:#93c5fd; }
|
|
.v { color:#fca5a5; word-break: break-all; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="wrap">
|
|
<div class="card">
|
|
<%
|
|
const hasUser = typeof user !== 'undefined' && user;
|
|
const hasCookies = typeof cookies !== 'undefined' && cookies && Object.keys(cookies).length;
|
|
const displayName =
|
|
(hasUser && (user.name || user.displayName || user.email)) ||
|
|
(hasCookies && (cookies.user_name || cookies.displayName || cookies.email)) ||
|
|
'usuario';
|
|
%>
|
|
<h1>Hola, <span><%= displayName %></span> 👋</h1>
|
|
<p class="lead">Bienvenido a SuiteCoffee. Este es tu inicio.</p>
|
|
|
|
<% if (hasUser) { %>
|
|
<h2>Sesión</h2>
|
|
<table>
|
|
<tbody>
|
|
<% for (const [k,v] of Object.entries(user)) { %>
|
|
<tr>
|
|
<th><code class="k"><%= k %></code></th>
|
|
<td><code class="v"><%= typeof v === 'object' ? JSON.stringify(v) : String(v) %></code></td>
|
|
</tr>
|
|
<% } %>
|
|
</tbody>
|
|
</table>
|
|
<% } %>
|
|
|
|
<div class="grid" style="margin-top:18px;">
|
|
<section class="card">
|
|
<h2>Cookies (servidor)</h2>
|
|
<% if (hasCookies) { %>
|
|
<table>
|
|
<thead>
|
|
<tr><th>Nombre</th><th>Valor</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<% for (const [name, value] of Object.entries(cookies)) { %>
|
|
<tr>
|
|
<td><code class="k"><%= name %></code></td>
|
|
<td><code class="v"><%= typeof value === 'object' ? JSON.stringify(value) : String(value) %></code></td>
|
|
</tr>
|
|
<% } %>
|
|
</tbody>
|
|
</table>
|
|
<% } else { %>
|
|
<p class="muted">No se recibieron cookies desde el servidor (req.cookies). ¿Estás usando <code>cookie-parser</code> o pasando <code>cookies</code> al render?</p>
|
|
<% } %>
|
|
</section>
|
|
|
|
<section class="card">
|
|
<h2>Cookies (navegador)</h2>
|
|
<table id="client-cookies">
|
|
<thead>
|
|
<tr><th>Nombre</th><th>Valor</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr><td colspan="2" class="muted">Cargando…</td></tr>
|
|
</tbody>
|
|
</table>
|
|
<p class="muted" style="margin-top:10px;">Raw <code>document.cookie</code>:</p>
|
|
<pre id="cookie-raw" class="muted" style="white-space: pre-wrap; word-break: break-all;"></pre>
|
|
</section>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
(function () {
|
|
try {
|
|
const tbody = document.querySelector('#client-cookies tbody');
|
|
const raw = document.cookie || '';
|
|
document.getElementById('cookie-raw').textContent = raw || '(sin cookies)';
|
|
const pairs = raw ? raw.split(/;\s*/) : [];
|
|
if (!pairs.length) {
|
|
tbody.innerHTML = '<tr><td colspan="2"><em class="muted">sin cookies</em></td></tr>';
|
|
return;
|
|
}
|
|
tbody.innerHTML = '';
|
|
for (const kv of pairs) {
|
|
const i = kv.indexOf('=');
|
|
const name = i >= 0 ? kv.slice(0, i) : kv;
|
|
const value = i >= 0 ? kv.slice(i + 1) : '';
|
|
const tr = document.createElement('tr');
|
|
const td1 = document.createElement('td');
|
|
const td2 = document.createElement('td');
|
|
td1.innerHTML = '<code class="k"></code>';
|
|
td2.innerHTML = '<code class="v"></code>';
|
|
td1.querySelector('code').textContent = decodeURIComponent(name);
|
|
td2.querySelector('code').textContent = decodeURIComponent(value);
|
|
tr.append(td1, td2);
|
|
tbody.appendChild(tr);
|
|
}
|
|
} catch (err) {
|
|
console.error('cookie render error:', err);
|
|
}
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|