Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
claude/adoring-hopper-5x74bqclaude/affectionate-feynman-ykrf1hclaude/architecture-audit-design-wxprenclaude/build-status-update-3MXsfclaude/charming-meitner-mllb5rclaude/compare-gate-gluecron-s4mFQclaude/confident-faraday-tikcwbclaude/continue-work-XMTlIclaude/crontech-gluecron-deploy-7MIECclaude/crontech-platform-setup-SeKfwclaude/design-2026claude/ecstatic-ptolemy-jMdigclaude/enhance-github-integration-QNHdGclaude/fix-aa-loop-issue-PonMQclaude/fix-actions-and-processclaude/fix-desktop-errors-XqoW8claude/fix-red-workflowsclaude/fix-website-access-6FKJNclaude/gatetest-integration-hardeningclaude/github-audit-improvements-bDFr9claude/gluecron-launch-status-FoMRlclaude/hopeful-lamport-olfCTclaude/issue-to-pr-and-protectionsclaude/jolly-heisenberg-2sg1Qclaude/launch-preparation-QmTb6claude/new-session-xk1l7claude/plan-platform-architecture-kkN4yclaude/platform-analysis-roadmap-1nUGLclaude/platform-launch-assessment-8dWV8claude/polish-platform-release-AeDrUclaude/resume-previous-work-KzyLwclaude/review-crontech-handoff-qYEVqclaude/review-project-completeness-lHhS2claude/review-readme-docs-ulqPKclaude/serene-edison-rj87weclaude/setup-multi-repo-dev-BCwNQclaude/ship-fixes-and-tests-Jvz1cclaude/site-audit-competitive-pctlwgclaude/site-migration-vercel-XstpKclaude/standalone-product-repos-XHFTDcopilot/feat-smart-empty-states-keyboard-first-enhancementcopilot/feat-smart-morning-digest-review-context-restorecopilot/fix-and-process-workflowscopilot/update-ai-powered-code-reviewfeat/debt-mapfeat/push-policy-codeowners-hardeningfeat/smart-digest-contextfeat/stage-impactfeat/t1-secret-migrationfeat/u-polishfeat/w-self-hostfeat/w2-claude-configfix/agent-journey-orphan-sweepgatetest/auto-fix-1776586424172gatetest/auto-fix-1776586534814gatetest/auto-fix-1776590685143gatetest/auto-fix-1776590808199mainops/redeploy-retriggerstyle/dxt-cta-themeworktree-agent-a3377aad30d55da26worktree-agent-a7ef607b7ee1d6c74
legal.tsx11.1 KB · 363 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/**
 * Legal pages — Terms, Privacy, AUP served from markdown source.
 *
 * The body wraps the rendered markdown in a 2026-style hero card +
 * table of contents + scoped section card. The TOC is parsed from the
 * markdown's `<h2>`s with a tiny regex pass — no shared file touches.
 *
 * All CSS is scoped under `.legal-page-*` so it cannot bleed into the
 * sub-routes under `/legal/terms` etc. (which render their own JSX).
 */

import { Hono } from "hono";
import { readFileSync } from "fs";
import { join } from "path";
import { Layout } from "../views/layout";
import { renderMarkdown, markdownCss } from "../lib/markdown";
import { softAuth } from "../middleware/auth";
import type { AuthEnv } from "../middleware/auth";
import { html } from "hono/html";

const legal = new Hono<AuthEnv>();

legal.use("*", softAuth);

