cmsstore

package module
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: AGPL-3.0 Imports: 15 Imported by: 1

README

Cms Store Open in Gitpod

Tests Status Go Report Card PkgGoDev

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/agpl-3.0.en.html

For commercial use, please use my contact page to obtain a commercial license.

Introduction

This package allows to build user interfaces based on blocks.

Installation

go get -u github.com/gouniverse/cmsstore

Documentation

Index

Constants

View Source
const BLOCK_STATUS_ACTIVE = "active"
View Source
const BLOCK_STATUS_DRAFT = "draft"
View Source
const BLOCK_STATUS_INACTIVE = "inactive"
View Source
const COLUMN_ALIAS = "alias"
View Source
const COLUMN_CANONICAL_URL = "canonical_url"
View Source
const COLUMN_CONTENT = "content"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_DOMAIN_NAMES = "domain_names"
View Source
const COLUMN_EDITOR = "editor"
View Source
const COLUMN_HANDLE = "handle"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_META_DESCRIPTION = "meta_description"
View Source
const COLUMN_META_KEYWORDS = "meta_keywords"
View Source
const COLUMN_META_ROBOTS = "meta_robots"
View Source
const COLUMN_NAME = "name"
View Source
const COLUMN_PAGE_ID = "page_id"
View Source
const COLUMN_PARENT_ID = "parent_id"
View Source
const COLUMN_SEQUENCE = "sequence"
View Source
const COLUMN_SITE_ID = "site_id"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_STATUS = "status"
View Source
const COLUMN_TEMPLATE_ID = "template_id"
View Source
const COLUMN_TITLE = "title"
View Source
const COLUMN_TYPE = "type"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const ERROR_EMPTY_ARRAY = "array cannot be empty"
View Source
const ERROR_EMPTY_STRING = "string cannot be empty"
View Source
const ERROR_NEGATIVE_NUMBER = "number cannot be negative"
View Source
const PAGE_EDITOR_BLOCKAREA = "blockarea"
View Source
const PAGE_EDITOR_BLOCKEDITOR = "blockeditor"
View Source
const PAGE_EDITOR_CODEMIRROR = "codemirror"
View Source
const PAGE_EDITOR_HTMLAREA = "htmlarea"
View Source
const PAGE_EDITOR_MARKDOWN = "markdown"
View Source
const PAGE_EDITOR_TEXTAREA = "textarea"
View Source
const PAGE_STATUS_ACTIVE = "active"
View Source
const PAGE_STATUS_DRAFT = "draft"
View Source
const PAGE_STATUS_INACTIVE = "inactive"
View Source
const SITE_STATUS_ACTIVE = "active"
View Source
const SITE_STATUS_DRAFT = "draft"
View Source
const SITE_STATUS_INACTIVE = "inactive"
View Source
const TEMPLATE_STATUS_ACTIVE = "active"
View Source
const TEMPLATE_STATUS_DRAFT = "draft"
View Source
const TEMPLATE_STATUS_INACTIVE = "inactive"

Variables

This section is empty.

Functions

func NewBlockFromExistingData added in v0.2.0

func NewBlockFromExistingData(data map[string]string) *block

func NewPageFromExistingData added in v0.1.0

func NewPageFromExistingData(data map[string]string) *page

func NewSiteFromExistingData added in v0.2.1

func NewSiteFromExistingData(data map[string]string) *site

func NewTemplateFromExistingData added in v0.2.0

func NewTemplateFromExistingData(data map[string]string) *template

Types

type BlockInterface added in v0.2.0

type BlockInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	ID() string
	SetID(id string) BlockInterface

	CreatedAt() string
	SetCreatedAt(createdAt string) BlockInterface
	CreatedAtCarbon() carbon.Carbon

	Content() string
	SetContent(content string) BlockInterface

	Editor() string
	SetEditor(editor string) BlockInterface

	Handle() string
	SetHandle(handle string) BlockInterface

	Memo() string
	SetMemo(memo string) BlockInterface

	Meta(key string) string
	SetMeta(key, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error
	UpsertMetas(metas map[string]string) error

	Name() string
	SetName(name string) BlockInterface

	PageID() string
	SetPageID(pageID string) BlockInterface

	ParentID() string
	SetParentID(parentID string) BlockInterface

	Sequence() string
	SequenceInt() int
	SetSequenceInt(sequence int) BlockInterface
	SetSequence(sequence string) BlockInterface

	SiteID() string
	SetSiteID(siteID string) BlockInterface

	TemplateID() string
	SetTemplateID(templateID string) BlockInterface

	SoftDeletedAt() string
	SetSoftDeletedAt(softDeletedAt string) BlockInterface
	SoftDeletedAtCarbon() carbon.Carbon

	// Status returns the status of the block, i.e. BLOCK_STATUS_ACTIVE
	Status() string

	// SetStatus sets the status of the block, i.e. BLOCK_STATUS_ACTIVE
	SetStatus(status string) BlockInterface

	// Type returns the type of the block, i.e. "text"
	Type() string

	// SetType sets the type of the block, i.e. "text"
	SetType(blockType string) BlockInterface

	// UpdatedAt returns the last updated time of block
	UpdatedAt() string

	// SetUpdatedAt sets the last updated time of block
	SetUpdatedAt(updatedAt string) BlockInterface

	// UpdatedAtCarbon returns carbon.Carbon of the last updated time of block
	UpdatedAtCarbon() carbon.Carbon

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool
}

func NewBlock added in v0.2.0

func NewBlock() BlockInterface

type BlockQueryInterface added in v0.2.1

type BlockQueryInterface interface {
	Validate() error

	IsCountOnly() bool

	HasCreatedAtGte() bool
	HasCreatedAtLte() bool
	HasHandle() bool
	HasID() bool
	HasIDIn() bool
	HasLimit() bool
	HasNameLike() bool
	HasOffset() bool
	HasOrderBy() bool
	HasPageID() bool
	HasParentID() bool
	HasSequence() bool
	HasSiteID() bool
	HasSoftDeleted() bool
	HasSortOrder() bool
	HasStatus() bool
	HasStatusIn() bool
	HasTemplateID() bool

	CreatedAtGte() string
	CreatedAtLte() string
	Handle() string
	ID() string
	IDIn() []string
	Limit() int
	NameLike() string
	Offset() int
	OrderBy() string
	PageID() string
	ParentID() string
	Sequence() int
	SiteID() string
	SoftDeleteIncluded() bool
	SortOrder() string
	Status() string
	StatusIn() []string
	TemplateID() string

	SetCountOnly(countOnly bool) BlockQueryInterface
	SetID(id string) BlockQueryInterface
	SetIDIn(idIn []string) BlockQueryInterface
	SetHandle(handle string) BlockQueryInterface
	SetLimit(limit int) BlockQueryInterface
	SetNameLike(nameLike string) BlockQueryInterface
	SetOffset(offset int) BlockQueryInterface
	SetOrderBy(orderBy string) BlockQueryInterface
	SetPageID(pageID string) BlockQueryInterface
	SetParentID(parentID string) BlockQueryInterface
	SetSequence(sequence int) BlockQueryInterface
	SetSiteID(websiteID string) BlockQueryInterface
	SetSoftDeleteIncluded(withSoftDeleted bool) BlockQueryInterface
	SetSortOrder(sortOrder string) BlockQueryInterface
	SetStatus(status string) BlockQueryInterface
	SetStatusIn(statusIn []string) BlockQueryInterface
	SetTemplateID(templateID string) BlockQueryInterface
}

func BlockQuery added in v0.5.0

func BlockQuery() BlockQueryInterface

type NewStoreOptions added in v0.1.0

type NewStoreOptions struct {
	BlockTableName     string
	PageTableName      string
	SiteTableName      string
	TemplateTableName  string
	DB                 *sql.DB
	DbDriverName       string
	AutomigrateEnabled bool
	DebugEnabled       bool
}

