render

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package render handles HTML template rendering and markdown-to-HTML conversion for the registry site.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyStaticAssets

func CopyStaticAssets(srcDir, dstDir string) error

CopyStaticAssets copies static files (CSS, images) from a source directory to the output directory, preserving the directory structure.

func RenderMarkdown

func RenderMarkdown(markdown []byte) (template.HTML, error)

RenderMarkdown converts markdown content to sanitized HTML. The output is sanitized with bluemonday to prevent XSS from untrusted markdown sources (e.g. external git repositories).

func WriteOpenAPISpec

func WriteOpenAPISpec(path string) error

WriteOpenAPISpec writes the embedded OpenAPI specification to the given path.

Types

type AttributeCredRef added in v0.7.0

type AttributeCredRef struct {
	Org  string
	Slug string
	Name string // credential display name or slug
}

AttributeCredRef links an attribute back to a credential.

type AttributeData added in v0.7.0

type AttributeData struct {
	Path        string // dot-joined claim path
	DisplayName string // first non-empty display name found
	Credentials []AttributeCredRef
}

AttributeData holds a single attribute (claim) with references to the credentials that define it.

func CollectAttributes added in v0.7.0

func CollectAttributes(credentials []CredentialData) []AttributeData

CollectAttributes aggregates claims from all credentials into a deduplicated cross-cutting index. Claims with the same dot-path are merged, collecting references to all credentials that define them.

type CredentialData

type CredentialData struct {
	Org           string
	Slug          string
	Schema        *schemameta.SchemaMeta
	TS11Compliant bool
	HasRulebook   bool
	RulebookHTML  template.HTML

	// VCTM content
	VCTM             *VCTMData
	RawVCTMJSON      string
	RawMdocJSON      string
	RawVCJSON        string
	HasMdoc          bool
	HasVC            bool
	AvailableFormats []FormatInfo

	// Source info
	SourceURL  string
	SourceOrg  string
	SourceRepo string
}

CredentialData holds the data for rendering a credential detail page.

type FormatInfo

type FormatInfo struct {
	Name  string
	Label string
	File  string
}

FormatInfo describes an available credential format file for download.

type OrgData

type OrgData struct {
	Name        string
	Credentials []CredentialData
	HasTS11     bool
	AvatarURL   string
}

OrgData holds the data for rendering an organization page.

type Renderer

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

Renderer renders HTML pages from Go templates.

func NewRenderer

func NewRenderer(overrideDir string) (*Renderer, error)

NewRenderer creates a renderer, loading default templates and optionally overlaying site-specific template overrides.

func (*Renderer) RenderAPIDocs

func (r *Renderer) RenderAPIDocs(outputDir string, data SiteData) error

RenderAPIDocs renders the API reference page.

func (*Renderer) RenderAttributes added in v0.7.0

func (r *Renderer) RenderAttributes(outputDir string, data SiteData) error

RenderAttributes renders the Catalogue of Attributes page.

func (*Renderer) RenderCredential

func (r *Renderer) RenderCredential(outputDir string, data CredentialData) error

RenderCredential renders a credential detail page.

func (*Renderer) RenderExtraDocPages

func (r *Renderer) RenderExtraDocPages(outputDir string, data SiteData) error

RenderExtraDocPages renders any additional HTML templates loaded from the override directory that aren't part of the built-in set. They are rendered to docs/{name} in the output directory.

func (*Renderer) RenderIndex

func (r *Renderer) RenderIndex(outputDir string, data SiteData) error

RenderIndex renders the site index page.

func (*Renderer) RenderOrg

func (r *Renderer) RenderOrg(outputDir string, data OrgData) error

RenderOrg renders an organization page.

func (*Renderer) RenderRulebook

func (r *Renderer) RenderRulebook(outputDir string, data CredentialData) error

RenderRulebook renders a rulebook markdown file to HTML.

func (*Renderer) RenderTS11Docs

func (r *Renderer) RenderTS11Docs(outputDir string, data SiteData) error

RenderTS11Docs renders the TS11 documentation page.

type SiteData

type SiteData struct {
	BaseURL     string
	Credentials []CredentialData
	BuildTime   string
	Orgs        []OrgData
	TS11Count   int
	Attributes  []AttributeData
}

SiteData holds the data for rendering the site index page.

type VCTMClaim

type VCTMClaim struct {
	Path    []string           `json:"path"`
	Display []VCTMClaimDisplay `json:"display,omitempty"`
}

VCTMClaim holds a single claim definition.

type VCTMClaimDisplay

type VCTMClaimDisplay struct {
	Name   string `json:"name,omitempty"`
	Locale string `json:"locale,omitempty"`
}

VCTMClaimDisplay holds display info for a claim.

type VCTMData

type VCTMData struct {
	VCT         string        `json:"vct,omitempty"`
	Name        string        `json:"name,omitempty"`
	Description string        `json:"description,omitempty"`
	Extends     string        `json:"extends,omitempty"`
	Display     []VCTMDisplay `json:"display,omitempty"`
	Claims      []VCTMClaim   `json:"claims,omitempty"`
}

VCTMData holds parsed SD-JWT VC Type Metadata content.

type VCTMDisplay

type VCTMDisplay struct {
	Locale          string         `json:"locale,omitempty"`
	Name            string         `json:"name,omitempty"`
	Description     string         `json:"description,omitempty"`
	BackgroundColor string         `json:"background_color,omitempty"`
	TextColor       string         `json:"text_color,omitempty"`
	BackgroundImage *VCTMImage     `json:"background_image,omitempty"`
	Rendering       *VCTMRendering `json:"rendering,omitempty"`
}

VCTMDisplay holds display properties for a VCTM credential.

type VCTMImage

type VCTMImage struct {
	URI     string `json:"uri,omitempty"`
	AltText string `json:"alt_text,omitempty"`
}

VCTMImage holds image data (logo or background).

type VCTMRendering

type VCTMRendering struct {
	SVGTemplates []VCTMSVGTemplate `json:"svg_templates,omitempty"`
}

VCTMRendering holds rendering hints for a display entry.

type VCTMSVGTemplate

type VCTMSVGTemplate struct {
	URI        string             `json:"uri,omitempty"`
	Properties *VCTMTemplateProps `json:"properties,omitempty"`
}

VCTMSVGTemplate holds an SVG template reference.

type VCTMTemplateProps

type VCTMTemplateProps struct {
	Orientation string `json:"orientation,omitempty"`
	ColorScheme string `json:"color_scheme,omitempty"`
	Contrast    string `json:"contrast,omitempty"`
}

VCTMTemplateProps describes SVG template rendering properties.

Jump to

Keyboard shortcuts

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