// ─── Scoped CSS ─────────────────────────────────────────────────────────────
const legalStyles = `
  .legal-page-wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: var(--space-6) var(--space-4);
  }

  /* ─── Hero ─── */
  .legal-page-hero {
    position: relative;
    margin-bottom: var(--space-5);
    padding: var(--space-5) var(--space-6);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
  }
  .legal-page-hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, #5b6ee8 30%, #5f8fa0 70%, transparent 100%);
    opacity: 0.78;
    pointer-events: none;
  }
  .legal-page-hero-orb {
    position: absolute;
    inset: -22% -10% auto auto;
    width: 380px; height: 380px;
    background: radial-gradient(circle, rgba(91,110,232,0.20), rgba(95,143,160,0.10) 45%, transparent 70%);
    filter: blur(80px);
    opacity: 0.7;
    pointer-events: none;
    z-index: 0;
  }
  .legal-page-hero-inner { position: relative; z-index: 1; max-width: 720px; }
  .legal-page-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 14px;
  }
  .legal-page-eyebrow-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 6px;
    background: rgba(91,110,232,0.14);
    color: #5b6ee8;
    box-shadow: inset 0 0 0 1px rgba(91,110,232,0.35);
  }
  .legal-page-title {
    font-size: clamp(28px, 4vw, 40px);
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: -0.028em;
    line-height: 1.05;
    margin: 0 0 var(--space-2);
    color: var(--text-strong);
  }
  .legal-page-title-grad {
    background-image: linear-gradient(135deg, #5b6ee8 0%, #5b6ee8 50%, #5f8fa0 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
  }
  .legal-page-sub {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.55;
  }

  /* ─── Table of contents ─── */
  .legal-page-toc {
    position: relative;
    margin-bottom: var(--space-5);
    padding: var(--space-4) var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
  }
  .legal-page-toc::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, #5b6ee8 0%, #5f8fa0 100%);
  }
  .legal-page-toc-label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--accent);
    margin-bottom: var(--space-3);
    font-weight: 600;
  }
  .legal-page-toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 2;
    column-gap: 28px;
  }
  @media (max-width: 720px) {
    .legal-page-toc-list { columns: 1; }
  }
  .legal-page-toc-list li {
    margin-bottom: 6px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    break-inside: avoid;
  }
  .legal-page-toc-list a {
    color: var(--text);
    text-decoration: none;
    transition: color 120ms ease;
    display: inline-block;
  }
  .legal-page-toc-list a:hover { color: var(--accent); text-decoration: underline; }
  .legal-page-toc-list .num {
    color: var(--text-faint);
    margin-right: 8px;
    font-variant-numeric: tabular-nums;
  }

  /* ─── Body card ─── */
  .legal-page-body {
    padding: var(--space-6) clamp(var(--space-4), 3vw, var(--space-6));
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 14px;
  }
  .legal-page-body .markdown-body { background: transparent; }
  .legal-page-body .markdown-body h1:first-child { display: none; }
  .legal-page-body .markdown-body h2 {
    scroll-margin-top: 72px;
  }

  .legal-page-foot {
    margin-top: var(--space-5);
    padding: var(--space-4);
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border: 1px dashed var(--border);
    border-radius: 12px;
  }
  .legal-page-foot a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
  }
  .legal-page-foot a:hover { text-decoration: underline; }
`;

/**
 * Build a deterministic slug for a heading. Matches the post-process pass
 * below so the TOC anchors hit their targets.
 */
function slugify(text: string): string {
  return text
    .toLowerCase()
    .replace(/<[^>]+>/g, "")
    .replace(/&[a-z]+;/g, "")
    .replace(/[^\w\s-]/g, "")
    .trim()
    .replace(/\s+/g, "-");
}

/**
 * Pull `## Heading` lines from the raw markdown and synth a TOC. Returns an
 * empty list if no h2s are found, in which case the renderer skips the TOC
 * card entirely.
 */
function extractToc(markdown: string): Array<{ id: string; text: string }> {
  const out: Array<{ id: string; text: string }> = [];
  const seen = new Map<string, number>();
  const re = /^##\s+(.+?)\s*$/gm;
  let m: RegExpExecArray | null;
  while ((m = re.exec(markdown)) !== null) {
    const text = m[1]!.trim();
    let id = slugify(text);
    const n = seen.get(id) ?? 0;
    seen.set(id, n + 1);
    if (n > 0) id = `${id}-${n}`;
    out.push({ id, text });
  }
  return out;
}

/**
 * Inject `id="..."` into rendered `<h2>` tags so the TOC anchors land.
 * marked doesn't add heading ids out of the box and we don't want to touch
 * the shared `lib/markdown.ts` for a single page.
 */