NewStoreOptions define the options for creating a new block store

type PageInterface added in v0.1.0

type PageInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	ID() string
	SetID(id string) PageInterface

	Alias() string
	SetAlias(alias string) PageInterface

	CreatedAt() string
	SetCreatedAt(createdAt string) PageInterface
	CreatedAtCarbon() carbon.Carbon

	CanonicalUrl() string
	SetCanonicalUrl(canonicalUrl string) PageInterface

	Content() string
	SetContent(content string) PageInterface

	Editor() string
	SetEditor(editor string) PageInterface

	Handle() string
	SetHandle(handle string) PageInterface

	Memo() string
	SetMemo(memo string) PageInterface

	MetaDescription() string
	SetMetaDescription(metaDescription string) PageInterface

	MetaKeywords() string
	SetMetaKeywords(metaKeywords string) PageInterface

	MetaRobots() string
	SetMetaRobots(metaRobots string) PageInterface

	Meta(key string) string
	SetMeta(key, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error
	UpsertMetas(metas map[string]string) error

	Name() string
	SetName(name string) PageInterface

	SiteID() string
	SetSiteID(siteID string) PageInterface

	SoftDeletedAt() string
	SetSoftDeletedAt(softDeletedAt string) PageInterface
	SoftDeletedAtCarbon() carbon.Carbon

	Status() string
	SetStatus(status string) PageInterface

	Title() string
	SetTitle(title string) PageInterface

	TemplateID() string
	SetTemplateID(templateID string) PageInterface

	UpdatedAt() string
	SetUpdatedAt(updatedAt string) PageInterface
	UpdatedAtCarbon() carbon.Carbon

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool
}

func NewPage added in v0.1.0

func NewPage() PageInterface

type PageQueryInterface added in v0.1.0

type PageQueryInterface interface {
	Validate() error

	HasAlias() bool
	Alias() string
	SetAlias(alias string) PageQueryInterface

	HasAliasLike() bool
	AliasLike() string
	SetAliasLike(nameLike string) PageQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) PageQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) PageQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) PageQueryInterface

	HasHandle() bool
	Handle() string
	SetHandle(handle string) PageQueryInterface

	HasID() bool
	ID() string
	SetID(id string) PageQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) PageQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) PageQueryInterface

	HasNameLike() bool
	NameLike() string
	SetNameLike(nameLike string) PageQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) PageQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) PageQueryInterface

	HasSiteID() bool
	SiteID() string
	SetSiteID(siteID string) PageQueryInterface

	HasSortOrder() bool
	SortOrder() string
	SetSortOrder(sortOrder string) PageQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeleteIncluded bool) PageQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) PageQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) PageQueryInterface

	HasTemplateID() bool
	TemplateID() string
	SetTemplateID(templateID string) PageQueryInterface
}

func PageQuery added in v0.5.0

func PageQuery() PageQueryInterface

type PageQueryOptions added in v0.1.0

type PageQueryOptions struct {
	ID           string
	IDIn         []string
	Status       string
	StatusIn     []string
	Handle       string
	CreatedAtGte string
	CreatedAtLte string
	Offset       int
	Limit        int
	SortOrder    string
	OrderBy      string
	CountOnly    bool
	WithDeleted  bool
}

type ShortcodeInterface added in v0.6.0

type ShortcodeInterface interface {
	Alias() string
	Description() string
	Render(r *http.Request, s string, m map[string]string) string
}

type SiteInterface added in v0.2.1

type SiteInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	ID() string
	SetID(id string) SiteInterface

	CreatedAt() string
	SetCreatedAt(createdAt string) SiteInterface
	CreatedAtCarbon() carbon.Carbon

	DomainNames() ([]string, error)
	SetDomainNames(domainNames []string) (SiteInterface, error)

	Handle() string
	SetHandle(handle string) SiteInterface

	Memo() string
	SetMemo(memo string) SiteInterface

	Meta(key string) string
	SetMeta(key, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error
	UpsertMetas(metas map[string]string) error

	Name() string
	SetName(name string) SiteInterface

	SoftDeletedAt() string
	SetSoftDeletedAt(softDeletedAt string) SiteInterface
	SoftDeletedAtCarbon() carbon.Carbon

	Status() string
	SetStatus(status string) SiteInterface

	UpdatedAt() string
	SetUpdatedAt(updatedAt string) SiteInterface
	UpdatedAtCarbon() carbon.Carbon

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool
}

func NewSite added in v0.2.1

func NewSite() SiteInterface

type SiteQueryInterface added in v0.2.1

type SiteQueryInterface interface {
	Validate() error

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) SiteQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) SiteQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) SiteQueryInterface

	HasDomainName() bool
	DomainName() string
	SetDomainName(domainName string) SiteQueryInterface

	HasHandle() bool
	Handle() string
	SetHandle(handle string) SiteQueryInterface

	HasID() bool
	ID() string
	SetID(id string) SiteQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) SiteQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) SiteQueryInterface

	HasNameLike() bool
	NameLike() string
	SetNameLike(nameLike string) SiteQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) SiteQueryInterface

	HasSortOrder() bool
	SortOrder() string
	SetSortOrder(sortOrder string) SiteQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) SiteQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(softDeletedIncluded bool) SiteQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) SiteQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) SiteQueryInterface
}

func SiteQuery added in v0.5.0

func SiteQuery() SiteQueryInterface

type SiteQueryOptions added in v0.2.1

type SiteQueryOptions struct {
	ID           string
	IDIn         []string
	Handle       string
	NameLike     string
	Status       string
	StatusIn     []string
	CreatedAtGte string
	CreatedAtLte string
	Offset       int
	Limit        int
	SortOrder    string
	OrderBy      string
	CountOnly    bool
	WithDeleted  bool
}

type StoreInterface added in v0.1.0

type StoreInterface interface {
	AutoMigrate() error
	EnableDebug(debug bool)

	BlockCreate(block BlockInterface) error
	BlockCount(options BlockQueryInterface) (int64, error)
	BlockDelete(block BlockInterface) error
	BlockDeleteByID(id string) error
	BlockFindByHandle(blockHandle string) (BlockInterface, error)
	BlockFindByID(blockID string) (BlockInterface, error)
	BlockList(query BlockQueryInterface) ([]BlockInterface, error)
	BlockSoftDelete(block BlockInterface) error
	BlockSoftDeleteByID(id string) error
	BlockUpdate(block BlockInterface) error

	PageCreate(page PageInterface) error
	PageCount(options PageQueryInterface) (int64, error)
	PageDelete(page PageInterface) error
	PageDeleteByID(id string) error
	PageFindByHandle(pageHandle string) (PageInterface, error)
	PageFindByID(pageID string) (PageInterface, error)
	PageList(query PageQueryInterface) ([]PageInterface, error)
	PageSoftDelete(page PageInterface) error
	PageSoftDeleteByID(id string) error
	PageUpdate(page PageInterface) error

	SiteCreate(site SiteInterface) error
	SiteCount(options SiteQueryInterface) (int64, error)
	SiteDelete(site SiteInterface) error
	SiteDeleteByID(id string) error
	SiteFindByDomainName(siteDomainName string) (SiteInterface, error)
	SiteFindByHandle(siteHandle string) (SiteInterface, error)
	SiteFindByID(siteID string) (SiteInterface, error)
	SiteList(query SiteQueryInterface) ([]SiteInterface, error)
	SiteSoftDelete(site SiteInterface) error
	SiteSoftDeleteByID(id string) error
	SiteUpdate(site SiteInterface) error

	TemplateCreate(template TemplateInterface) error
	TemplateCount(options TemplateQueryInterface) (int64, error)
	TemplateDelete(template TemplateInterface) error
	TemplateDeleteByID(id string) error
	TemplateFindByHandle(templateHandle string) (TemplateInterface, error)
	TemplateFindByID(templateID string) (TemplateInterface, error)
	TemplateList(query TemplateQueryInterface) ([]TemplateInterface, error)
	TemplateSoftDelete(template TemplateInterface) error
	TemplateSoftDeleteByID(id string) error
	TemplateUpdate(template TemplateInterface) error
}

