render

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package render generates HTML pages listing edits.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenFile

func OpenFile(edits []seed.Edit, opts ...Option) error

OpenFile writes an HTML page containing edits to a temporary file and opens it in a browser.

func OpenHTTP

func OpenHTTP(ctx context.Context, addr string, edits []seed.Edit, opts ...Option) error

OpenHTTP starts a local HTTP server at addr and opens an HTML page containing edits in a browser. This is fairly complicated but it can be convenient if the browser doesn't have direct filesystem access (e.g. the server is running in a Chrome OS VM), and I think that a fixed host:port may be needed in order to permanently tell Chrome to avoid blocking popups.

func Write

func Write(w io.Writer, edits []seed.Edit, opts ...Option) error

Write writes an HTML page containing the supplied edits to w.

Types

type EditInfo

type EditInfo struct {
	Desc   string      `json:"desc"`
	URL    string      `json:"url"`    // includes params iff GET
	Params []paramInfo `json:"params"` // includes params iff POST
}

EditInfo is a version of seed.Edit used in HTML pages. It's used both for passing edits to pageTmpl in CLI mode and for returning edits via XHRs when running in server mode.

func NewEditInfo

func NewEditInfo(edit seed.Edit, serverURL string) (*EditInfo, error)

NewEditInfo converts a seed.Edit into an EditInfo struct.

func NewEditInfos

func NewEditInfos(edits []seed.Edit, serverURL string) ([]*EditInfo, error)

NewEditInfos calls NewEditInfo for each of the supplied edits.

type Option

type Option func(*config)

Option can be passed to configure the page.

func ServerURL

func ServerURL(u string) Option

ServerURL sets the base MusicBrainz server URL, e.g. "https://musicbrainz.org" or "https://test.musicbrainz.org".

func Version

func Version(v string) Option

Version sets an optional yambs version to include in the page.

Jump to

Keyboard shortcuts

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