html

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MaxEmbeddedManifestSize = 10 << 20 // 10 MiB

MaxEmbeddedManifestSize is the maximum size of MANIFEST.age that will be embedded (base64-encoded) in recover.html. Manifests at or below this size are included so recovery can work without the separate MANIFEST.age file.

Variables

This section is empty.

Functions

func DocsLanguages added in v0.0.16

func DocsLanguages() []string

DocsLanguages returns the language codes that have a translated docs guide (e.g. ["es"]). English is excluded since it's the default.

func DocsLanguagesJS added in v0.0.16

func DocsLanguagesJS() string

DocsLanguagesJS returns a JS array literal of language codes that have a translated docs guide (e.g. ['es']). English is excluded since it's the default and uses docs.html without a language suffix.

func ExtractManifestFromHTML added in v0.0.10

func ExtractManifestFromHTML(htmlContent []byte) ([]byte, error)

ExtractManifestFromHTML extracts the MANIFEST.age bytes from a personalized recover.html file. It finds the embedded PERSONALIZATION JSON, parses the manifestB64 field, and base64-decodes it.

Returns an error if the HTML doesn't contain personalization data, or if the personalization doesn't include an embedded manifest (e.g., when --no-embed-manifest was used or the manifest was too large).

func ExtractShareFromHTML added in v0.0.15

func ExtractShareFromHTML(htmlContent []byte) (*core.Share, error)

ExtractShareFromHTML extracts the share from a personalized recover.html file. It finds the embedded PERSONALIZATION JSON and parses the holderShare field.

func GenerateDocsHTML

func GenerateDocsHTML(lang string, selfhosted bool) string

GenerateDocsHTML creates the documentation page HTML from Markdown content. lang is the language code (e.g. "en", "es"). Falls back to "en" if not found.

func GenerateHomeHTML added in v0.0.16

func GenerateHomeHTML(bundlesJSON string) string

GenerateHomeHTML creates the selfhosted home page with bundle data.

func GenerateIndexHTML

func GenerateIndexHTML(selfhosted bool) string

GenerateIndexHTML creates the landing page HTML with embedded CSS.

func GenerateMakerHTML

func GenerateMakerHTML(createWASMBytes []byte, opts MakerHTMLOptions) string

GenerateMakerHTML creates the complete maker.html with all assets embedded. createWASMBytes is the create.wasm binary (runs in browser for bundle creation). Note: recover.html uses native JavaScript crypto, not WASM.

func GenerateRecoverHTML

func GenerateRecoverHTML(personalization *PersonalizationData, opts ...RecoverHTMLOptions) string

GenerateRecoverHTML creates the complete recover.html with all assets embedded. Uses native JavaScript crypto (no WASM required). personalization can be nil for a generic recover.html, or provided to personalize for a specific friend.

func GenerateSetupHTML added in v0.0.16

func GenerateSetupHTML() string

GenerateSetupHTML creates the admin password setup page.

func GetCreateWASMBytes

func GetCreateWASMBytes() []byte

GetCreateWASMBytes returns the full WASM binary with bundle creation. This larger WASM is used in maker.html for the creation tool. Note: Must be set via SetCreateWASMBytes before use (done in CLI init).

func HomeBundlesJSON added in v0.0.16

func HomeBundlesJSON(bundles any) string

HomeBundlesJSON serializes bundle metadata to JSON for the home page.

func SetBuildDate added in v0.0.17

func SetBuildDate(d string)

SetBuildDate sets the package-level build date used by HTML generation. Call this once at startup before generating any HTML.

func SetCreateWASMBytes

func SetCreateWASMBytes(data []byte)

SetCreateWASMBytes sets the create.wasm bytes. Called by CLI initialization to avoid circular embedding.

func SetVersion added in v0.0.16

func SetVersion(v string)

SetVersion sets the package-level version used by all Generate functions. Call this once at startup before generating any HTML.

Types

type DocsFrontmatter added in v0.0.16

type DocsFrontmatter struct {
	Title        string `yaml:"title"`
	Subtitle     string `yaml:"subtitle"`
	CLIGuideNote string `yaml:"cli_guide_note"`
	NavHome      string `yaml:"nav_home"`
	NavHomeLink  string `yaml:"nav_home_link"`
	NavCreate    string `yaml:"nav_create"`
	NavRecover   string `yaml:"nav_recover"`
	TOCTitle     string `yaml:"toc_title"`
	FooterSource string `yaml:"footer_source"`
	FooterDL     string `yaml:"footer_download"`
	FooterHome   string `yaml:"footer_home"`
}

