my-homelab-configs/cmd/nextpath/internal/web/templates.go

28 lines
9.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package web
import "html/template"
func parsePage(content string) (*template.Template, error) {
return template.New("layout").Funcs(template.FuncMap{
"seq": func() []int { return []int{1, 2, 3, 4, 5} },
"progress": func(answered, total int) int { return answered * 100 / total },
}).Parse(layoutPage + content)
}
const layoutPage = `{{define "layout"}}<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>{{.Title}} · NextPath Arizona</title><style>
:root{color-scheme:dark;--bg:#07131e;--panel:#0d1d2a;--line:#264156;--text:#edf7ff;--muted:#9ab1c3;--accent:#43d7c2}
*{box-sizing:border-box}body{margin:0;background:radial-gradient(circle at top right,#12263d,var(--bg) 50%);color:var(--text);font:16px/1.5 system-ui,sans-serif}
main{max-width:900px;margin:auto;padding:48px 20px}.brand{color:var(--accent);font-weight:800;letter-spacing:.18em;text-transform:uppercase}h1{font-size:clamp(2rem,6vw,4rem);line-height:1.05;margin:.4em 0}.panel{background:color-mix(in srgb,var(--panel) 92%,transparent);border:1px solid var(--line);border-radius:20px;padding:28px;margin:24px 0}.muted{color:var(--muted)}
label{display:block;margin:16px 0 6px;font-weight:700}input,select,button{width:100%;padding:13px 14px;border-radius:10px;border:1px solid var(--line);background:#091722;color:var(--text);font:inherit}button,.button{display:inline-block;background:var(--accent);color:#03201b;border:0;font-weight:800;text-decoration:none;text-align:center;cursor:pointer}.secondary{background:transparent;color:var(--text);border:1px solid var(--line)}.error{padding:12px;border:1px solid #7b3342;background:#2b1720;border-radius:10px;color:#ffb4c1}.answers{display:grid;grid-template-columns:repeat(5,1fr);gap:8px}.answers label{margin:0;text-align:center;font-weight:500}.answers input{width:auto;display:block;margin:8px auto}.progress{height:8px;border-radius:8px;background:#172c3b;overflow:hidden}.progress span{display:block;height:100%;background:var(--accent)}.score{display:grid;grid-template-columns:40px 1fr 48px;gap:10px;align-items:center;margin:14px 0}.bar{height:12px;background:#172c3b;border-radius:8px;overflow:hidden}.bar span{display:block;height:100%;background:var(--accent)}.actions{display:flex;gap:12px;flex-wrap:wrap}.actions>*{flex:1;min-width:180px}.small{font-size:.85rem}code{color:var(--accent)}a{color:var(--accent)}
</style></head><body><main><div class="brand">NextPath Arizona</div>{{template "content" .}}</main></body></html>{{end}}`
const registerPage = `{{define "content"}}<h1>Find a path that fits your life.</h1><p class="muted">Start with your interests. We will add Arizona education and labor-market evidence without pretending to predict whether you will be hired.</p><section class="panel"><h2>Create your private profile</h2>{{if .Error}}<p class="error">{{.Error}}</p>{{end}}<form method="post" action="/register"><input type="hidden" name="csrf_token" value="{{.CSRF}}"><label for="display_name">Name shown in NextPath</label><input id="display_name" name="display_name" maxlength="80" value="{{.DisplayName}}" required><label for="email">Email</label><input id="email" name="email" type="email" value="{{.Email}}" required><label for="age_band">Age band</label><select id="age_band" name="age_band" required><option value="">Choose one</option><option>13-17</option><option>18-24</option><option>25-39</option><option>40-54</option><option>55+</option></select><label for="zip_code">Arizona ZIP code</label><input id="zip_code" name="zip_code" inputmode="numeric" pattern="[0-9]{5}" value="{{.ZIPCode}}" required><label for="password">Password (12 characters minimum)</label><input id="password" name="password" type="password" minlength="12" required><label><input style="width:auto" type="checkbox" name="consent" value="yes" required> I accept storage of this profile and assessment. I can export or delete it.</label><button type="submit">Create profile</button></form><p class="small muted">Already registered? <a href="/login">Sign in</a>.</p></section>{{end}}`
const loginPage = `{{define "content"}}<h1>Continue exploring.</h1><section class="panel"><h2>Sign in</h2>{{if .Error}}<p class="error">{{.Error}}</p>{{end}}<form method="post" action="/login"><input type="hidden" name="csrf_token" value="{{.CSRF}}"><label for="email">Email</label><input id="email" name="email" type="email" value="{{.Email}}" required><label for="password">Password</label><input id="password" name="password" type="password" required><button type="submit">Sign in</button></form><p class="small muted"><a href="/register">Create a profile</a></p></section>{{end}}`
const assessmentPage = `{{define "content"}}<h1>What sounds interesting, {{.Name}}?</h1><p class="muted">Rate the activity itself—not whether you are already good at it.</p><div class="progress"><span style="width:{{progress .Answered .Total}}%"></span></div><p class="small muted">{{.Answered}} of {{.Total}} answered</p><section class="panel"><h2>{{.Question.Prompt}}</h2><form method="post" action="/assessment"><input type="hidden" name="csrf_token" value="{{.CSRF}}"><input type="hidden" name="question_id" value="{{.Question.ID}}"><div class="answers">{{range $value := seq}}<label><input type="radio" name="answer" value="{{$value}}" required>{{$value}}</label>{{end}}</div><div class="answers small muted"><span>Not interested</span><span></span><span>Unsure</span><span></span><span>Very interested</span></div><button type="submit">Save and continue</button></form></section>{{end}}`
const resultsPage = `{{define "content"}}<h1>Your current interest profile</h1><p>Hello {{.Name}}. Your three-letter exploration code is <code>{{.Result.Code}}</code>.</p><section class="panel">{{range .Result.Scores}}<div class="score"><strong>{{.Dimension}}</strong><div class="bar"><span style="width:{{.Percent}}%"></span></div><span>{{.Percent}}%</span></div>{{end}}</section><section class="panel"><h2>Careers to explore next</h2><p class="muted">Interest fit and Arizona market outlook are separate signals. These percentages are market indexes, not your probability of being hired.</p>{{range .Matches}}<article class="panel"><div class="small muted">O*NET-SOC {{.Occupation.ONETSOC}} · interest fit {{.FitScore}}%</div><h3>{{.Occupation.Title}}</h3><p>{{.Occupation.Summary}}</p><p>{{.Reason}}</p>{{if .Outlook}}<div class="outlook"><h4>Arizona market evidence</h4><p><strong>Employability today: {{.Outlook.TodayEmployabilityPercent}}%</strong> · {{.Outlook.TodayLabel}}</p><p><strong>Five-year outlook: {{.Outlook.FiveYearEmployabilityPercent}}%</strong> · {{.Outlook.FiveYearLabel}}</p><p class="small">{{.Outlook.Evidence.ArizonaProjectedOpenings}} projected openings/year and {{.Outlook.Evidence.ActivePostings}} sampled current postings. Arizona exact-program completions: {{.Outlook.Evidence.ArizonaGraduateHistory}}; three-year average {{.Outlook.ThreeYearAverageGraduates}}. Demand-to-average-graduates ratio: {{.Outlook.AnnualDemandToGraduateRatio}}.</p><p class="small">Official projected employment growth: {{.Outlook.Evidence.ProjectedEmploymentGrowthPercent}}%. Historical graduate trend: {{.Outlook.GraduateAnnualTrendPercent}}%/year; modeled five-year graduate supply: {{.Outlook.ProjectedFiveYearGraduates}}.</p><p class="small muted">Today = 75% projected annual demand coverage + 25% sampled current posting coverage. Five-year = 75% projected demand coverage against trend-modeled supply + 25% official employment-growth signal. Supply trend is capped at ±10%/year; official growth from -5% to +20% maps to the 0–100 growth signal. {{.Outlook.Confidence}} evidence confidence. Snapshot {{.Outlook.Evidence.PostingsObservedAt.Format "Jan 2, 2006"}}.</p><div class="small"><a href="{{.Outlook.Evidence.GraduateSourceURL}}" rel="noreferrer">Completion source</a> · <a href="{{.Outlook.Evidence.ProjectionSourceURL}}" rel="noreferrer">Projection source</a> · <a href="{{.Outlook.Evidence.PostingSourceURL}}" rel="noreferrer">Posting source</a></div></div>{{else}}<p class="muted"><strong>Arizona employability outlook unavailable.</strong> Complete source evidence has not been refreshed for this occupation; no percentage is estimated.</p>{{end}}<p><strong>Try it first:</strong> {{.Occupation.TryFirst}}</p><a href="{{.Occupation.SourceURL}}" rel="noreferrer">Review the O*NET occupation profile</a></article>{{end}}</section><section class="panel"><h2>How to use this</h2><p>{{.Result.InstrumentNotice}}</p><p class="muted">Confidence: {{.Result.Confidence}}. This describes interests, not ability or identity. Market indexes are contextual evidence, not a hiring promise.</p></section><div class="actions"><a class="button" href="/account/export">Export my data</a><form method="post" action="/logout"><input type="hidden" name="csrf_token" value="{{.CSRF}}"><button class="secondary">Sign out</button></form></div><section class="panel"><h2>Delete account</h2><form method="post" action="/account/delete"><input type="hidden" name="csrf_token" value="{{.CSRF}}"><label for="confirm">Type DELETE</label><input id="confirm" name="confirm" required><button class="secondary" type="submit">Delete profile and answers</button></form></section>{{end}}`