function addHeadingIds(htmlString: string): string {
  const seen = new Map<string, number>();
  return htmlString.replace(/<h2>([^<]+)<\/h2>/g, (_full, inner) => {
    let id = slugify(inner);
    const n = seen.get(id) ?? 0;
    seen.set(id, n + 1);
    if (n > 0) id = `${id}-${n}`;
    return `<h2 id="${id}">${inner}</h2>`;
  });
}

function getPageMeta(slug: string): { eyebrow: string; title: string; grad: string; sub: string } {
  switch (slug) {
    case "terms":
      return {
        eyebrow: "Legal · Terms of Service",
        title: "The rules we both",
        grad: "agree to.",
        sub: "Last updated April 2026. Plain-English where we can, lawyer-English where we must.",
      };
    case "privacy":
      return {
        eyebrow: "Legal · Privacy Policy",
        title: "What we collect, why,",
        grad: "and how to make us stop.",
        sub: "We collect the minimum we need to run the platform. You can export or delete your data at any time.",
      };
    case "acceptable-use":
      return {
        eyebrow: "Legal · Acceptable Use",
        title: "What you can",
        grad: "build here.",
        sub: "Short list: almost anything. Don't host malware, don't dox people, don't break the law.",
      };
    default:
      return {
        eyebrow: "Legal",
        title: "Policy",
        grad: "document.",
        sub: "",
      };
  }
}

function serveLegalPage(title: string, slug: string, filename: string) {
  return async (c: any) => {
    const user = c.get("user");
    let content: string;
    try {
      content = readFileSync(
        join(process.cwd(), "legal", filename),
        "utf-8"
      );
    } catch {
      content = `# ${title}\n\nThis page is being prepared. Check back soon.`;
    }

    const rendered = addHeadingIds(renderMarkdown(content));
    const toc = extractToc(content);
    const meta = getPageMeta(slug);

    return c.html(
      <Layout title={title} user={user}>
        <style>{markdownCss}</style>
        <style dangerouslySetInnerHTML={{ __html: legalStyles }} />
        <div class={`legal-page-wrap legal-page-${slug}`}>
          {/* ─── Hero ─── */}
          <section class="legal-page-hero">
            <div class="legal-page-hero-orb" aria-hidden="true" />
            <div class="legal-page-hero-inner">
              <div class="legal-page-eyebrow">
                <span class="legal-page-eyebrow-pill" aria-hidden="true">
                  <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
                    <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />
                    <polyline points="14 2 14 8 20 8" />
                  </svg>
                </span>
                {meta.eyebrow}
              </div>
              <h1 class="legal-page-title">
                {meta.title}{" "}
                <span class="legal-page-title-grad">{meta.grad}</span>
              </h1>
              <p class="legal-page-sub">{meta.sub}</p>
            </div>
          </section>

          {/* ─── Table of contents ─── */}
          {toc.length > 0 && (
            <nav class="legal-page-toc" aria-label="Table of contents">
              <div class="legal-page-toc-label">Contents</div>
              <ol class="legal-page-toc-list">
                {toc.map((item, i) => (
                  <li>
                    <a href={`#${item.id}`}>
                      <span class="num">
                        {String(i + 1).padStart(2, "0")}
                      </span>
                      {item.text}
                    </a>
                  </li>
                ))}
              </ol>
            </nav>
          )}

          {/* ─── Body ─── */}
          <article class="legal-page-body">
            <div class="markdown-body">
              {html([rendered] as unknown as TemplateStringsArray)}
            </div>
          </article>

          <div class="legal-page-foot">
            Questions? Email{" "}
            <a href="mailto:legal@gluecron.com">legal@gluecron.com</a>{" "}
            · Other policies:{" "}
            <a href="/terms">Terms</a> · <a href="/privacy">Privacy</a> ·{" "}
            <a href="/acceptable-use">AUP</a>
          </div>
        </div>
      </Layout>
    );
  };
}

legal.get("/terms", serveLegalPage("Terms of Service", "terms", "TERMS.md"));
legal.get("/privacy", serveLegalPage("Privacy Policy", "privacy", "PRIVACY.md"));
legal.get("/acceptable-use", serveLegalPage("Acceptable Use Policy", "acceptable-use", "AUP.md"));

export default legal;