web

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 20 Imported by: 0

README

Web compilation

This code is extensively based on maxence-charriere/go-app.

MIT License (Copyright (c) 2016 Maxence Charriere)

Documentation

Index

Constants

View Source
const (
	// DefaultAppWorkersJS is the default template used in [MakeAppWorkerJS] to generate app-worker.js.
	DefaultAppWorkerJS = "" /* 2722-byte string literal not displayed */

	// WASMExecJSGoCurrent is the wasm_exec.js file for the current version of Go.
	WASMExecJSGoCurrent = "" /* 18065-byte string literal not displayed */

	// AppJS is the string used for [AppJSTmpl].
	AppJS = "" /* 9365-byte string literal not displayed */

	// ManifestJSON is the string used for [ManifestJSONTmpl].
	ManifestJSON = "" /* 528-byte string literal not displayed */

	// AppCSS is the string used for app.css.
	AppCSS = "" /* 3033-byte string literal not displayed */

	// IndexHTML is the string used for [IndexHTMLTmpl].
	IndexHTML = "" /* 2378-byte string literal not displayed */

)

Variables

View Source
var AppJSTmpl = template.Must(template.New("app.js").Parse(AppJS))

AppJSTmpl is the template used in MakeAppJS to build the app.js file

View Source
var IndexHTMLTmpl = template.Must(template.New("index.html").Parse(IndexHTML))

IndexHTMLTmpl is the template used in MakeIndexHTML to build the index.html file

View Source
var ManifestJSONTmpl = template.Must(template.New("manifest.webmanifest").Parse(ManifestJSON))

ManifestJSONTmpl is the template used in MakeManifestJSON to build the mainfest.webmanifest file

Functions

func Build

func Build(c *config.Config) error

Build builds an app for web using the given configuration information.

func MakeAppJS

func MakeAppJS(c *config.Config) ([]byte, error)

MakeAppJS exectues AppJSTmpl based on the given configuration information.

func MakeAppWorkerJS

func MakeAppWorkerJS(c *config.Config) ([]byte, error)

MakeWorkerJS executes [config.Config.Web.ServiceWorkerTemplate]. If it empty, it sets it to DefaultAppWorkerJS.

func MakeFiles

func MakeFiles(c *config.Config) error

MakeFiles makes the necessary static web files based on the given configuration information.

func MakeIndexHTML

func MakeIndexHTML(c *config.Config, basePath string, title string) ([]byte, error)

MakeIndexHTML exectues IndexHTMLTmpl based on the given configuration information, base path for app resources (used in MakePages), and optional title (used in MakePages, defaults to config.Config.Name otherwise).

func MakeManifestJSON

func MakeManifestJSON(c *config.Config) ([]byte, error)

MakeManifestJSON exectues ManifestJSONTmpl based on the given configuration information.

func MakePages added in v0.1.1

func MakePages(c *config.Config) error

MakePages makes a directory structure of pages for the core pages located at config.Config.Pages.

func Serve

func Serve(c *config.Config) error

Serve serves the build output directory on the default network address at the config port.

func WASMExecJS

func WASMExecJS() string

WASMExecJS returns the wasm_exec.js file appropriate for the Go verison being used.

Types

type AppJSData

type AppJSData struct {
	Env                     string
	WasmContentLengthHeader string
	AutoUpdateInterval      int64
}

AppJSData is the data passed to AppJSTmpl

type AppWorkerJSData

type AppWorkerJSData struct {
	Version          string
	ResourcesToCache string
}

AppWorkerJSData is the data passed to [config.Config.Web.ServiceWorkerTemplate]

type IndexHTMLData

type IndexHTMLData struct {
	BasePath               string
	Author                 string
	Desc                   string
	Keywords               []string
	Title                  string
	SiteName               string
	Image                  string
	VanityURL              string
	GithubVanityRepository string
}

IndexHTMLData is the data passed to IndexHTMLTmpl

type ManifestJSONData

type ManifestJSONData struct {
	ShortName   string
	Name        string
	Description string
}

ManifestJSONData is the data passed to ManifestJSONTmpl

Jump to

Keyboard shortcuts

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