isokit

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: BSD-3-Clause Imports: 21 Imported by: 1

README

IsoKit

Go Report Card

The isokit package provides common functionality for developing Isomorphic Go applications.

Installation

IsoKit requires GopherJS.

Get IsoKit

go get -u go.isomorphicgo.org/go/isokit

The Isomorphic Go Project

More information on the benefits of Isomorphic Go applications can be found at the Isomorphic Go Website.

License

IsoKit is licensed under the BSD License. Read the LICENSE file for more information.

Documentation

Overview

Package isokit provides common isomorphic functionality intended to be used in an Isomorphic Go web application.

Index

Constants

View Source
const (
	ServerEnvironment = iota
	WebBrowserEnvironment
)
View Source
const (
	GoRuntime = iota
	JSRuntime
)
View Source
const (
	RouteWithParamsPattern = `/([^/]*)`
	RouteOnlyPrefixPattern = `/`
	RouteSuffixPattern     = `/?$`
)
View Source
const (
	PlacementAppendTo = iota
	PlacementReplaceInnerContents
	PlacementInsertBefore
)

Variables

View Source
var (
	PrefixNamePartial        = "partials/"
	PrefixNameLayout         = "layouts/"
	PrefixNameView           = "views/"
	PrefixNameComponent      = "components/"
	PrefixNameDialog         = "dialogs/"
	PrefixNameForm           = "forms/"
	TemplateFileExtension    = ".tmpl"
	ShouldBundleStaticAssets = true
)
View Source
var CogStaticAssetsSearchPaths []string
View Source
var ShouldMinifyStaticAssets bool
View Source
var StaticAssetsPath string
View Source
var (
	WebAppRoot = ""
)

Functions

func BundleStaticAssets

func BundleStaticAssets()

func ClientRedirect

func ClientRedirect(destinationURL string)

ClientRedirect performs a redirect when operating on the client-side.

func FormValue

func FormValue(fp *FormParams, key string) string

func GopherjsScriptHandler

func GopherjsScriptHandler(webAppRoot string) http.Handler

func GopherjsScriptMapHandler

func GopherjsScriptMapHandler(webAppRoot string) http.Handler

func OperatingEnvironment

func OperatingEnvironment() int

func OperatingRuntime

func OperatingRuntime() int

func Redirect

func Redirect(params *RedirectParams) error

func ServerRedirect

func ServerRedirect(w http.ResponseWriter, r *http.Request, destinationURL string)

ServerRedirect performs a redirect when operating on the server-side.

Types

type BasicForm

type BasicForm struct {
	// contains filtered or unexported fields
}

func (*BasicForm) ClearErrors

func (c *BasicForm) ClearErrors()

func (*BasicForm) DisplayErrors

func (c *BasicForm) DisplayErrors()

func (*BasicForm) Errors

func (c *BasicForm) Errors() map[string]string

func (*BasicForm) Fields

func (c *BasicForm) Fields() map[string]string

func (*BasicForm) FormParams

func (c *BasicForm) FormParams() *FormParams

func (*BasicForm) GetFieldValue

func (c *BasicForm) GetFieldValue(key string) string

func (*BasicForm) PopulateFields

func (c *BasicForm) PopulateFields()

func (*BasicForm) PrefillFields

func (c *BasicForm) PrefillFields() []string

func (*BasicForm) RegenerateErrors

func (c *BasicForm) RegenerateErrors()

func (*BasicForm) SetError

func (c *BasicForm) SetError(key string, message string)

func (*BasicForm) SetErrors

func (c *BasicForm) SetErrors(errors map[string]string)

func (*BasicForm) SetFields

func (c *BasicForm) SetFields(fields map[string]string)

func (*BasicForm) SetFormParams

func (c *BasicForm) SetFormParams(formParams *FormParams)

func (*BasicForm) SetPrefillFields

func (c *BasicForm) SetPrefillFields(prefillFields []string)

type Form

type Form interface {
	Validate() bool
	Fields() map[string]string
	Errors() map[string]string
	FormParams() *FormParams
	PrefillFields()
	SetFields(fields map[string]string)
	SetErrors(errors map[string]string)
	SetFormParams(formParams *FormParams)
	SetPrefillFields(prefillFields []string)
}

type FormParams

type FormParams struct {
	FormElement                *dom.HTMLFormElement
	ResponseWriter             http.ResponseWriter
	Request                    *http.Request
	UseFormFieldsForValidation bool
	FormFields                 map[string]string
}

type Handler

type Handler interface {
	ServeRoute(context.Context)
}

type HandlerFunc

type HandlerFunc func(context.Context)

func (HandlerFunc) ServeRoute

func (f HandlerFunc) ServeRoute(ctx context.Context)

type OperatingDetails

type OperatingDetails struct {
	Environment int
	Runtime     int
}

type RedirectParams

type RedirectParams struct {
	ResponseWriter http.ResponseWriter
	Request        *http.Request
	URL            string
}

type RenderParams

type RenderParams struct {
	Data                          interface{}
	Writer                        io.Writer
	Element                       dom.Element
	Disposition                   int8
	Attributes                    map[string]string
	ShouldPopulateRenderedContent bool
	RenderedContent               string
	ShouldSkipFinalRenderStep     bool
	PageTitle                     string
}

type Route

type Route struct {
	// contains filtered or unexported fields
}

func NewRoute

func NewRoute(path string, handler HandlerFunc) *Route

type RouteVarsKey

type RouteVarsKey string

type Router

type Router struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) Handle

func (r *Router) Handle(path string, handler Handler) *Route

func (*Router) HandleFunc

func (r *Router) HandleFunc(path string, handler HandlerFunc) *Route

func (*Router) Listen

func (r *Router) Listen()
func (r *Router) RegisterLinks(querySelector string)

type Template

type Template struct {
	*template.Template
	Namespace string
	// contains filtered or unexported fields
}

func (*Template) GetTemplateType

func (t *Template) GetTemplateType() TemplateType

func (*Template) NameWithNamespace

func (t *Template) NameWithNamespace() string

func (*Template) NameWithPrefix

func (t *Template) NameWithPrefix() string

func (*Template) Render

func (t *Template) Render(params *RenderParams) error

func (*Template) RenderSimple

func (t *Template) RenderSimple(params interface{}) ([]byte, error)

func (*Template) RenderTemplateOnClient

func (t *Template) RenderTemplateOnClient(params *RenderParams)

func (*Template) RenderTemplateOnServer

func (t *Template) RenderTemplateOnServer(params *RenderParams)

type TemplateBundle

type TemplateBundle struct {
	// contains filtered or unexported fields
}

func NewTemplateBundle

func NewTemplateBundle(namespace string) *TemplateBundle

func (*TemplateBundle) Items

func (t *TemplateBundle) Items() map[string]string

type TemplateSet

type TemplateSet struct {
	Funcs template.FuncMap

	TemplateFilesPath string
	// contains filtered or unexported fields
}

func NewTemplateSet

func NewTemplateSet() *TemplateSet

func (*TemplateSet) AddTemplateFile

func (t *TemplateSet) AddTemplateFile(namespace string, templateType TemplateType, templateName string, filename string) error

func (*TemplateSet) Bundle

func (t *TemplateSet) Bundle(namespace string) (*TemplateBundle, error)

func (*TemplateSet) GatherTemplatesFromPackrBox

func (t *TemplateSet) GatherTemplatesFromPackrBox(namespace string, box *packr.Box, path string) error

func (*TemplateSet) GatherTemplatesFromPath

func (t *TemplateSet) GatherTemplatesFromPath(namespace string, templatesPath string) error

func (*TemplateSet) GetTemplateBundleBinary

func (t *TemplateSet) GetTemplateBundleBinary() []byte

func (*TemplateSet) ImportTemplatesFromMap

func (t *TemplateSet) ImportTemplatesFromMap(namespace string, bundle *TemplateBundle) error

func (*TemplateSet) MakeAllAssociations

func (t *TemplateSet) MakeAllAssociations() error

func (*TemplateSet) Members

func (t *TemplateSet) Members() map[string]*Template

func (*TemplateSet) PersistTemplateBundleToDisk

func (t *TemplateSet) PersistTemplateBundleToDisk(bundlePath string) error

func (*TemplateSet) Render

func (t *TemplateSet) Render(templateURI string, params *RenderParams) error

func (*TemplateSet) RenderSimple

func (t *TemplateSet) RenderSimple(templateURI string, params interface{}) ([]byte, error)

func (*TemplateSet) RestoreTemplateBundleFromBinary

func (t *TemplateSet) RestoreTemplateBundleFromBinary(bundle []byte) error

func (*TemplateSet) RestoreTemplateBundleFromDisk

func (t *TemplateSet) RestoreTemplateBundleFromDisk(bundlePath string) error

type TemplateType

type TemplateType = int8
const (
	TemplateRegular   TemplateType = 0x00
	TemplatePartial   TemplateType = 0x01
	TemplateView      TemplateType = 0x02
	TemplateComponent TemplateType = 0x03
	TemplateDialog    TemplateType = 0x04
	TemplateForm      TemplateType = 0x05
	TemplateLayout    TemplateType = 0x06
)

Jump to

Keyboard shortcuts

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