model

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Host                 = MultisiteStrategy("host")
	HostByLocale         = MultisiteStrategy("host-by-locale")
	HostWithPath         = MultisiteStrategy("host-with-path")
	HostWithPathByLocale = MultisiteStrategy("host-with-path-by-locale")
)
View Source
const (
	MetaName     = MetaType("name")
	MetaEquiv    = MetaType("http-equiv")
	MetaProperty = MetaType("property")
)
View Source
const (
	PageCMS            = "_page_cms"
	PageAliasPrefix    = "_page_alias_"
	PageInternalPrefix = "_page_internal_"
	PageInternalCreate = PageInternalPrefix + "create"
	PageErrorPrefix    = PageInternalPrefix + "error_"
	PageErrorInternal  = PageErrorPrefix + "internal"
	PageError4xx       = PageErrorPrefix + "4xx"
	PageError5xx       = PageErrorPrefix + "5xx"
)
View Source
const (
	TemplateDB = TemplateType("db")
	TemplateFS = TemplateType("fs")
)

Variables

View Source
var (
	ErrPasswordIsEmpty  = errors.New("password: is empty")
	ErrPasswordNotValid = errors.New("password: is not valid")
	ErrPasswordShort    = errors.New("password: is too short, must be at least 8 characters long")
	ErrPasswordLong     = errors.New("password: is too long, must be at most 64 characters long")
)
View Source
var ErrOTPNotValid = errors.New("otp: is not valid")
View Source
var TemplateTypes = []TemplateType{TemplateDB, TemplateFS}

Functions

This section is empty.

Types

type Admin

type Admin struct {
	ID       int64     `json:"id,omitempty" required:"true"`
	Avatar   string    `json:"avatar,omitempty" required:"true"`
	Email    string    `json:"email,omitempty" required:"true" format:"email"`
	Roles    []string  `json:"roles,omitempty" required:"true"`
	Salt     string    `json:"_" hidden:"true"`
	Password Password  `json:"-" hidden:"true"`
	OTP      OTP       `json:"-" hidden:"true"`
	Created  time.Time `json:"created,omitempty" required:"true"`
	Updated  time.Time `json:"updated,omitempty" required:"true"`
}

func (Admin) GetID

func (a Admin) GetID() int64

func (Admin) OTPKey

func (a Admin) OTPKey(issuer string) (string, error)

func (Admin) ValidateOTP

func (a Admin) ValidateOTP(password string) error

func (Admin) ValidatePassword

func (a Admin) ValidatePassword(password string) error

func (Admin) WithRandomSalt

func (a Admin) WithRandomSalt() Admin

type Configuration

type Configuration struct {
	Debug                 bool              `json:"debug,omitempty" yaml:"debug,omitempty" required:"true"`
	Multisite             MultisiteStrategy `` /* 137-byte string literal not displayed */
	FallbackLocale        string            `json:"fallbackLocale,omitempty" yaml:"fallbackLocale,omitempty" required:"false"`
	IgnoreRequestPatterns []string          `json:"ignoreRequestPatterns,omitempty" yaml:"ignoreRequestPatterns,omitempty" required:"false"`
	IgnoreRequestURIs     []string          `json:"ignoreRequestURIs,omitempty" yaml:"ignoreRequestURIs,omitempty" required:"false"`
	CatchErrors           map[string][]int  `json:"catchErrors,omitempty" yaml:"catchErrors,omitempty" required:"false"`
	Additional            map[string]string `json:"additional,omitempty" yaml:"additional,omitempty" required:"false"`
}

func NewConfiguration

func NewConfiguration() Configuration

func (Configuration) IgnorePattern

func (c Configuration) IgnorePattern(pattern string) bool

func (Configuration) IgnoreURI

func (c Configuration) IgnoreURI(uri string) bool

func (Configuration) With

type Menu struct {
	ID      int64     `json:"id,omitempty" yaml:"id,omitempty" required:"true"`
	NodeID  *int64    `json:"nodeID,omitempty" yaml:"nodeID,omitempty" required:"false"`
	Name    string    `json:"name,omitempty" yaml:"name,omitempty" required:"true"`
	Handle  string    `json:"handle,omitempty" yaml:"handle,omitempty" required:"true"`
	Enabled bool      `json:"enabled,omitempty" yaml:"enabled,omitempty" required:"true"`
	Created time.Time `json:"created,omitempty" yaml:"created,omitempty" required:"true"`
	Updated time.Time `json:"updated,omitempty" yaml:"updated,omitempty" required:"true"`
	Node    *Node     `json:"-" yaml:"-"`
}
func (m Menu) GetID() int64
func (m Menu) String() string
func (m Menu) WithFixedHandle() Menu

type Meta

type Meta struct {
	Type    MetaType `json:"type,omitempty" yaml:"type,omitempty" required:"true" enum:"name,http-equiv,property"`
	Key     string   `json:"key,omitempty" yaml:"key,omitempty" required:"true"`
	Content string   `json:"content,omitempty" yaml:"content,omitempty" required:"false"`
}

func (Meta) Equal

func (m Meta) Equal(another Meta) bool

type MetaType

type MetaType string

func (MetaType) IsZero

func (t MetaType) IsZero() bool

func (MetaType) String

func (t MetaType) String() string

type MultisiteStrategy

type MultisiteStrategy string

func (MultisiteStrategy) IsZero

func (t MultisiteStrategy) IsZero() bool

func (MultisiteStrategy) String

func (t MultisiteStrategy) String() string

type Node

type Node struct {
	ID                 int64             `json:"id,omitempty" yaml:"id,omitempty" required:"true"`
	ParentID           int64             `json:"parentID,omitempty" yaml:"parentID,omitempty" required:"true"`
	Name               string            `json:"name,omitempty" yaml:"name,omitempty" required:"true"`
	Label              string            `json:"label,omitempty" yaml:"label,omitempty" required:"false"`
	URI                string            `json:"uri,omitempty" yaml:"uri,omitempty" required:"false"`
	Path               string            `json:"path,omitempty" yaml:"path,omitempty" required:"true"`
	Level              int               `json:"level,omitempty" yaml:"level,omitempty" required:"false"`
	Position           int               `json:"position,omitempty" yaml:"position,omitempty" required:"false"`
	DisplayChildren    bool              `json:"displayChildren,omitempty" yaml:"displayChildren,omitempty" required:"false"`
	Display            bool              `json:"display,omitempty" yaml:"display,omitempty" required:"false"`
	Attributes         map[string]string `json:"attributes,omitempty" yaml:"attributes,omitempty" required:"false"`
	LinkAttributes     map[string]string `json:"linkAttributes,omitempty" yaml:"linkAttributes,omitempty" required:"false"`
	ChildrenAttributes map[string]string `json:"childrenAttributes,omitempty" yaml:"childrenAttributes,omitempty" required:"false"`
	LabelAttributes    map[string]string `json:"labelAttributes,omitempty" yaml:"labelAttributes,omitempty" required:"false"`
	Metadata           map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty" required:"false"`
	Created            time.Time         `json:"created,omitempty" yaml:"created,omitempty" required:"true"`
	Updated            time.Time         `json:"updated,omitempty" yaml:"updated,omitempty" required:"true"`
	Current            bool              `json:"-" yaml:"-"`
	Ancestor           bool              `json:"-" yaml:"-"`
	Parent             *Node             `json:"-" yaml:"-"`
	Menu               *Menu             `json:"-" yaml:"-"`
	Children           []*Node           `json:"-" yaml:"-"`
}

func (Node) GetID

func (n Node) GetID() int64

func (Node) HasChildren

func (n Node) HasChildren() bool

func (Node) IsRoot

func (n Node) IsRoot() bool

func (Node) String

func (n Node) String() string

func (Node) WithFixedPathAndLevel

func (n Node) WithFixedPathAndLevel() Node

type OTP

type OTP [otpSize]byte

func MustNewOTP

func MustNewOTP() OTP

func NewOTP

func NewOTP() (otp OTP, err error)

func (OTP) Compare

func (otp OTP) Compare(other OTP) int

func (OTP) IsZero

func (otp OTP) IsZero() bool

func (OTP) String

func (otp OTP) String() string

func (OTP) Validate

func (otp OTP) Validate(password string) error

type Page

type Page struct {
	ID         int64             `json:"id,omitempty" yaml:"id,omitempty" required:"true"`
	SiteID     int64             `json:"siteID,omitempty" yaml:"siteID,omitempty" required:"true"`
	ParentID   *int64            `json:"parentID,omitempty" yaml:"parentID,omitempty" required:"false"`
	Name       string            `json:"name,omitempty" yaml:"name,omitempty" required:"true"`
	Title      string            `json:"title,omitempty" yaml:"title,omitempty" required:"false"`
	Pattern    string            `json:"pattern,omitempty" yaml:"pattern,omitempty" required:"true"`
	Alias      string            `json:"alias,omitempty" yaml:"alias,omitempty" required:"false"`
	Slug       string            `json:"slug,omitempty" yaml:"slug,omitempty" required:"false"`
	URL        string            `json:"url,omitempty" yaml:"url,omitempty" required:"false"`
	CustomURL  string            `json:"customURL,omitempty" yaml:"customURL,omitempty" required:"false"`
	Javascript string            `json:"javascript,omitempty" yaml:"javascript,omitempty" required:"false"`
	Stylesheet string            `json:"stylesheet,omitempty" yaml:"stylesheet,omitempty" required:"false"`
	Template   string            `json:"template,omitempty" yaml:"template,omitempty" required:"true"`
	Decorate   bool              `json:"decorate,omitempty" yaml:"decorate,omitempty" required:"false"`
	Position   int               `json:"position,omitempty" yaml:"position,omitempty" required:"false"`
	Headers    map[string]string `json:"headers,omitempty" yaml:"headers,omitempty" required:"false"`
	Metas      []Meta            `json:"metas,omitempty" yaml:"metas,omitempty" required:"false"`
	Metadata   map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty" required:"false"`
	Created    time.Time         `json:"created,omitempty" yaml:"created,omitempty" required:"true"`
	Updated    time.Time         `json:"updated,omitempty" yaml:"updated,omitempty" required:"true"`
	Published  *time.Time        `json:"published,omitempty" yaml:"published,omitempty" required:"false"`
	Expired    *time.Time        `json:"expired,omitempty" yaml:"expired,omitempty" required:"false"`
	Site       *Site             `json:"-" yaml:"-"`
	Parent     *Page             `json:"-" yaml:"-"`
	Children   []Page            `json:"-" yaml:"-"`
}

