assets

package
v0.801.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package assets provides the embedded JaWS client assets and page-resource helpers.

The embedded client forwards browser events and applies server-sent DOM commands; authoritative application state remains on the server. It inserts server-sent HTML without escaping, so applications must escape untrusted text before converting it to html/template.HTML or passing it as a plain string to an HTML-producing widget; see github.com/linkdata/jaws/lib/bind.MakeHTMLGetter.

Index

Constants

View Source
const ISO8601 = "2006-01-02"

ISO8601 is the date format used by date input widgets (YYYY-MM-DD).

Variables

View Source
var DefaultCookieName string

DefaultCookieName is the default JaWS cookie name, derived from the executable's base name (ASCII letters and digits only) and falling back to "jaws". It is computed once during package initialization, so it is safe to read concurrently; callers needing a different name supply their own.

View Source
var JavascriptText string

JavascriptText is the source code for the client-side JaWS JavaScript library.

It holds the embedded asset as an immutable string shared process-wide.

View Source
var JawsCSS string

JawsCSS is the source code for the client-side JaWS stylesheet.

It holds the embedded asset as an immutable string shared process-wide.

Functions

func MakeCookieName

func MakeCookieName(exename string) (cookie string)

MakeCookieName creates a cookie-safe name from an executable path.

It uses the path's base name with its last file extension removed, then keeps only ASCII letters and digits. If no usable characters remain (including for an empty path), it returns "jaws", the fallback recorded in DefaultCookieName.

func PreloadHTML

func PreloadHTML(urls ...*url.URL) (htmlCode, faviconURL string)

PreloadHTML returns head markup for common resource URLs.

A .js extension matched by secureheaders.InferResource emits a deferred classic script, and a matched .css extension emits a stylesheet. These forms may include a trailing @version when the final extension is otherwise unrecognized. Non-favicon resources inferred exclusively as images or fonts emit preloads. Module scripts, MIME-only scripts and stylesheets, generic fetch resources, and all other URLs are omitted. Font preloads use anonymous CORS. Image and font preloads include a compatible MIME type from the final extension when available. Resource URLs must come from trusted application configuration because matched scripts are executable.

Nil URL arguments are skipped. A resource is returned as faviconURL only when its base name begins with "favicon" and it is classified as an image. A script or stylesheet is never treated as a favicon, regardless of its base name. If more than one resource qualifies as a favicon, the last one wins and earlier favicon URLs are discarded. The winner is emitted as an icon and returned as faviconURL.

Types

This section is empty.

Jump to

Keyboard shortcuts

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