Documentation ¶
Index ¶
- Constants
- func BuildTags(name string, id int64, data ...string) []string
- func BuildTagsByIDs(name string, data ...int64) []string
- func PageAfterSave(storage PageStorage) func(context.Context, *SaveEvent[*Page]) error
- func PageBeforeSave(storage PageStorage) func(context.Context, *SaveEvent[*Page]) error
- type DeleteEvent
- type EventPageStorage
- func (s *EventPageStorage) FindByPageAlias(ctx context.Context, siteID int64, pageAlias string, date time.Time) (Page, error)
- func (s *EventPageStorage) FindByParentID(ctx context.Context, parentID int64, date time.Time) ([]Page, error)
- func (s *EventPageStorage) FindByRouteName(ctx context.Context, siteID int64, routeName string, date time.Time) (Page, error)
- func (s *EventPageStorage) FindByURL(ctx context.Context, siteID int64, url string, date time.Time) (Page, error)
- type EventSiteStorage
- type EventStorage
- func (s *EventStorage[T]) Create(ctx context.Context, model *T) error
- func (s *EventStorage[T]) Delete(ctx context.Context, ids ...int64) error
- func (s *EventStorage[T]) Find(ctx context.Context, criteria *cr.Criteria) ([]T, error)
- func (s *EventStorage[T]) FindAndCount(ctx context.Context, criteria *cr.Criteria) ([]T, int, error)
- func (s *EventStorage[T]) FindByID(ctx context.Context, id int64) (T, error)
- func (s *EventStorage[T]) Update(ctx context.Context, model *T) error
- type EventTemplateStorage
- type FindA0Event
- type FindA1Event
- type FindA2Event
- type FindA3Event
- type FindAndCountEvent
- type FindByIDEvent
- type FindEvent
- type Hook
- type Meta
- type MetaType
- type Page
- func (p *Page) FixURL()
- func (p *Page) IsCMS() bool
- func (p *Page) IsDynamic() bool
- func (p *Page) IsEnabled(now time.Time) bool
- func (p *Page) IsError() bool
- func (p *Page) IsHybrid() bool
- func (p *Page) IsInternal() bool
- func (p *Page) SetAlias(pageAlias string)
- func (p *Page) SetError(routeName string)
- func (p *Page) SetInternal(routeName string)
- func (p *Page) String() string
- type PageDefaults
- type PageService
- type PageStorage
- type SaveEvent
- type Site
- type SiteService
- type SiteStorage
- type Storage
- type StubHook
- type Template
- type TemplateService
- type TemplateStorage
- type TemplateType
Constants ¶
View Source
const ( PageRouteCMS = "page_slug" PageAliasPrefix = "_page_alias_" PageInternalPrefix = "_page_internal_" PageErrorPrefix = PageInternalPrefix + "error_" )
Variables ¶
This section is empty.
Functions ¶
func BuildTagsByIDs ¶
func PageAfterSave ¶
func PageBeforeSave ¶
Types ¶
type DeleteEvent ¶
type DeleteEvent struct { IDs []int64 // contains filtered or unexported fields }
func NewDeleteEvent ¶
func NewDeleteEvent(ids []int64, tags ...string) *DeleteEvent
func (*DeleteEvent) Tags ¶
func (e *DeleteEvent) Tags() []string
type EventPageStorage ¶
type EventPageStorage struct { *EventStorage[Page] BeforeFindByURL Hook[*FindA3Event[int64, string, time.Time, Page]] AfterFindByURL Hook[*FindA3Event[int64, string, time.Time, Page]] BeforeFindByRouteName Hook[*FindA3Event[int64, string, time.Time, Page]] AfterFindByRouteName Hook[*FindA3Event[int64, string, time.Time, Page]] BeforeFindByPageAlias Hook[*FindA3Event[int64, string, time.Time, Page]] AfterFindByPageAlias Hook[*FindA3Event[int64, string, time.Time, Page]] BeforeFindByParentID Hook[*FindA2Event[int64, time.Time, []Page]] AfterFindByParentID Hook[*FindA2Event[int64, time.Time, []Page]] // contains filtered or unexported fields }
func NewEventPageStorage ¶
func NewEventPageStorage(storage PageStorage) *EventPageStorage
func (*EventPageStorage) FindByPageAlias ¶
func (*EventPageStorage) FindByParentID ¶
func (*EventPageStorage) FindByRouteName ¶
type EventSiteStorage ¶
type EventSiteStorage struct { *EventStorage[Site] BeforeFindByHosts Hook[*FindA2Event[[]string, time.Time, []Site]] AfterFindByHosts Hook[*FindA2Event[[]string, time.Time, []Site]] BeforeFindAll Hook[*FindA0Event[[]Site]] AfterFindAll Hook[*FindA0Event[[]Site]] // contains filtered or unexported fields }
func NewEventSiteStorage ¶
func NewEventSiteStorage(storage SiteStorage) *EventSiteStorage
func (*EventSiteStorage) FindAll ¶
func (s *EventSiteStorage) FindAll(ctx context.Context) ([]Site, error)
func (*EventSiteStorage) FindByHosts ¶
type EventStorage ¶
type EventStorage[T any] struct { Storage[T] SaveEventTags func(*T) []string DeleteEventTags func(ids ...int64) []string BeforeCreate Hook[*SaveEvent[*T]] AfterCreate Hook[*SaveEvent[*T]] BeforeUpdate Hook[*SaveEvent[*T]] AfterUpdate Hook[*SaveEvent[*T]] BeforeDelete Hook[*DeleteEvent] AfterDelete Hook[*DeleteEvent] BeforeFindByID Hook[*FindByIDEvent[T]] AfterFindByID Hook[*FindByIDEvent[T]] BeforeFind Hook[*FindEvent[T]] AfterFind Hook[*FindEvent[T]] BeforeFindAndCount Hook[*FindAndCountEvent[T]] AfterFindAndCount Hook[*FindAndCountEvent[T]] }
func NewEventStorage ¶
func (*EventStorage[T]) Create ¶
func (s *EventStorage[T]) Create(ctx context.Context, model *T) error
func (*EventStorage[T]) Delete ¶
func (s *EventStorage[T]) Delete(ctx context.Context, ids ...int64) error
func (*EventStorage[T]) FindAndCount ¶
type EventTemplateStorage ¶
type EventTemplateStorage struct { *EventStorage[Template] BeforeFindByCode Hook[*FindA2Event[string, time.Time, Template]] AfterFindByCode Hook[*FindA2Event[string, time.Time, Template]] // contains filtered or unexported fields }
func NewEventTemplateStorage ¶
func NewEventTemplateStorage(storage TemplateStorage) *EventTemplateStorage
func (*EventTemplateStorage) FindByCode ¶
type FindA0Event ¶
type FindA0Event[R any] struct { Result R }
type FindA1Event ¶
type FindA1Event[A1, R any] struct { Arg1 A1 Result R }
type FindA2Event ¶
type FindA2Event[A1, A2, R any] struct { Arg1 A1 Arg2 A2 Result R }
type FindA3Event ¶
type FindA3Event[A1, A2, A3, R any] struct { Arg1 A1 Arg2 A2 Arg3 A3 Result R }
type FindAndCountEvent ¶
type FindByIDEvent ¶
type Meta ¶
type Page ¶
type Page struct { ID int64 `json:"id,omitempty"` SiteID int64 `json:"site_id,omitempty"` ParentID *int64 `json:"parent_id,omitempty"` Name string `json:"name,omitempty"` Title string `json:"title,omitempty"` RouteName string `json:"route_name,omitempty"` PageAlias string `json:"page_alias,omitempty"` Slug string `json:"slug,omitempty"` URL string `json:"url,omitempty"` CustomURL string `json:"custom_url,omitempty"` Javascript string `json:"javascript,omitempty"` Stylesheet string `json:"stylesheet,omitempty"` TemplateCode string `json:"template_code,omitempty"` Decorate bool `json:"decorate,omitempty"` Position int `json:"position,omitempty"` RequestMethods []string `json:"request_methods,omitempty"` Headers map[string]string `json:"headers,omitempty"` Site *Site `json:"site,omitempty"` Parent *Page `json:"parent,omitempty"` Children []*Page `json:"children,omitempty"` Metas []Meta `json:"metas,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` Created time.Time `json:"created,omitempty"` Updated time.Time `json:"updated,omitempty"` Published *time.Time `json:"published,omitempty"` Expired *time.Time `json:"expired,omitempty"` }
func (*Page) IsInternal ¶
func (*Page) SetInternal ¶
type PageDefaults ¶
type PageService ¶
type PageService interface { CreateWithDefaults(ctx context.Context, defaults map[string]interface{}) (Page, error) Save(ctx context.Context, page *Page) error GetByID(ctx context.Context, id int64) (Page, error) GetByURL(ctx context.Context, siteID int64, url string) (Page, error) GetByRouteName(ctx context.Context, siteID int64, routeName string) (Page, error) GetByPageAlias(ctx context.Context, siteID int64, pageAlias string) (Page, error) GetChildren(ctx context.Context, parentID int64) ([]Page, error) }
func NewPageService ¶
func NewPageService(storage PageStorage, defaults PageDefaults) PageService
type PageStorage ¶
type SaveEvent ¶
type SaveEvent[T any] struct { Model T // contains filtered or unexported fields }
func NewSaveEvent ¶
type Site ¶
type Site struct { ID int64 `json:"id,omitempty"` Name string `json:"name,omitempty"` Title string `json:"title,omitempty"` Separator string `json:"separator,omitempty"` Host string `json:"host,omitempty"` Locale string `json:"locale,omitempty"` RelativePath string `json:"relative_path,omitempty"` IsDefault bool `json:"is_default,omitempty"` Metas []Meta `json:"metas,omitempty"` Metadata map[string]any `json:"metadata,omitempty"` Created time.Time `json:"created,omitempty"` Updated time.Time `json:"updated,omitempty"` Published *time.Time `json:"published,omitempty"` Expired *time.Time `json:"expired,omitempty"` }
func (Site) IsLocalhost ¶
type SiteService ¶
type SiteService interface { CreateLocalhost() Site Save(ctx context.Context, site *Site) error GetByID(ctx context.Context, id int64) (Site, error) GetByHost(ctx context.Context, host string) ([]Site, error) GetAll(ctx context.Context) ([]Site, error) }
func NewSiteService ¶
func NewSiteService(storage SiteStorage) SiteService
type SiteStorage ¶
type Storage ¶
type Storage[T any] interface { Create(ctx context.Context, model *T) error Update(ctx context.Context, model *T) error Delete(ctx context.Context, ids ...int64) error FindByID(ctx context.Context, id int64) (T, error) Find(ctx context.Context, criteria *cr.Criteria) ([]T, error) FindAndCount(ctx context.Context, criteria *cr.Criteria) ([]T, int, error) }
type Template ¶
type Template struct { ID int64 `json:"id,omitempty"` Code string `json:"code,omitempty"` Content string `json:"content,omitempty"` Type TemplateType `json:"type,omitempty"` Created time.Time `json:"created,omitempty"` Updated time.Time `json:"updated,omitempty"` Published *time.Time `json:"published,omitempty"` Expired *time.Time `json:"expired,omitempty"` }
func (Template) ContentBytes ¶
type TemplateService ¶
type TemplateService interface { GetByID(ctx context.Context, id int64) (Template, error) GetByCode(ctx context.Context, code string) (Template, error) IsFresh(ctx context.Context, code string, t int64) (bool, error) Exists(ctx context.Context, code string) (bool, error) }
func NewTemplateService ¶
func NewTemplateService(storage TemplateStorage) TemplateService
type TemplateStorage ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.