panel

package
v0.29.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2026 License: CC0-1.0 Imports: 39 Imported by: 0

Documentation

Overview

Package panel hosts the web UI for prosa. The panel is a thin templ + HTMX client of the Connect API exposed by prosa-server; it owns OAuth, cookies, and the HTML rendering — nothing else.

Index

Constants

This section is empty.

Variables

View Source
var Themes = []ThemeMeta{
	{"almanac", "Almanac", "Warm editorial (default)", []string{"#2f8f7f", "#c9952f", "#7aaa6d", "#cf6b4a"}},
	{"colorblind", "Colorblind", "Colorblind-safe Okabe-Ito", []string{"#56b4e9", "#e69f00", "#1fb894", "#ef6c1a"}},
	{"light", "Light", "Always light", []string{"#4a5af0", "#56b4e9", "#e69f00", "#009e73"}},
	{"nord", "Nord", "Cool arctic", []string{"#88c0d0", "#ebcb8b", "#a3be8c", "#bf616a"}},
	{"solarized-dark", "Solarized Dark", "Solarized dark", []string{"#268bd2", "#b58900", "#859900", "#dc322f"}},
	{"solarized-light", "Solarized Light", "Solarized light", []string{"#268bd2", "#b58900", "#859900", "#cb4b16"}},
	{"dracula", "Dracula", "Purple night", []string{"#bd93f9", "#ffb86c", "#50fa7b", "#ff5555"}},
	{"gruvbox", "Gruvbox", "Warm retro", []string{"#fabd2f", "#fe8019", "#b8bb26", "#fb4934"}},
	{"high-contrast", "High Contrast", "Maximum contrast", []string{"#ffd400", "#4dd2ff", "#00e676", "#ff3b30"}},
	{"system", "System", "Follow OS preference", []string{"#56b4e9", "#e69f00", "#1fb894", "#ef6c1a"}},
}

Themes is the single source of truth for the catalog: the picker renders from it and the Set handler validates against it, so the two can never drift. Order here is the order shown on the Settings page.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ListenAddr is where the panel's HTTP server binds.
	// Env: PROSA_PANEL_LISTEN_ADDR (default ":8080").
	ListenAddr string

	// ServerURL is the prosa-server Connect base URL.
	// Env: PROSA_PANEL_SERVER_URL (default "http://localhost:7070").
	ServerURL string

	// AdminToken is shared with prosa-server; the panel attaches it as
	// `Authorization: Admin <token>` on every Connect call so the
	// server scopes the request as "owner" (not device).
	// Env: PROSA_ADMIN_TOKEN (required).
	AdminToken string

	// OAuth GitHub client credentials. Required unless DevLoginEmail
	// is set.
	// Env: PROSA_PANEL_OAUTH_GH_CLIENT_ID / PROSA_PANEL_OAUTH_GH_SECRET.
	OAuthGHClientID string
	OAuthGHSecret   string

	// PublicBaseURL is the absolute URL the panel is reachable at; used
	// to build the OAuth callback. Default derived from ListenAddr +
	// "http://localhost".
	// Env: PROSA_PANEL_PUBLIC_URL (optional).
	PublicBaseURL string

	// CookieKey is the HMAC key for session cookies. Hex-encoded; 32+
	// bytes recommended. Required.
	// Env: PROSA_PANEL_COOKIE_KEY.
	CookieKey string

	// CookieSecure flags the `Secure` cookie attribute. False is OK in
	// local dev over plain http; turn on in production.
	// Env: PROSA_PANEL_COOKIE_SECURE ("true"/"1").
	CookieSecure bool

	// OwnerEmails is the email whitelist. CSV of lowercase emails.
	// Anyone whose verified GitHub primary email isn't in here gets a
	// 403 and the session is not started.
	// Env: PROSA_OWNER_EMAILS (default "hi@caian.org").
	OwnerEmails []string

	// DevLoginEmail, when set, enables a local-only POST /dev-login
	// route that skips GitHub OAuth entirely and sets the session
	// cookie directly. Email must be in OwnerEmails. Boot logs a loud
	// warning when this is non-empty.
	// Env: PROSA_PANEL_DEV_LOGIN (optional; do NOT use in production).
	DevLoginEmail string
}

Config carries every knob the panel binary reads from the environment. All values are loaded once at startup; runtime mutation is not supported.

func Load

func Load() (Config, error)

Load reads the environment and returns a validated Config.

func (Config) IsOwnerEmail

func (c Config) IsOwnerEmail(email string) bool

IsOwnerEmail returns true when email (case-insensitive) is in the whitelist.

type Panel

type Panel struct {
	// contains filtered or unexported fields
}

Panel is the assembled HTTP server. Build via New, drive with Serve.

func New

func New(cfg Config) (*Panel, error)

New parses the embedded templates and wires every route. Each view gets its own clone so per-view `{{define "content"}}` / `{{define "side"}}` blocks don't collide, while shared templates are parsed once.

func (*Panel) Serve

func (p *Panel) Serve(ctx context.Context) error

Serve binds the configured listener and blocks until ctx fires.

type ThemeMeta

type ThemeMeta struct {
	ID     string
	Label  string
	Hint   string
	Swatch []string
}

ThemeMeta drives the Settings picker. Swatch is a handful of representative hexes (accent + a few chart hues) shown as preview dots; the actual palette lives in tokens.css under [data-theme="<ID>"].

Directories

Path Synopsis
Package assets embeds the panel's static files.
Package assets embeds the panel's static files.
Package charts builds chart specs serialized to a JSON island and rendered client-side by Frappe Charts (see assets/charts-init.js).
Package charts builds chart specs serialized to a JSON island and rendered client-side by Frappe Charts (see assets/charts-init.js).
Package oauth speaks the minimal GitHub OAuth web flow needed by the panel: build the consent URL, exchange the code, fetch the primary verified email.
Package oauth speaks the minimal GitHub OAuth web flow needed by the panel: build the consent URL, exchange the code, fetch the primary verified email.
Package render turns canonical session content into the HTML the sidepanel template ships.
Package render turns canonical session content into the HTML the sidepanel template ships.
Package rpc wraps Connect clients that call prosa-server, pre-injecting "Authorization: Admin <token>" so callers never need to remember it.
Package rpc wraps Connect clients that call prosa-server, pre-injecting "Authorization: Admin <token>" so callers never need to remember it.
Package session implements the panel's HMAC-signed cookie.
Package session implements the panel's HMAC-signed cookie.
Package templates holds the html/template sources rendered by the panel handlers.
Package templates holds the html/template sources rendered by the panel handlers.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL