isokit

package module
v0.0.0-...-781d812 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: BSD-3-Clause Imports: 20 Imported by: 324

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 (
	TemplateRegular = iota
	TemplatePartial
	TemplateLayout
)
View Source
const (
	PlacementAppendTo = iota
	PlacementReplaceInnerContents
	PlacementInsertBefore
)

Variables

View Source
var (
	PrefixNamePartial            = "partials/"
	PrefixNameLayout             = "layouts/"
	TemplateFileExtension        = ".tmpl"
	TemplateFilesPath            = "./templates"
	UseStaticTemplateBundleFile  = false
	UseTemplateBundleFromBuffer  = false
	StaticTemplateBundleFilePath = ""
	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 FetchTemplateBundle

func FetchTemplateBundle(templateSetChannel chan *TemplateSet)

func FetchTemplateBundleWithSuppliedFunctionMap

func FetchTemplateBundleWithSuppliedFunctionMap(templateSetChannel chan *TemplateSet, funcMap template.FuncMap)

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 RegisterStaticAssetsSearchPath

func RegisterStaticAssetsSearchPath(path string)

func ServerRedirect

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

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

func StaticTemplateBundleFileExists

func StaticTemplateBundleFileExists() bool

func TemplateBundleHandler

func TemplateBundleHandler(ts *TemplateSet) http.Handler

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
	// contains filtered or unexported fields
}

func (*Template) GetTemplateType

func (t *Template) GetTemplateType() int8

func (*Template) NameWithPrefix

func (t *Template) NameWithPrefix() string

func (*Template) Render

func (t *Template) Render(params *RenderParams) 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() *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(name, filename string, templateType int8) error

func (*TemplateSet) Bundle

func (t *TemplateSet) Bundle() *TemplateBundle

func (*TemplateSet) GatherCogTemplates

func (t *TemplateSet) GatherCogTemplates(cogTemplatePath string, prefixName string, templateFileExtension string)

func (*TemplateSet) GatherTemplates

func (t *TemplateSet) GatherTemplates()

func (*TemplateSet) ImportTemplatesFromMap

func (t *TemplateSet) ImportTemplatesFromMap(templateMap map[string]string) 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() error

func (*TemplateSet) PersistTemplateBundleToTemplateSetBuffer

func (t *TemplateSet) PersistTemplateBundleToTemplateSetBuffer() error

func (*TemplateSet) Render

func (t *TemplateSet) Render(templateName string, params *RenderParams)

func (*TemplateSet) RestoreTemplateBundleFromDisk

func (t *TemplateSet) RestoreTemplateBundleFromDisk() error

func (*TemplateSet) RestoreTemplateBundleFromTemplateSetBuffer

func (t *TemplateSet) RestoreTemplateBundleFromTemplateSetBuffer() error

Jump to

Keyboard shortcuts

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