widget

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

package widget: Widget is inner representation of functionality, that connects web and server part.

Index

Constants

This section is empty.

Variables

View Source
var TemplateRegistry = make(map[string]*template.Template) // typename => html.template
View Source
var TypeRegistry = make(map[string]reflect.Type) // typename => widgettype

Functions

func InitChildren added in v1.0.3

func InitChildren(ctx context.Context, w Widget) error

TODO may be VisitChildren()

func MustSurvive

func MustSurvive(err error) struct{}

func RegisterWidgetType

func RegisterWidgetType(w Widget, tmplstring string) error

Types

type BaseWidget

type BaseWidget struct {
	Config
	Widget Widget         // link to actual widget object
	Chan   chan string    // channel to interact with visual representation
	Log    zerolog.Logger // logger for specified widget
}

func (*BaseWidget) Base

func (w *BaseWidget) Base() *BaseWidget

func (*BaseWidget) Children added in v1.0.3

func (w *BaseWidget) Children() map[string]Widget

func (*BaseWidget) Dispatch added in v1.0.2

func (w *BaseWidget) Dispatch(ctx context.Context, event string) error

Consume websocket message in separate goroutine

func (*BaseWidget) Errorf

func (w *BaseWidget) Errorf(f string, args ...any) error

func (*BaseWidget) Init

func (w *BaseWidget) Init(ctx context.Context) error

func (*BaseWidget) InitStage1 added in v1.0.3

func (w *BaseWidget) InitStage1(ctx context.Context) error

func (*BaseWidget) RenderTo

func (w *BaseWidget) RenderTo(ctx context.Context, wr io.Writer) error

func (*BaseWidget) Send

func (w *BaseWidget) Send(msg string) error

func (*BaseWidget) SendChan added in v1.0.2

func (w *BaseWidget) SendChan() chan string

type Button

type Button struct {
	BaseWidget
	Args ButtonArgs
}

func (*Button) Dispatch added in v1.0.2

func (w *Button) Dispatch(ctx context.Context, event string) error

TODO 🔴REFACTOR!!!!🔴 yes, we can!!!🟢

func (*Button) Init

func (w *Button) Init(context.Context) error

type ButtonArgs

type ButtonArgs struct {
	Action *struct {
		PlaySound   string
		File        string
		Html        string
		CommandLine string
	}
}

type Clock

type Clock struct {
	BaseWidget
	Format string
}

func (*Clock) Init

func (w *Clock) Init(ctx context.Context) error

type Config

type Config struct {
	Name    string // Unique widget id
	Type    string // Type of widget class
	Caption string // Text to render in widget if it is a button or something like this
	Style   string // css style for this widget only
	Args    any    // Widget specific config
}

type Container added in v1.0.2

type Container struct {
	BaseWidget

	// registry part
	Map   map[string]Widget // contained widgets
	Order []string          // order which widgets was in config
	Len   int               // count of widgets
}

func (*Container) Children added in v1.0.3

func (w *Container) Children() map[string]Widget

func (*Container) Dispatch added in v1.0.2

func (w *Container) Dispatch(ctx context.Context, b string) error

func (*Container) Init added in v1.0.2

func (w *Container) Init(ctx context.Context) error

type Eval added in v1.0.3

type Eval struct {
	BaseWidget
}

func (*Eval) Dispatch added in v1.0.3

func (w *Eval) Dispatch(ctx context.Context, event string) error

type HrBr

type HrBr struct {
	BaseWidget
}

type Label

type Label struct {
	BaseWidget
}

type ObsRecord

type ObsRecord struct {
	BaseWidget
}

func (*ObsRecord) Dispatch added in v1.0.2

func (w *ObsRecord) Dispatch(ctx context.Context, event string) error

func (*ObsRecord) Init

func (w *ObsRecord) Init(ctx context.Context) error

type ObsRecordInfo

type ObsRecordInfo struct {
	Rec    bool
	Pause  bool
	Length string
}

type ObsStream

type ObsStream struct {
	BaseWidget
}

func (*ObsStream) Init

func (w *ObsStream) Init(ctx context.Context) error

type ObsStreamInfo

type ObsStreamInfo struct {
	Active     bool
	Reconnect  bool
	Congestion float64
	Length     string
}

type RawHTML added in v1.0.3

type RawHTML string

func (RawHTML) String added in v1.0.3

func (r RawHTML) String() string

type Scenes added in v1.0.2

type Scenes struct {
	BaseWidget
}

func (*Scenes) Dispatch added in v1.0.2

func (w *Scenes) Dispatch(ctx context.Context, event string) error

func (*Scenes) Init added in v1.0.2

func (w *Scenes) Init(ctx context.Context) error

func (*Scenes) SendScene added in v1.0.2

func (w *Scenes) SendScene(ctx context.Context, o *obs.Obs) error

type Widget

type Widget interface {
	Init(ctx context.Context) error                   // init widget with config in it's base
	Dispatch(ctx context.Context, event string) error // consume one event from Websocket
	RenderTo(ctx context.Context, wr io.Writer) error // render visual representation
	SendChan() chan string                            // get channel where out messages is
	Send(event string) error                          // Send something to all my visual representations
	Base() *BaseWidget                                // access to common data
	Children() map[string]Widget                      // get all children
}

func New

func New(ctx context.Context, cfga any) Widget

type Youtube added in v1.0.3

type Youtube struct {
	BaseWidget
	StartChan chan struct{}
	PerPage   int `default:"10"`
	Period    int `default:"2"`
}

func (*Youtube) Dispatch added in v1.0.3

func (w *Youtube) Dispatch(ctx context.Context, event string) error

func (*Youtube) Init added in v1.0.3

func (w *Youtube) Init(ctx context.Context) error

Jump to

Keyboard shortcuts

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