Documentation ¶
Overview ¶
Package render generates HTML pages listing edits.
Index ¶
- func OpenFile(ctx context.Context, edits []seed.Edit, opts ...Option) error
- func OpenHTTP(ctx context.Context, addr string, edits []seed.Edit, opts ...Option) error
- func TransformTS(ts, fn string, minify bool) (string, error)
- func Write(w io.Writer, edits []seed.Edit, opts ...Option) error
- type EditInfo
- type Option
- type Stream
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenFile ¶
OpenFile writes an HTML page containing edits to a temporary file and opens it in a browser.
func OpenHTTP ¶
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 TransformTS ¶ added in v0.1.11
TransformTS transpiles the supplied TypeScript code from the named file to JavaScript.
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 indexTmpl in CLI mode and for returning edits via XHRs when running in server mode.
func NewEditInfo ¶
NewEditInfo converts a seed.Edit into an EditInfo struct.
type Option ¶
type Option func(*config)
Option can be passed to configure the page.
func MinifyJS ¶ added in v0.1.11
MinifyJS configures whether the page's JavaScript is minified. Minification is performed by default.
func ServerURL ¶
ServerURL sets the base MusicBrainz server URL, e.g. "https://musicbrainz.org" or "https://test.musicbrainz.org".
type Stream ¶ added in v0.1.12
type Stream struct {
// contains filtered or unexported fields
}
Stream writes JSON-serialized messages to a http.ResponseWriter.
func NewStream ¶ added in v0.1.12
func NewStream(rw http.ResponseWriter, nowFunc func() time.Time) *Stream
NewStream returns a new Stream. Data shouldn't be written to rw before (or after) calling this. Non-test code should just pass time.Now as nowFunc.