func NewStore added in v0.1.0

func NewStore(opts NewStoreOptions) (StoreInterface, error)

NewStore creates a new block store

type TemplateInterface added in v0.2.0

type TemplateInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	ID() string
	SetID(id string) TemplateInterface

	CreatedAt() string
	SetCreatedAt(createdAt string) TemplateInterface
	CreatedAtCarbon() carbon.Carbon

	Content() string
	SetContent(content string) TemplateInterface

	Editor() string
	SetEditor(editor string) TemplateInterface

	Handle() string
	SetHandle(handle string) TemplateInterface

	Memo() string
	SetMemo(memo string) TemplateInterface

	Meta(key string) string
	SetMeta(key, value string) error
	Metas() (map[string]string, error)
	SetMetas(metas map[string]string) error
	UpsertMetas(metas map[string]string) error

	Name() string
	SetName(name string) TemplateInterface

	SiteID() string
	SetSiteID(siteID string) TemplateInterface

	SoftDeletedAt() string
	SetSoftDeletedAt(softDeletedAt string) TemplateInterface
	SoftDeletedAtCarbon() carbon.Carbon

	Status() string
	SetStatus(status string) TemplateInterface

	UpdatedAt() string
	SetUpdatedAt(updatedAt string) TemplateInterface
	UpdatedAtCarbon() carbon.Carbon

	IsActive() bool
	IsInactive() bool
	IsSoftDeleted() bool
}

func NewTemplate added in v0.2.0

func NewTemplate() TemplateInterface

type TemplateQueryInterface added in v0.2.1

type TemplateQueryInterface interface {
	Validate() error

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) TemplateQueryInterface

	HasCreatedAtGte() bool
	CreatedAtGte() string
	SetCreatedAtGte(createdAtGte string) TemplateQueryInterface

	HasCreatedAtLte() bool
	CreatedAtLte() string
	SetCreatedAtLte(createdAtLte string) TemplateQueryInterface

	HasHandle() bool
	Handle() string
	SetHandle(handle string) TemplateQueryInterface

	HasID() bool
	ID() string
	SetID(id string) TemplateQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) TemplateQueryInterface

	HasNameLike() bool
	NameLike() string
	SetNameLike(nameLike string) TemplateQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) TemplateQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) TemplateQueryInterface

	HasSortOrder() bool
	SortOrder() string
	SetSortOrder(sortOrder string) TemplateQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) TemplateQueryInterface

	HasSiteID() bool
	SiteID() string
	SetSiteID(siteID string) TemplateQueryInterface

	HasSoftDeletedIncluded() bool
	SoftDeletedIncluded() bool
	SetSoftDeletedIncluded(includeSoftDeleted bool) TemplateQueryInterface

	HasStatus() bool
	Status() string
	SetStatus(status string) TemplateQueryInterface

	HasStatusIn() bool
	StatusIn() []string
	SetStatusIn(statusIn []string) TemplateQueryInterface
}

func TemplateQuery added in v0.5.0

func TemplateQuery() TemplateQueryInterface

type TemplateQueryOptions added in v0.2.1

type TemplateQueryOptions struct {
	ID           string
	IDIn         []string
	Status       string
	StatusIn     []string
	Handle       string
	CreatedAtGte string
	CreatedAtLte string
	Offset       int
	Limit        int
	SortOrder    string
	OrderBy      string
	CountOnly    bool
	WithDeleted  bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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