DocsFrontmatter holds the chrome/UI strings from the YAML frontmatter at the top of each Markdown docs content file.

type FriendInfo

type FriendInfo struct {
	Name       string `json:"name"`
	Contact    string `json:"contact,omitempty"`
	ShareIndex int    `json:"shareIndex"` // 1-based share index for this friend
}

FriendInfo holds friend contact information for the UI.

type I18nScriptOptions added in v0.0.16

type I18nScriptOptions struct {
	Component           string // translation component name: "maker", "recover", "index"
	UseNonce            bool   // whether to add nonce="{{CSP_NONCE}}" to the script tag
	ExtraDeclarations   string // JS inserted after translations (e.g. docsLangs)
	SetLanguageExtra    string // JS appended inside setLanguage() after core DOM updates
	DOMContentLoadedPre string // JS at start of DOMContentLoaded handler, before setLanguage()
}

I18nScriptOptions controls the page-specific parts of the shared i18n script block.

type LayoutOptions added in v0.0.16

type LayoutOptions struct {
	Title           string // Page <title>
	BodyClass       string // Optional body class (e.g. "setup" to hide nav)
	HeadMeta        string // Extra <head> content (CSP, OG tags, etc.)
	PageStyles      string // Page-specific CSS (injected after shared styles)
	NavExtras       string // Extra nav content (e.g. language selector)
	BeforeContainer string // Content before the .container div (e.g. toast container, modals)
	Content         string // Page-specific HTML inside .container
	FooterContent   string // Footer inner HTML
	Scripts         string // Page-specific <script> tags
	Selfhosted      bool   // Selfhosted mode: logo links to "/" instead of "about.html"
}

LayoutOptions holds the parameters for assembling a page from the shared layout.

type MakerHTMLOptions added in v0.0.16

type MakerHTMLOptions struct {
	Selfhosted       bool              // Use selfhosted JS variant with server integration
	SelfhostedConfig *SelfhostedConfig // Config injected into the HTML for selfhosted mode
}

MakerHTMLOptions holds optional parameters for GenerateMakerHTML.

type PersonalizationData

type PersonalizationData struct {
	Holder       string       `json:"holder"`                 // This friend's name
	HolderShare  string       `json:"holderShare"`            // This friend's encoded share
	OtherFriends []FriendInfo `json:"otherFriends"`           // List of other friends
	Threshold    int          `json:"threshold"`              // Required shares (K)
	Total        int          `json:"total"`                  // Total shares (N)
	Language     string       `json:"language,omitempty"`     // Default UI language for this friend
	ManifestB64  string       `json:"manifestB64,omitempty"`  // Base64-encoded MANIFEST.age (when <= MaxEmbeddedManifestSize)
	TlockEnabled bool         `json:"tlockEnabled,omitempty"` // Signals tlock-js should be included
}

PersonalizationData holds the data to personalize recover.html for a specific friend.

type RecoverHTMLOptions added in v0.0.16

type RecoverHTMLOptions struct {
	NoTlock          bool              // Omit tlock-js even from generic recover.html
	Selfhosted       bool              // Full selfhosted server mode (nav rewrites + config)
	SelfhostedConfig *SelfhostedConfig // Config injected into the HTML for selfhosted mode
	StaticHosted     bool              // Static hosting mode (manifest fetch, no nav rewrites)
}

RecoverHTMLOptions holds optional parameters for GenerateRecoverHTML.

type SelfhostedConfig added in v0.0.16

type SelfhostedConfig struct {
	MaxManifestSize int    `json:"maxManifestSize"`       // Maximum MANIFEST.age size the server accepts
	HasManifest     bool   `json:"hasManifest"`           // Whether a manifest currently exists on the server
	ManifestURL     string `json:"manifestURL,omitempty"` // URL to fetch manifest from (set by server or static pages)
}

SelfhostedConfig holds configuration passed to the selfhosted frontend.

type TOCEntry added in v0.0.16

type TOCEntry struct {
	ID    string // The heading's anchor ID
	Text  string // The heading text
	Level int    // 2 for h2, 3 for h3
}

TOCEntry represents a single entry in the table of contents.

Jump to

Keyboard shortcuts

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