func (Page) GetID

func (p Page) GetID() int64

func (Page) IsCMS

func (p Page) IsCMS() bool

func (Page) IsDynamic

func (p Page) IsDynamic() bool

func (Page) IsEnabled

func (p Page) IsEnabled(now time.Time) bool

func (Page) IsError

func (p Page) IsError() bool

func (Page) IsHybrid

func (p Page) IsHybrid() bool

func (Page) IsInternal

func (p Page) IsInternal() bool

func (Page) String

func (p Page) String() string

func (Page) WithAlias

func (p Page) WithAlias(alias string) Page

func (Page) WithError

func (p Page) WithError(pattern string) Page

func (Page) WithFixedURL

func (p Page) WithFixedURL() Page

func (Page) WithInternal

func (p Page) WithInternal(pattern string) Page

type Password

type Password []byte

func NewPassword

func NewPassword(password string) (Password, error)

func (Password) IsZero

func (p Password) IsZero() bool

func (Password) String

func (p Password) String() string

func (Password) Validate

func (p Password) Validate(password string) error

type Site

type Site struct {
	ID           int64             `json:"id,omitempty" yaml:"id,omitempty" required:"true"`
	Name         string            `json:"name,omitempty" yaml:"name,omitempty" required:"true"`
	Title        string            `json:"title,omitempty" yaml:"title,omitempty" required:"false"`
	Separator    string            `json:"separator,omitempty" yaml:"separator,omitempty" required:"true"`
	Host         string            `json:"host,omitempty" yaml:"host,omitempty" required:"true"`
	Locale       string            `json:"locale,omitempty" yaml:"locale,omitempty" required:"false"`
	RelativePath string            `json:"relativePath,omitempty" yaml:"relativePath,omitempty" required:"false"`
	IsDefault    bool              `json:"isDefault,omitempty" yaml:"isDefault,omitempty" required:"false"`
	Javascript   string            `json:"javascript,omitempty" yaml:"javascript,omitempty" required:"false"`
	Stylesheet   string            `json:"stylesheet,omitempty" yaml:"stylesheet,omitempty" required:"false"`
	Metas        []Meta            `json:"metas,omitempty" yaml:"metas,omitempty" required:"false"`
	Metadata     map[string]string `json:"metadata,omitempty" yaml:"metadata,omitempty" required:"false"`
	Created      time.Time         `json:"created,omitempty" yaml:"created,omitempty" required:"true"`
	Updated      time.Time         `json:"updated,omitempty" yaml:"updated,omitempty" required:"true"`
	Published    *time.Time        `json:"published,omitempty" yaml:"published,omitempty" required:"false"`
	Expired      *time.Time        `json:"expired,omitempty" yaml:"expired,omitempty" required:"false"`
	// contains filtered or unexported fields
}

func (Site) GetID

func (s Site) GetID() int64

func (Site) IsEnabled

func (s Site) IsEnabled(now time.Time) bool

func (Site) IsLocalhost

func (s Site) IsLocalhost() bool

func (Site) String

func (s Site) String() string

func (Site) URL

func (s Site) URL() string

func (Site) WithHost

func (s Site) WithHost(scheme, host string) Site

type Template

type Template struct {
	ID      int64        `json:"id,omitempty" yaml:"id,omitempty" required:"true"`
	Name    string       `json:"name,omitempty" yaml:"name,omitempty" required:"true"`
	Content string       `json:"content,omitempty" yaml:"content,omitempty" required:"false"`
	Type    TemplateType `json:"type,omitempty" yaml:"type,omitempty" required:"true" enum:"db,fs"`
	Enabled bool         `json:"enabled,omitempty" yaml:"enabled,omitempty" required:"false"`
	Created time.Time    `json:"created,omitempty" yaml:"created,omitempty" required:"true"`
	Updated time.Time    `json:"updated,omitempty" yaml:"updated,omitempty" required:"true"`
}

func (Template) Changed

func (t Template) Changed() time.Time

func (Template) Code

func (t Template) Code() []byte

func (Template) GetID

func (t Template) GetID() int64

func (Template) String

func (t Template) String() string

type TemplateType

type TemplateType string

func (TemplateType) IsZero

func (t TemplateType) IsZero() bool

func (TemplateType) String

func (t TemplateType) String() string

Jump to

Keyboard shortcuts

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