assets

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: BSD-2-Clause Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package assets validates and publishes visual assets (SVG card templates, logos) discovered by repository layout plugins.

Index

Constants

View Source
const MaxSVGSize = 2 << 20

MaxSVGSize is the largest SVG document accepted for publication.

Variables

View Source
var Exts = []string{".svg", ".png", ".jpg", ".jpeg", ".webp"}

Exts are the file extensions published for an asset.

View Source
var Keys = []string{"svg_template", "svg_template_dark", "logo"}

Keys are the asset keys layout plugins use in DiscoveredCredential.Assets.

Functions

func Check

func Check(filename string, data []byte) error

Check validates asset content for publication. SVG documents are checked with ValidateSVG; raster images are accepted by extension.

func DropURIs

func DropURIs(vctm []byte, uris map[string]bool) ([]byte, error)

DropURIs removes every object whose "uri" is in uris from a VCTM document and prunes containers left empty (svg_templates, logo, simple, rendering). It returns the document unchanged when uris is empty.

func Filename

func Filename(slug, key, ext string) string

Filename returns the published file name of an asset: <slug>-<key><ext>.

func IsPublishableExt

func IsPublishableExt(ext string) bool

IsPublishableExt reports whether ext (with leading dot) is a published asset extension.

func Publish

func Publish(srcDir, outputDir, org, slug string, logger *slog.Logger) []string

Publish copies the staged assets of one credential from srcDir to <outputDir>/<org>/, next to the credential's VCTM. Staged files are named <slug>-<key><ext> for the known keys and extensions. SVG files are validated again before they are written, and a file that would replace a credential format file keeps the format file. It returns the published file names.

func URL

func URL(baseURL, org, filename string) string

URL returns the absolute URL of a published asset: <baseURL>/<org>/<filename>. A trailing slash on baseURL is trimmed.

func ValidateSVG

func ValidateSVG(data []byte) error

ValidateSVG checks that data is a well-formed SVG document that is safe to serve from the registry origin. It returns a descriptive error for the first violation found. The document is walked with the encoding/xml tokenizer, so the checks follow the parsed structure of the document.

Types

This section is empty.

Jump to

Keyboard shortcuts

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