Documentation
¶
Overview ¶
Package view holds the types shared by the shell, components and pages: page metadata, the user's appearance preferences, status values and date formatting. Pages receive plain view models; they never query services.
Index ¶
- Constants
- Variables
- func ColonHex(hex string) string
- func Date(t time.Time) string
- func DateTime(t time.Time) string
- func Fingerprint(hex string) string
- func Relative(now, t time.Time) string
- type ActivityRow
- type CertRow
- type Crumb
- type Density
- type KV
- type Layout
- type Message
- type MessageKind
- type Option
- type Page
- type Prefs
- type Session
- type Status
- type Tab
- type Theme
Constants ¶
const ( LayoutA Layout = "a" // narrow sidebar LayoutB Layout = "b" // standard sidebar LayoutC Layout = "c" // no sidebar ThemeLight Theme = "light" ThemeDark Theme = "dark" ThemeSystem Theme = "system" DensityComfortable Density = "comfortable" DensityCompact Density = "compact" )
Allowed values.
const PrefsCookie = "myownpki_ui"
PrefsCookie stores the appearance preferences. It holds no secret, so it isn't signed; every value is checked against an allow-list when read. With TLS (phase 1) it gets the __Host- prefix and Secure.
Variables ¶
var ( Layouts = []Layout{LayoutA, LayoutB, LayoutC} Themes = []Theme{ThemeLight, ThemeDark, ThemeSystem} Densities = []Density{DensityComfortable, DensityCompact} )
Layouts, Themes and Densities list the allowed values in display order.
Functions ¶
func ColonHex ¶
ColonHex formats hex digits as colon-separated byte pairs, like `openssl x509 -fingerprint` (78:3D:62:…). Input case and existing colons are ignored.
func Fingerprint ¶
Fingerprint formats a SHA-256 fingerprint like OpenSSL, split into two lines of 16 bytes so it fits a details column and can be compared line by line.
Types ¶
type ActivityRow ¶
ActivityRow is one audit entry in the recent-activity table.
type CertRow ¶
type CertRow struct {
ID, CommonName, Preset, CA string
Serial string
Expires, ExpiresRel string
Status Status
StatusText string
}
CertRow is one certificate in a table (list, overview, CA details).
type Crumb ¶
type Crumb struct {
Label, Href string
}
Crumb is one breadcrumb entry; an empty Href renders plain text.
type Message ¶
type Message struct {
Kind MessageKind
Text string
Href string
LinkText string
}
Message is one message bar, optionally with a link after the text.
type MessageKind ¶
type MessageKind string
MessageKind selects the label of a message bar.
const ( MessageInfo MessageKind = "info" MessageSuccess MessageKind = "ok" MessageWarning MessageKind = "warn" MessageError MessageKind = "crit" )
Message kinds and their labels ("Warning:", "Error:" …).
func (MessageKind) Label ¶
func (k MessageKind) Label() string
Label is the text label shown in front of the message.
type Page ¶
type Page struct {
Title string
Description string // optional one-line description under the title
Status Status // optional status next to the title
StatusText string
Actions templ.Component // optional command groups right of the title
Section string // key of the active navigation entry
Crumbs []Crumb // breadcrumb trail, without the current page
Prefs Prefs
Dev bool // show the DEV MODE banner
Tenant string
Tenants []string
User string
Search string // current value of the header search box
// Session is the signed-in user of the real UI (phase 1 step 14); nil
// in the prototype, which shows its placeholder user menu.
Session *Session
// Notices are shown above the page header on every page: the demo
// warning and "signing is off" while sealed.
Notices []Message
// BuiltOnly hides navigation entries that don't exist yet.
BuiltOnly bool
}
Page is what every page passes to the application shell. The shell renders the page header – breadcrumb, title, status, description, actions – from it, so every page has the same header.
func (Page) WithActions ¶
WithActions returns a copy of p with the given header actions.
type Prefs ¶
Prefs are the per-user appearance settings.
func ParsePrefs ¶
ParsePrefs reads the cookie value "layout.theme.density". Unknown or missing parts fall back to the default, so a tampered cookie can never inject anything into the page.
func PrefsFromRequest ¶
PrefsFromRequest returns the preferences of the request, or the defaults.
type Session ¶
type Session struct {
Username string
Roles string // "admin of tenant default", for the user menu
CSRF string // token for the forms of the user menu
CanSeal bool // instance admin: offer "Seal now"
// CanIssue: the user may issue at one CA at least – otherwise "Issue
// certificate" is not offered anywhere (no dead links, owner 2026-10-18).
CanIssue bool
// Hidden are navigation entries the user may not use (step 19).
Hidden []string
}
Session is what the shell shows of the signed-in user.
type Status ¶
type Status string
Status is the meaning of a status text. Colors are fixed tokens (ADR-12).