server

package
v0.0.0-...-df0e004 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2014 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package server contains helper functions and structs for the frontend server.

Package server contains helper functions and structs for the frontend server.

Index

Constants

This section is empty.

Variables

View Source
var ExtractTypeOptions []*FormOption
View Source
var FormTmpl = templates.Parse("templates/form.html")
View Source
var PleaseSelect = &FormOption{
	Key: i18n.Key("Please select"),
}

Functions

func Call

func Call(context *frontend.Context, f func(io.Writer, *TmplArgs) error) (answer []byte, err error)

func SetLanguageList

func SetLanguageList(list []language.Code) error

Types

type FieldType

type FieldType string
const (
	InputText     FieldType = "input"
	InputTextArea FieldType = "textarea"
	InputPassword FieldType = "password"
	InputSelect   FieldType = "select"
)

type Form

type Form struct {
	Header    i18n.Key
	Error     i18n.Key
	Hint      i18n.Key
	Fields    []*FormField
	Extra     i18n.Key
	Submit    i18n.Key
	Class     string // css class
	MustLogIn bool
}

func (*Form) Apply

func (f *Form) Apply(c *frontend.Context)

type FormField

type FormField struct {
	Name          string
	Type          FieldType
	Property      i18n.Key
	Value         string        // optional
	Error         i18n.Key      // optional
	Hint          i18n.Key      // optional
	Link          *Link         // optional
	InputTemplate FieldType     // optional
	Options       []*FormOption // mandatory only with InputTemplate==InputSelect
}

type FormOption

type FormOption struct {
	Value string
	Key   i18n.Key `json:",omitempty"` // preferred over Text
	Text  string   `json:",omitempty"` // only used if no key provided
}
type Link struct {
	Href string
	Text i18n.Key
}

type TmplArgs

type TmplArgs struct {
	Data                map[string]interface{}
	Css                 string // "extract" (default), "form", or other .scss file
	Angular             bool   // angular script
	AngularLocal        bool   // angular local instead of CDN
	Context             *frontend.Context
	Description         i18n.Key
	DescriptionLitteral string // fallback if i18n.Key is not defined
	localizer.Localizer
}

func GetTmplArgs

func GetTmplArgs(context *frontend.Context) (*TmplArgs, error)

func (*TmplArgs) AngularVersion

func (a *TmplArgs) AngularVersion() string

func (*TmplArgs) CanonicalUrl

func (a *TmplArgs) CanonicalUrl() string

func (*TmplArgs) GetLanguage

func (args *TmplArgs) GetLanguage(code language.Code) string

func (*TmplArgs) GetLanguageOptions

func (args *TmplArgs) GetLanguageOptions() ([]*FormOption, error)

func (*TmplArgs) LoggedIn

func (a *TmplArgs) LoggedIn() bool

func (*TmplArgs) Nest

func (a *TmplArgs) Nest(data interface{}) *nestedArgs

func (*TmplArgs) Title

func (a *TmplArgs) Title() (string, error)

func (*TmplArgs) UserName

func (a *TmplArgs) UserName() string

Jump to

Keyboard shortcuts

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