Documentation
¶
Overview ¶
Package cmsstore contains the implementation of the CMS store functionality.
Package cmsstore defines the interface for querying menu items.
Package cmsstore provides the core functionality for the CMS store.
Package cmsstore provides functionality to create and manage a CMS store, handling various components like blocks, menus, pages, templates, and translations.
Index ¶
- Constants
- func GenerateShortID() string
- func GetAllBlockTypes() map[string]BlockType
- func GetBlockTypeOrigin(typeKey string) string
- func GetCustomBlockTypes() map[string]BlockType
- func GetSystemBlockTypes() map[string]BlockType
- func IsShortID(id string) bool
- func Middleware() *middleware
- func NewBlockFromExistingData(data map[string]string) *block
- func NewMenuFromExistingData(data map[string]string) *menuImplementation
- func NewMenuItemFromExistingData(data map[string]string) *menuItemImplementation
- func NewPageFromExistingData(data map[string]string) *pageImplementation
- func NewSiteFromExistingData(data map[string]string) *siteImplementation
- func NormalizeID(id string) string
- func RegisterCustomBlockType(blockType BlockType)
- func RegisterSystemBlockType(blockType BlockType)
- func ShortenID(id string) string
- func UnshortenID(id string) string
- type BlockAdminFieldProvider
- type BlockAttributeDefinition
- type BlockInterface
- type BlockQueryInterface
- type BlockRenderer
- type BlockType
- func AdminOnlyAdapter(typeKey, typeLabel string, adminProvider BlockAdminFieldProvider) BlockType
- func GetBlockType(typeKey string) BlockType
- func NewBlockTypeAdapter(typeKey, typeLabel string, renderer BlockRenderer, ...) BlockType
- func RendererOnlyAdapter(typeKey, typeLabel string, renderer BlockRenderer) BlockType
- type BlockTypeAdapter
- func (a *BlockTypeAdapter) GetAdminFields(block BlockInterface, r *http.Request) interface{}
- func (a *BlockTypeAdapter) Render(ctx context.Context, block BlockInterface, opts ...RenderOption) (string, error)
- func (a *BlockTypeAdapter) SaveAdminFields(r *http.Request, block BlockInterface) error
- func (a *BlockTypeAdapter) TypeKey() string
- func (a *BlockTypeAdapter) TypeLabel() string
- type BlockTypeRegistry
- func (r *BlockTypeRegistry) Get(typeKey string) BlockType
- func (r *BlockTypeRegistry) GetAll() map[string]BlockType
- func (r *BlockTypeRegistry) GetByOrigin(origin string) map[string]BlockType
- func (r *BlockTypeRegistry) GetKeys() []string
- func (r *BlockTypeRegistry) GetOrigin(typeKey string) string
- func (r *BlockTypeRegistry) Register(blockType BlockType)
- func (r *BlockTypeRegistry) RegisterWithOrigin(blockType BlockType, origin string)
- type CustomAttributeDefinition
- type CustomEntityDefinition
- type CustomEntityStore
- func (s *CustomEntityStore) Count(ctx context.Context, options entitystore.EntityQueryOptions) (int64, error)
- func (s *CustomEntityStore) Create(ctx context.Context, entityType string, attrs map[string]interface{}, ...) (string, error)
- func (s *CustomEntityStore) Delete(ctx context.Context, entityID string) error
- func (s *CustomEntityStore) FindByID(ctx context.Context, entityID string) (entitystore.EntityInterface, error)
- func (s *CustomEntityStore) GetAllDefinitions() []CustomEntityDefinition
- func (s *CustomEntityStore) GetEntityDefinition(entityType string) (CustomEntityDefinition, bool)
- func (s *CustomEntityStore) GetRelationships(ctx context.Context, entityID string) ([]entitystore.RelationshipInterface, error)
- func (s *CustomEntityStore) GetTaxonomyAssignments(ctx context.Context, entityID string) ([]entitystore.EntityTaxonomyInterface, error)
- func (s *CustomEntityStore) Inner() entitystore.StoreInterface
- func (s *CustomEntityStore) List(ctx context.Context, options entitystore.EntityQueryOptions) ([]entitystore.EntityInterface, error)
- func (s *CustomEntityStore) RegisterEntityType(def CustomEntityDefinition) error
- func (s *CustomEntityStore) Update(ctx context.Context, entity entitystore.EntityInterface, ...) error
- type CustomEntityStoreOptions
- type MenuInterface
- type MenuItemInterface
- type MenuItemQueryInterface
- type MenuQueryInterface
- type MiddlewareInterface
- type NewStoreOptions
- type Option
- type Options
- type PageInterface
- type PageQueryInterface
- type RelationshipDefinition
- type RenderOption
- type RenderOptions
- type ShortcodeInterface
- type SiteInterface
- type SiteQueryInterface
- type StoreInterface
- type TemplateInterface
- type TemplateQueryInterface
- type TranslationInterface
- type TranslationQueryInterface
- type VersioningInterface
- type VersioningQueryInterface
Examples ¶
Constants ¶
const ( // BLOCK_ORIGIN_SYSTEM for built-in block types BLOCK_ORIGIN_SYSTEM = "system" // BLOCK_ORIGIN_CUSTOM for user-defined block types BLOCK_ORIGIN_CUSTOM = "custom" )
BlockType defines a complete block type with both frontend rendering and admin UI.
This is the recommended way to define custom block types. It ensures that both the frontend renderer and admin UI are registered together, preventing the common mistake of registering one but forgetting the other.
Example implementation:
type GalleryBlockType struct {
store StoreInterface
}
func (t *GalleryBlockType) TypeKey() string {
return "gallery"
}
func (t *GalleryBlockType) TypeLabel() string {
return "Gallery Block"
}
func (t *GalleryBlockType) Render(ctx context.Context, block BlockInterface) (string, error) {
// Frontend rendering logic
images := parseImages(block.Content())
return renderGalleryHTML(images, block.Meta("layout")), nil
}
func (t *GalleryBlockType) GetAdminFields(block BlockInterface, r *http.Request) []form.FieldInterface {
// Admin form fields
return []form.FieldInterface{
form.NewField(form.FieldOptions{
Label: "Gallery Images",
Name: "gallery_images",
Type: form.FORM_FIELD_TYPE_TEXTAREA,
Value: block.Content(),
}),
}
}
func (t *GalleryBlockType) SaveAdminFields(r *http.Request, block BlockInterface) error {
// Save form data
images := req.GetStringTrimmed(r, "gallery_images")
block.SetContent(images)
return nil
}
To register:
cmsstore.RegisterBlockType(&GalleryBlockType{store: store})
This single registration automatically makes the block type available in both frontend rendering and admin UI.
const ( BLOCK_TYPE_HTML = "html" BLOCK_TYPE_MENU = "menu" BLOCK_TYPE_NAVBAR = "navbar" BLOCK_TYPE_BREADCRUMBS = "breadcrumbs" )
Block Types (lowercase for consistency with other constants)
const ( BLOCK_META_MENU_ID = "menu_id" BLOCK_META_MENU_CSS_CLASS = "menu_css_class" BLOCK_META_MENU_CSS_ID = "menu_css_id" BLOCK_META_MENU_STYLE = "menu_style" BLOCK_META_MENU_RENDERING_MODE = "menu_rendering_mode" BLOCK_META_MENU_START_LEVEL = "menu_start_level" BLOCK_META_MENU_MAX_DEPTH = "menu_max_depth" )
Block Meta Keys for Menu Type
const ( BLOCK_MENU_STYLE_HORIZONTAL = "horizontal" BLOCK_MENU_STYLE_VERTICAL = "vertical" BLOCK_MENU_STYLE_DROPDOWN = "dropdown" BLOCK_MENU_STYLE_BREADCRUMB = "breadcrumb" )
Block Menu Styles
const ( BLOCK_MENU_RENDERING_PLAIN = "plain" BLOCK_MENU_RENDERING_BOOTSTRAP5 = "bootstrap5" )
Block Menu Rendering Modes
const ( BLOCK_META_NAVBAR_STYLE = "navbar_style" BLOCK_META_NAVBAR_RENDERING_MODE = "navbar_rendering_mode" BLOCK_META_NAVBAR_CSS_CLASS = "navbar_css_class" BLOCK_META_NAVBAR_CSS_ID = "navbar_css_id" BLOCK_META_NAVBAR_BRAND_TEXT = "navbar_brand_text" BLOCK_META_NAVBAR_BRAND_URL = "navbar_brand_url" BLOCK_META_NAVBAR_BRAND_IMAGE_URL = "navbar_brand_image_url" BLOCK_META_NAVBAR_BRAND_IMAGE_WIDTH = "navbar_brand_image_width" BLOCK_META_NAVBAR_BRAND_IMAGE_HEIGHT = "navbar_brand_image_height" BLOCK_META_NAVBAR_BRAND_IMAGE_ALT = "navbar_brand_image_alt" BLOCK_META_NAVBAR_FIXED = "navbar_fixed" BLOCK_META_NAVBAR_DARK = "navbar_dark" BLOCK_META_NAVBAR_CUSTOM_CSS = "navbar_custom_css" )
Block Meta Keys for Navbar Type
const ( BLOCK_NAVBAR_STYLE_DEFAULT = "default" BLOCK_NAVBAR_STYLE_CENTERED = "centered" BLOCK_NAVBAR_STYLE_BOTTOM = "bottom" )
Block Navbar Styles
const ( BLOCK_NAVBAR_RENDERING_PLAIN = "plain" BLOCK_NAVBAR_RENDERING_BOOTSTRAP5 = "bootstrap5" )
Block Navbar Rendering Modes
const ( BLOCK_META_BREADCRUMBS_STYLE = "breadcrumbs_style" BLOCK_META_BREADCRUMBS_RENDERING_MODE = "breadcrumbs_rendering_mode" BLOCK_META_BREADCRUMBS_CSS_CLASS = "breadcrumbs_css_class" BLOCK_META_BREADCRUMBS_CSS_ID = "breadcrumbs_css_id" BLOCK_META_BREADCRUMBS_SEPARATOR = "breadcrumbs_separator" BLOCK_META_BREADCRUMBS_HOME_TEXT = "breadcrumbs_home_text" BLOCK_META_BREADCRUMBS_HOME_URL = "breadcrumbs_home_url" )
Block Meta Keys for Breadcrumbs Type
const ( BLOCK_BREADCRUMBS_STYLE_DEFAULT = "default" BLOCK_BREADCRUMBS_STYLE_CENTERED = "centered" BLOCK_BREADCRUMBS_STYLE_RIGHT = "right" )
Block Breadcrumbs Styles
const ( BLOCK_BREADCRUMBS_RENDERING_PLAIN = "plain" BLOCK_BREADCRUMBS_RENDERING_BOOTSTRAP5 = "bootstrap5" )
Block Breadcrumbs Rendering Modes
const ( BLOCK_STATUS_DRAFT = "draft" BLOCK_STATUS_ACTIVE = "active" BLOCK_STATUS_INACTIVE = "inactive" )
Block Statuses
const ( ERROR_EMPTY_ARRAY = "array cannot be empty" ERROR_EMPTY_STRING = "string cannot be empty" ERROR_NEGATIVE_NUMBER = "number cannot be negative" )
Error Messages for Validation
const ( COLUMN_ALIAS = "alias" COLUMN_CANONICAL_URL = "canonical_url" COLUMN_CONTENT = "content" COLUMN_CREATED_AT = "created_at" COLUMN_DOMAIN_NAMES = "domain_names" COLUMN_EDITOR = "editor" COLUMN_ID = "id" COLUMN_HANDLE = "handle" COLUMN_MEMO = "memo" COLUMN_MENU_ID = "menu_id" COLUMN_META_DESCRIPTION = "meta_description" COLUMN_META_KEYWORDS = "meta_keywords" COLUMN_META_ROBOTS = "meta_robots" COLUMN_METAS = "metas" COLUMN_NAME = "name" COLUMN_MIDDLEWARES_BEFORE = "middlewares_before" COLUMN_MIDDLEWARES_AFTER = "middlewares_after" COLUMN_PAGE_ID = "page_id" COLUMN_PARENT_ID = "parent_id" COLUMN_SEQUENCE = "sequence" COLUMN_SITE_ID = "site_id" COLUMN_SOFT_DELETED_AT = "soft_deleted_at" COLUMN_STATUS = "status" COLUMN_TARGET = "target" COLUMN_TYPE = "type" COLUMN_TEMPLATE_ID = "template_id" COLUMN_TITLE = "title" COLUMN_UPDATED_AT = "updated_at" COLUMN_URL = "url" )
Column Names for Database Queries
const ( MENU_STATUS_DRAFT = "draft" MENU_STATUS_ACTIVE = "active" MENU_STATUS_INACTIVE = "inactive" )
Menu Statuses
const ( MENU_ITEM_STATUS_DRAFT = "draft" MENU_ITEM_STATUS_ACTIVE = "active" MENU_ITEM_STATUS_INACTIVE = "inactive" )
Menu Item Statuses
const ( MIDDLEWARE_TYPE_BEFORE = "before" MIDDLEWARE_TYPE_AFTER = "after" )
Middleware Types
const ( PAGE_STATUS_DRAFT = "draft" PAGE_STATUS_ACTIVE = "active" PAGE_STATUS_INACTIVE = "inactive" )
Page Statuses
const ( PAGE_EDITOR_BLOCKAREA = "blockarea" PAGE_EDITOR_BLOCKEDITOR = "blockeditor" PAGE_EDITOR_CODEMIRROR = "codemirror" PAGE_EDITOR_HTMLAREA = "htmlarea" PAGE_EDITOR_MARKDOWN = "markdown" PAGE_EDITOR_TEXTAREA = "textarea" )
Page Editor Types
const ( SITE_STATUS_DRAFT = "draft" SITE_STATUS_ACTIVE = "active" SITE_STATUS_INACTIVE = "inactive" )
Site Statuses
const ( TEMPLATE_STATUS_DRAFT = "draft" TEMPLATE_STATUS_ACTIVE = "active" TEMPLATE_STATUS_INACTIVE = "inactive" )
Template Statuses
const ( TRANSLATION_STATUS_DRAFT = "draft" TRANSLATION_STATUS_ACTIVE = "active" TRANSLATION_STATUS_INACTIVE = "inactive" )
Translation Statuses
const ( VERSIONING_TYPE_BLOCK = "block" VERSIONING_TYPE_PAGE = "page" VERSIONING_TYPE_MENU = "menu" VERSIONING_TYPE_MENU_ITEM = "menu_item" VERSIONING_TYPE_TEMPLATE = "template" VERSIONING_TYPE_TRANSLATION = "translation" VERSIONING_TYPE_SITE = "site" )
Versioning Types
Variables ¶
This section is empty.
Functions ¶
func GenerateShortID ¶ added in v1.7.0
func GenerateShortID() string
GenerateShortID generates a new shortened ID using TimestampMicro + Crockford Base32 (lowercase) Returns a 9-character lowercase ID (e.g., "86ccrtsgx") Thread-safe: Uses mutex to prevent duplicate IDs when called concurrently
func GetAllBlockTypes ¶ added in v1.14.0
GetAllBlockTypes returns all registered block types.
Returns a map of type keys to block types. The returned map is a copy to prevent external modification. This method is thread-safe.
func GetBlockTypeOrigin ¶ added in v1.18.0
GetBlockTypeOrigin returns the origin for a block type (system/custom).
func GetCustomBlockTypes ¶ added in v1.18.0
GetCustomBlockTypes returns all custom (user-defined) block types.
func GetSystemBlockTypes ¶ added in v1.18.0
GetSystemBlockTypes returns all system (built-in) block types.
func IsShortID ¶ added in v1.7.0
IsShortID checks if an ID appears to be a shortened ID (9 or 21 chars) vs a long HumanUid ID (32 chars)
func NewMenuFromExistingData ¶
NewMenuFromExistingData creates a new menu instance from existing data. It hydrates the menu with the provided data map.
func NewPageFromExistingData ¶
NewPageFromExistingData creates a new page from existing data.
func NewSiteFromExistingData ¶
NewSiteFromExistingData creates a new site from existing data.
func NormalizeID ¶ added in v1.7.0
NormalizeID normalizes an ID to lowercase for consistent lookups Handles both short (9-char, 21-char) and long (32-char) ID formats
func RegisterCustomBlockType ¶ added in v1.18.0
func RegisterCustomBlockType(blockType BlockType)
RegisterCustomBlockType registers a user-defined (custom) block type.
Use this for your own custom block types. The CMS will treat these as user-defined and display them with a different badge color (cyan).
Example ¶
ExampleRegisterCustomBlockType shows how to register a custom block type.
This single registration makes the block type available in both:
- Frontend rendering (when blocks are displayed on pages)
- Admin UI (block type dropdown, edit forms, save logic)
package main
import (
"context"
"encoding/json"
"fmt"
"net/http"
"github.com/dracory/cmsstore"
"github.com/dracory/form"
"github.com/dracory/req"
)
// GalleryBlockType is a complete example of a custom block type.
//
// This single struct implements both frontend rendering and admin UI,
// ensuring they stay in sync and preventing registration errors.
type GalleryBlockType struct {
store cmsstore.StoreInterface
}
// TypeKey returns the unique identifier stored in the database.
func (t *GalleryBlockType) TypeKey() string {
return "gallery"
}
// TypeLabel returns the display name shown in the admin UI.
func (t *GalleryBlockType) TypeLabel() string {
return "Gallery Block"
}
// Render implements frontend rendering logic.
func (t *GalleryBlockType) Render(ctx context.Context, block cmsstore.BlockInterface, opts ...cmsstore.RenderOption) (string, error) {
// Parse gallery data from block content
var images []GalleryImage
if err := json.Unmarshal([]byte(block.Content()), &images); err != nil {
return "<!-- Invalid gallery data -->", nil
}
// Get configuration from metadata
layout := block.Meta("layout")
if layout == "" {
layout = "grid"
}
columns := block.Meta("columns")
if columns == "" {
columns = "3"
}
// Generate HTML
html := fmt.Sprintf(`<div class="gallery gallery-layout-%s" data-columns="%s">`, layout, columns)
for _, img := range images {
html += fmt.Sprintf(`
<div class="gallery-item">
<img src="%s" alt="%s" loading="lazy">
<div class="caption">%s</div>
</div>`, img.URL, img.Alt, img.Caption)
}
html += `</div>
<script>
// Initialize gallery (use your preferred library)
document.querySelectorAll('.gallery').forEach(gallery => {
initGallery(gallery);
});
</script>`
return html, nil
}
// GetAdminFields implements admin UI form fields.
func (t *GalleryBlockType) GetAdminFields(block cmsstore.BlockInterface, r *http.Request) interface{} {
return []form.FieldInterface{
form.NewField(form.FieldOptions{
Label: "Gallery Images (JSON)",
Name: "gallery_images",
Type: form.FORM_FIELD_TYPE_TEXTAREA,
Value: block.Content(),
Required: true,
Help: "Enter images as JSON array: [{\"url\":\"...\",\"alt\":\"...\",\"caption\":\"...\"}]",
}),
form.NewField(form.FieldOptions{
Label: "Layout Style",
Name: "gallery_layout",
Type: form.FORM_FIELD_TYPE_SELECT,
Value: block.Meta("layout"),
Options: []form.FieldOption{
{Value: "Grid", Key: "grid"},
{Value: "Masonry", Key: "masonry"},
{Value: "Carousel", Key: "carousel"},
{Value: "Slideshow", Key: "slideshow"},
},
}),
form.NewField(form.FieldOptions{
Label: "Columns (for grid layout)",
Name: "gallery_columns",
Type: form.FORM_FIELD_TYPE_SELECT,
Value: block.Meta("columns"),
Options: []form.FieldOption{
{Value: "2 columns", Key: "2"},
{Value: "3 columns", Key: "3"},
{Value: "4 columns", Key: "4"},
{Value: "6 columns", Key: "6"},
},
}),
form.NewField(form.FieldOptions{
Label: "Enable Lightbox",
Name: "gallery_lightbox",
Type: form.FORM_FIELD_TYPE_CHECKBOX,
Value: block.Meta("lightbox"),
Help: "Open images in a lightbox when clicked",
}),
}
}
// SaveAdminFields implements form submission handling.
func (t *GalleryBlockType) SaveAdminFields(r *http.Request, block cmsstore.BlockInterface) error {
// Get form values
images := req.GetStringTrimmed(r, "gallery_images")
layout := req.GetStringTrimmed(r, "gallery_layout")
columns := req.GetStringTrimmed(r, "gallery_columns")
lightbox := req.GetStringTrimmed(r, "gallery_lightbox")
// Validate JSON
if images == "" {
return &ValidationError{Message: "Gallery images are required"}
}
var imageData []GalleryImage
if err := json.Unmarshal([]byte(images), &imageData); err != nil {
return &ValidationError{Message: "Invalid JSON format: " + err.Error()}
}
if len(imageData) == 0 {
return &ValidationError{Message: "At least one image is required"}
}
// Save to block
block.SetContent(images)
block.SetMeta("layout", layout)
block.SetMeta("columns", columns)
block.SetMeta("lightbox", lightbox)
return nil
}
// GalleryImage represents a single image in the gallery.
type GalleryImage struct {
URL string `json:"url"`
Alt string `json:"alt"`
Caption string `json:"caption"`
}
// ValidationError represents a form validation error.
type ValidationError struct {
Message string
}
func (e *ValidationError) Error() string {
return e.Message
}
// ExampleRegisterCustomBlockType shows how to register a custom block type.
//
// This single registration makes the block type available in both:
// - Frontend rendering (when blocks are displayed on pages)
// - Admin UI (block type dropdown, edit forms, save logic)
func main() {
// Create your block type instance
galleryType := &GalleryBlockType{
store: nil, // Pass your store instance here
}
// Register it globally - that's it!
cmsstore.RegisterCustomBlockType(galleryType)
// Now the "gallery" block type is fully functional:
// - Appears in admin UI block type dropdown as "Gallery Block"
// - Shows custom form fields when editing
// - Renders with custom HTML on the frontend
// - Validates and saves form data correctly
fmt.Println("Gallery block type registered successfully")
}
// ExampleBlockType_interactiveWithVue shows a Vue.js interactive block.
type VueTreeBlockType struct{}
func (t *VueTreeBlockType) TypeKey() string {
return "vue_tree"
}
func (t *VueTreeBlockType) TypeLabel() string {
return "Interactive Tree (Vue.js)"
}
func (t *VueTreeBlockType) Render(ctx context.Context, block cmsstore.BlockInterface, opts ...cmsstore.RenderOption) (string, error) {
treeData := block.Content()
blockID := block.ID()
cssClass := block.Meta("css_class")
return fmt.Sprintf(`
<div id="vue-tree-%s" class="%s"></div>
<script type="module">
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js'
createApp({
data() {
return {
treeData: %s,
expanded: {}
}
},
methods: {
toggleNode(nodeId) {
this.expanded[nodeId] = !this.expanded[nodeId]
}
},
template: `+"`"+`
<div class="tree-container">
<tree-node
v-for="node in treeData"
:key="node.id"
:node="node"
:expanded="expanded"
@toggle="toggleNode"
/>
</div>
`+"`"+`
}).mount('#vue-tree-%s')
</script>
`, blockID, cssClass, treeData, blockID), nil
}
func (t *VueTreeBlockType) GetAdminFields(block cmsstore.BlockInterface, r *http.Request) interface{} {
return []form.FieldInterface{
form.NewField(form.FieldOptions{
Label: "Tree Data (JSON)",
Name: "tree_data",
Type: form.FORM_FIELD_TYPE_TEXTAREA,
Value: block.Content(),
Required: true,
Help: "Tree structure in JSON format",
}),
form.NewField(form.FieldOptions{
Label: "CSS Class",
Name: "tree_css_class",
Type: form.FORM_FIELD_TYPE_STRING,
Value: block.Meta("css_class"),
Help: "Custom CSS class for styling",
}),
}
}
func (t *VueTreeBlockType) SaveAdminFields(r *http.Request, block cmsstore.BlockInterface) error {
treeData := req.GetStringTrimmed(r, "tree_data")
cssClass := req.GetStringTrimmed(r, "tree_css_class")
// Validate JSON
if treeData != "" {
var test interface{}
if err := json.Unmarshal([]byte(treeData), &test); err != nil {
return &ValidationError{Message: "Invalid JSON: " + err.Error()}
}
}
block.SetContent(treeData)
block.SetMeta("css_class", cssClass)
return nil
}
Output: Gallery block type registered successfully
func RegisterSystemBlockType ¶ added in v1.18.0
func RegisterSystemBlockType(blockType BlockType)
RegisterSystemBlockType registers a system (built-in) block type.
This is used internally by the CMS for built-in types like HTML, Menu, Navbar. For user-defined custom block types, use RegisterCustomBlockType instead.
func ShortenID ¶ added in v1.7.0
ShortenID shortens a long ID to its shortened form - 9-char IDs: Return as-is (already shortened TimestampMicro) - 32-char IDs: Shorten to 21-char using Crockford - Other lengths: Return as-is
func UnshortenID ¶ added in v1.7.0
UnshortenID attempts to unshorten a shortened ID back to its original form Returns the original ID if it cannot be unshortened
Types ¶
type BlockAdminFieldProvider ¶ added in v1.14.0
type BlockAdminFieldProvider interface {
GetContentFields(block BlockInterface, r *http.Request) interface{}
GetTypeLabel() string
SaveContentFields(r *http.Request, block BlockInterface) error
}
BlockAdminFieldProvider interface for admin UI (from admin/blocks package).
type BlockAttributeDefinition ¶ added in v1.19.0
type BlockAttributeDefinition struct {
// Name is the attribute name (e.g., "depth", "style")
Name string
// Type is the attribute type: "string", "int", "bool", "enum", "float"
Type string
// Required indicates whether the attribute is required
Required bool
// Default is the default value if not provided
Default interface{}
// Description is a human-readable description
Description string
// EnumValues lists valid values for enum type
EnumValues []string
// Validation is a validation rule: "range:1,10", "regex:^[a-z]+$", etc.
Validation string
// MinValue is the minimum value (for int/float types)
MinValue *float64
// MaxValue is the maximum value (for int/float types)
MaxValue *float64
}
BlockAttributeDefinition describes a single runtime attribute.
type BlockInterface ¶
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 ¶
func NewBlock() BlockInterface
type BlockQueryInterface ¶
type BlockQueryInterface interface {
Validate() error
IsCountOnly() bool
HasColumns() bool
Columns() []string
SetColumns(columns []string) BlockQueryInterface
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
HasType() 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
Type() string
SetCountOnly(countOnly bool) BlockQueryInterface
SetCreatedAtGte(createdAtGte string) BlockQueryInterface
SetCreatedAtLte(createdAtLte string) 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
SetType(blockType string) BlockQueryInterface
}
func BlockQuery ¶
func BlockQuery() BlockQueryInterface
type BlockRenderer ¶ added in v1.14.0
type BlockRenderer interface {
Render(ctx context.Context, block BlockInterface) (string, error)
}
BlockRenderer interface for frontend rendering (from frontend package).
type BlockType ¶ added in v1.14.0
type BlockType interface {
// TypeKey returns the unique identifier for this block type.
// This is stored in the database and used for lookups.
// Example: "gallery", "video", "custom_tree"
TypeKey() string
// TypeLabel returns the human-readable display name.
// This appears in the admin UI block type dropdown.
// Example: "Gallery Block", "Video Block", "Custom Tree Block"
TypeLabel() string
// Render renders the block for frontend display.
// This is called when the block appears on a page.
//
// Options can include runtime attributes via WithAttributes(attrs).
// Example:
// blockType.Render(ctx, block) // Without attributes
// blockType.Render(ctx, block, WithAttributes(map[string]string{"depth": "2"})) // With attributes
//
// Parameters:
// - ctx: Request context
// - block: The block to render
// - opts: Optional render options (variadic)
//
// Returns:
// - HTML string to display on the page
// - Error if rendering fails
Render(ctx context.Context, block BlockInterface, opts ...RenderOption) (string, error)
// GetAdminFields returns form fields for the admin content editing tab.
//
// This method is called when displaying the block edit form in the admin panel.
// Return an array of form fields that allow users to configure the block.
//
// Parameters:
// - block: The block being edited (use for reading current values)
// - r: The HTTP request (use for context, loading related data, etc.)
//
// Returns:
// - Array of form fields to display
GetAdminFields(block BlockInterface, r *http.Request) interface{}
// SaveAdminFields processes form submission and updates the block.
//
// This method is called when the user saves the content tab in the admin panel.
// Read form values, validate them, and update the block accordingly.
//
// Parameters:
// - r: The HTTP request containing form data
// - block: The block to update (modify in place)
//
// Returns:
// - Error if validation fails, or nil on success
SaveAdminFields(r *http.Request, block BlockInterface) error
}
func AdminOnlyAdapter ¶ added in v1.14.0
func AdminOnlyAdapter(typeKey, typeLabel string, adminProvider BlockAdminFieldProvider) BlockType
AdminOnlyAdapter creates a BlockType from just an admin provider.
This is useful when you only need admin UI and the frontend rendering is handled elsewhere (e.g., by a separate system).
Example:
adminProvider := &CustomAdminProvider{}
blockType := cmsstore.AdminOnlyAdapter("custom", "Custom Block", adminProvider)
cmsstore.RegisterBlockType(blockType)
func GetBlockType ¶ added in v1.14.0
GetBlockType retrieves a registered block type by its key.
Returns nil if no block type is registered with the given key. This method is thread-safe.
func NewBlockTypeAdapter ¶ added in v1.14.0
func NewBlockTypeAdapter(typeKey, typeLabel string, renderer BlockRenderer, adminProvider BlockAdminFieldProvider) BlockType
NewBlockTypeAdapter creates a new adapter that combines a renderer and admin provider.
Parameters:
- typeKey: Unique identifier for the block type (e.g., "html", "menu")
- typeLabel: Display name for the block type (e.g., "HTML Block")
- renderer: Frontend renderer implementation
- adminProvider: Admin UI provider implementation
Returns:
- A BlockType that can be registered with RegisterBlockType()
func RendererOnlyAdapter ¶ added in v1.14.0
func RendererOnlyAdapter(typeKey, typeLabel string, renderer BlockRenderer) BlockType
RendererOnlyAdapter creates a BlockType from just a renderer.
This is useful when you only need frontend rendering and don't need admin UI. The admin UI will fall back to a basic textarea editor.
Example:
renderer := &CustomRenderer{}
blockType := cmsstore.RendererOnlyAdapter("custom", "Custom Block", renderer)
cmsstore.RegisterBlockType(blockType)
type BlockTypeAdapter ¶ added in v1.14.0
type BlockTypeAdapter struct {
// contains filtered or unexported fields
}
BlockTypeAdapter wraps separate renderer and admin provider into a unified BlockType.
This adapter allows the new unified BlockType system to work with code that still uses the separate BlockRenderer and BlockAdminFieldProvider interfaces.
This is useful for:
- Backward compatibility with existing code
- Gradual migration to the unified system
- Wrapping built-in block types (HTML, Menu)
Example:
renderer := &HTMLRenderer{}
adminProvider := &HTMLAdminProvider{}
blockType := cmsstore.NewBlockTypeAdapter("html", "HTML Block", renderer, adminProvider)
cmsstore.RegisterBlockType(blockType)
func (*BlockTypeAdapter) GetAdminFields ¶ added in v1.14.0
func (a *BlockTypeAdapter) GetAdminFields(block BlockInterface, r *http.Request) interface{}
GetAdminFields delegates to the wrapped admin provider.
func (*BlockTypeAdapter) Render ¶ added in v1.14.0
func (a *BlockTypeAdapter) Render(ctx context.Context, block BlockInterface, opts ...RenderOption) (string, error)
Render delegates to the wrapped renderer. Attributes are ignored for legacy adapters.
func (*BlockTypeAdapter) SaveAdminFields ¶ added in v1.14.0
func (a *BlockTypeAdapter) SaveAdminFields(r *http.Request, block BlockInterface) error
SaveAdminFields delegates to the wrapped admin provider.
func (*BlockTypeAdapter) TypeKey ¶ added in v1.14.0
func (a *BlockTypeAdapter) TypeKey() string
TypeKey returns the unique identifier for this block type.
func (*BlockTypeAdapter) TypeLabel ¶ added in v1.14.0
func (a *BlockTypeAdapter) TypeLabel() string
TypeLabel returns the human-readable display name.
type BlockTypeRegistry ¶ added in v1.14.0
type BlockTypeRegistry struct {
// contains filtered or unexported fields
}
BlockTypeRegistry manages all registered block types.
This is a global registry that stores block type definitions. Both the frontend and admin systems use this registry to look up block types.
The registry is thread-safe and can be accessed concurrently.
func (*BlockTypeRegistry) Get ¶ added in v1.14.0
func (r *BlockTypeRegistry) Get(typeKey string) BlockType
Get retrieves a block type by its key.
func (*BlockTypeRegistry) GetAll ¶ added in v1.14.0
func (r *BlockTypeRegistry) GetAll() map[string]BlockType
GetAll returns all registered block types.
func (*BlockTypeRegistry) GetByOrigin ¶ added in v1.18.0
func (r *BlockTypeRegistry) GetByOrigin(origin string) map[string]BlockType
GetByOrigin returns all block types with the specified origin.
Use BLOCK_ORIGIN_SYSTEM for built-in types, BLOCK_ORIGIN_CUSTOM for user-defined.
func (*BlockTypeRegistry) GetKeys ¶ added in v1.14.0
func (r *BlockTypeRegistry) GetKeys() []string
GetKeys returns all registered block type keys.
func (*BlockTypeRegistry) GetOrigin ¶ added in v1.18.0
func (r *BlockTypeRegistry) GetOrigin(typeKey string) string
GetOrigin returns the origin for a block type (system/custom). Returns BLOCK_ORIGIN_CUSTOM as default if not explicitly set.
func (*BlockTypeRegistry) Register ¶ added in v1.14.0
func (r *BlockTypeRegistry) Register(blockType BlockType)
Register registers a block type in the registry.
func (*BlockTypeRegistry) RegisterWithOrigin ¶ added in v1.18.0
func (r *BlockTypeRegistry) RegisterWithOrigin(blockType BlockType, origin string)
RegisterWithOrigin registers a block type with a specified origin.
type CustomAttributeDefinition ¶ added in v1.20.0
type CustomAttributeDefinition struct {
Name string // Attribute name (e.g., "title", "price")
Type string // Data type: "string", "int", "float", "bool", "json"
Label string // Human-readable label for admin UI
Required bool // Whether the attribute is required
DefaultValue interface{} // Default value for the attribute
Validation string // Validation rules (optional)
Help string // Help text for admin UI
}
CustomAttributeDefinition defines the structure of a custom entity attribute.
type CustomEntityDefinition ¶ added in v1.20.0
type CustomEntityDefinition struct {
Type string // Entity type identifier (e.g., "shop_product", "blog_post")
TypeLabel string // Human-readable label (e.g., "Product", "Blog Post")
Group string // Group for admin navigation (e.g., "Shop", "Blog")
Icon string // Icon for admin UI (optional)
Attributes []CustomAttributeDefinition // Attribute definitions
// Relationship configuration
AllowRelationships bool // Whether this entity type supports relationships
AllowedRelationTypes []string // Allowed relationship types (e.g., "belongs_to", "has_many")
// Taxonomy configuration
AllowTaxonomies bool // Whether this entity type supports taxonomies
TaxonomyIDs []string // IDs of taxonomies that can be assigned to this entity type
}
CustomEntityDefinition defines a custom entity type configuration.
type CustomEntityStore ¶ added in v1.20.0
type CustomEntityStore struct {
// contains filtered or unexported fields
}
CustomEntityStore wraps entitystore to provide CMS-specific custom entity functionality.
func NewCustomEntityStore ¶ added in v1.20.0
func NewCustomEntityStore(db *sql.DB, options CustomEntityStoreOptions) (*CustomEntityStore, error)
NewCustomEntityStore creates a new custom entity store wrapper.
func (*CustomEntityStore) Count ¶ added in v1.20.0
func (s *CustomEntityStore) Count(ctx context.Context, options entitystore.EntityQueryOptions) (int64, error)
Count counts custom entities matching the query options.
func (*CustomEntityStore) Create ¶ added in v1.20.0
func (s *CustomEntityStore) Create( ctx context.Context, entityType string, attrs map[string]interface{}, relationships []RelationshipDefinition, taxonomyTermIDs []string, ) (string, error)
Create creates a new custom entity with attributes, relationships, and taxonomy assignments.
func (*CustomEntityStore) Delete ¶ added in v1.20.0
func (s *CustomEntityStore) Delete(ctx context.Context, entityID string) error
Delete soft-deletes a custom entity.
func (*CustomEntityStore) FindByID ¶ added in v1.20.0
func (s *CustomEntityStore) FindByID(ctx context.Context, entityID string) (entitystore.EntityInterface, error)
FindByID retrieves a custom entity by ID.
func (*CustomEntityStore) GetAllDefinitions ¶ added in v1.20.0
func (s *CustomEntityStore) GetAllDefinitions() []CustomEntityDefinition
GetAllDefinitions returns all registered entity type definitions.
func (*CustomEntityStore) GetEntityDefinition ¶ added in v1.20.0
func (s *CustomEntityStore) GetEntityDefinition(entityType string) (CustomEntityDefinition, bool)
GetEntityDefinition retrieves the definition for an entity type.
func (*CustomEntityStore) GetRelationships ¶ added in v1.20.0
func (s *CustomEntityStore) GetRelationships(ctx context.Context, entityID string) ([]entitystore.RelationshipInterface, error)
GetRelationships retrieves relationships for an entity.
func (*CustomEntityStore) GetTaxonomyAssignments ¶ added in v1.20.0
func (s *CustomEntityStore) GetTaxonomyAssignments(ctx context.Context, entityID string) ([]entitystore.EntityTaxonomyInterface, error)
GetTaxonomyAssignments retrieves taxonomy assignments for an entity.
func (*CustomEntityStore) Inner ¶ added in v1.20.0
func (s *CustomEntityStore) Inner() entitystore.StoreInterface
Inner returns the underlying entitystore for advanced operations.
func (*CustomEntityStore) List ¶ added in v1.20.0
func (s *CustomEntityStore) List(ctx context.Context, options entitystore.EntityQueryOptions) ([]entitystore.EntityInterface, error)
List retrieves custom entities with optional filtering.
func (*CustomEntityStore) RegisterEntityType ¶ added in v1.20.0
func (s *CustomEntityStore) RegisterEntityType(def CustomEntityDefinition) error
RegisterEntityType registers a custom entity type definition.
func (*CustomEntityStore) Update ¶ added in v1.20.0
func (s *CustomEntityStore) Update(ctx context.Context, entity entitystore.EntityInterface, attrs map[string]interface{}) error
Update updates a custom entity's attributes.
type CustomEntityStoreOptions ¶ added in v1.20.0
type CustomEntityStoreOptions struct {
EntityTableName string
AttributeTableName string
EntityTrashTableName string
AttributeTrashTableName string
AutomigrateEnabled bool
// Relationship options
RelationshipsEnabled bool
RelationshipTableName string
RelationshipTrashTableName string
// Taxonomy options
TaxonomiesEnabled bool
TaxonomyTableName string
TaxonomyTermTableName string
EntityTaxonomyTableName string
TaxonomyTrashTableName string
TaxonomyTermTrashTableName string
}
CustomEntityStoreOptions holds configuration options for the custom entity store.
type MenuInterface ¶
type MenuInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
MarshalToVersioning() (string, error)
CreatedAt() string
SetCreatedAt(createdAt string) MenuInterface
CreatedAtCarbon() *carbon.Carbon
Handle() string
SetHandle(handle string) MenuInterface
ID() string
SetID(id string) MenuInterface
Memo() string
SetMemo(memo string) MenuInterface
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) MenuInterface
SiteID() string
SetSiteID(siteID string) MenuInterface
SoftDeletedAt() string
SetSoftDeletedAt(softDeletedAt string) MenuInterface
SoftDeletedAtCarbon() *carbon.Carbon
Status() string
SetStatus(status string) MenuInterface
UpdatedAt() string
SetUpdatedAt(updatedAt string) MenuInterface
UpdatedAtCarbon() *carbon.Carbon
IsActive() bool
IsInactive() bool
IsSoftDeleted() bool
}
func NewMenu ¶
func NewMenu() MenuInterface
NewMenu creates a new menu instance with default values. It initializes the menu with a unique ID, draft status, and current timestamps.
type MenuItemInterface ¶
type MenuItemInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
MarshalToVersioning() (string, error)
CreatedAt() string
SetCreatedAt(createdAt string) MenuItemInterface
CreatedAtCarbon() *carbon.Carbon
Handle() string
SetHandle(handle string) MenuItemInterface
ID() string
SetID(id string) MenuItemInterface
Memo() string
SetMemo(memo string) MenuItemInterface
MenuID() string
SetMenuID(menuID string) MenuItemInterface
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) MenuItemInterface
PageID() string
SetPageID(pageID string) MenuItemInterface
ParentID() string
SetParentID(parentID string) MenuItemInterface
Sequence() string
SequenceInt() int
SetSequence(sequence string) MenuItemInterface
SetSequenceInt(sequence int) MenuItemInterface
SoftDeletedAt() string
SetSoftDeletedAt(softDeletedAt string) MenuItemInterface
SoftDeletedAtCarbon() *carbon.Carbon
Status() string
SetStatus(status string) MenuItemInterface
Target() string
SetTarget(target string) MenuItemInterface
UpdatedAt() string
SetUpdatedAt(updatedAt string) MenuItemInterface
UpdatedAtCarbon() *carbon.Carbon
URL() string
SetURL(url string) MenuItemInterface
IsActive() bool
IsInactive() bool
IsSoftDeleted() bool
}
func NewMenuItem ¶
func NewMenuItem() MenuItemInterface
NewMenuItem creates a new menu item with default values.
type MenuItemQueryInterface ¶
type MenuItemQueryInterface interface {
// Validate validates the query parameters.
Validate() error
// Columns returns the columns to be returned in the query.
Columns() []string
// HasColumns checks if the columns are set.
HasColumns() bool
// SetColumns sets the columns to be returned in the query.
SetColumns(columns []string) MenuItemQueryInterface
// HasCountOnly returns true if the query is for counting only.
HasCountOnly() bool
// IsCountOnly returns true if the query is for counting only.
IsCountOnly() bool
// SetCountOnly sets the query to be for counting only.
SetCountOnly(countOnly bool) MenuItemQueryInterface
// HasCreatedAtGte returns true if the query has a CreatedAtGte filter.
HasCreatedAtGte() bool
// CreatedAtGte returns the CreatedAtGte filter.
CreatedAtGte() string
// SetCreatedAtGte sets the CreatedAtGte filter.
SetCreatedAtGte(createdAtGte string) MenuItemQueryInterface
// HasCreatedAtLte returns true if the query has a CreatedAtLte filter.
HasCreatedAtLte() bool
// CreatedAtLte returns the CreatedAtLte filter.
CreatedAtLte() string
// SetCreatedAtLte sets the CreatedAtLte filter.
SetCreatedAtLte(createdAtLte string) MenuItemQueryInterface
// HasID returns true if the query has an ID filter.
HasID() bool
// ID returns the ID filter.
ID() string
// SetID sets the ID filter.
SetID(id string) MenuItemQueryInterface
// HasIDIn returns true if the query has an IDIn filter.
HasIDIn() bool
// IDIn returns the IDIn filter.
IDIn() []string
// SetIDIn sets the IDIn filter.
SetIDIn(idIn []string) MenuItemQueryInterface
// HasMenuID returns true if the query has a MenuID filter.
HasMenuID() bool
// MenuID returns the MenuID filter.
MenuID() string
// SetMenuID sets the MenuID filter.
SetMenuID(menuID string) MenuItemQueryInterface
// HasNameLike returns true if the query has a NameLike filter.
HasNameLike() bool
// NameLike returns the NameLike filter.
NameLike() string
// SetNameLike sets the NameLike filter.
SetNameLike(nameLike string) MenuItemQueryInterface
// HasOffset returns true if the query has an Offset.
HasOffset() bool
// Offset returns the Offset.
Offset() int
// SetOffset sets the Offset.
SetOffset(offset int) MenuItemQueryInterface
// HasLimit returns true if the query has a Limit.
HasLimit() bool
// Limit returns the Limit.
Limit() int
// SetLimit sets the Limit.
SetLimit(limit int) MenuItemQueryInterface
// HasSortOrder returns true if the query has a SortOrder.
HasSortOrder() bool
// SortOrder returns the SortOrder.
SortOrder() string
// SetSortOrder sets the SortOrder.
SetSortOrder(sortOrder string) MenuItemQueryInterface
// HasOrderBy returns true if the query has an OrderBy.
HasOrderBy() bool
// OrderBy returns the OrderBy.
OrderBy() string
// SetOrderBy sets the OrderBy.
SetOrderBy(orderBy string) MenuItemQueryInterface
// HasSiteID returns true if the query has a SiteID filter.
HasSiteID() bool
// SiteID returns the SiteID filter.
SiteID() string
// SetSiteID sets the SiteID filter.
SetSiteID(siteID string) MenuItemQueryInterface
// HasSoftDeletedIncluded returns true if soft deleted items should be included.
HasSoftDeletedIncluded() bool
// SoftDeletedIncluded returns true if soft deleted items should be included.
SoftDeletedIncluded() bool
// SetSoftDeletedIncluded sets whether soft deleted items should be included.
SetSoftDeletedIncluded(includeSoftDeleted bool) MenuItemQueryInterface
// HasStatus returns true if the query has a Status filter.
HasStatus() bool
// Status returns the Status filter.
Status() string
// SetStatus sets the Status filter.
SetStatus(status string) MenuItemQueryInterface
// HasStatusIn returns true if the query has a StatusIn filter.
HasStatusIn() bool
// StatusIn returns the StatusIn filter.
StatusIn() []string
// SetStatusIn sets the StatusIn filter.
SetStatusIn(statusIn []string) MenuItemQueryInterface
}
MenuItemQueryInterface defines the interface for querying menu items.
func MenuItemQuery ¶
func MenuItemQuery() MenuItemQueryInterface
MenuItemQuery returns a new instance of MenuItemQueryInterface. It initializes the properties map to store query parameters.
type MenuQueryInterface ¶
type MenuQueryInterface interface {
// Validate checks if the query parameters are valid.
Validate() error
// Columns returns the list of columns to be selected in the query.
Columns() []string
// HasColumns checks if the columns are set.
HasColumns() bool
// SetColumns sets the list of columns to be selected in the query.
SetColumns(columns []string) MenuQueryInterface
// HasCountOnly checks if the query is set to return only the count.
HasCountOnly() bool
// IsCountOnly returns true if the query is set to return only the count.
IsCountOnly() bool
// SetCountOnly sets the query to return only the count.
SetCountOnly(countOnly bool) MenuQueryInterface
// HasCreatedAtGte checks if the query has a 'created_at' greater than or equal to condition.
HasCreatedAtGte() bool
// CreatedAtGte returns the 'created_at' greater than or equal to condition.
CreatedAtGte() string
// SetCreatedAtGte sets the 'created_at' greater than or equal to condition.
SetCreatedAtGte(createdAtGte string) MenuQueryInterface
// HasCreatedAtLte checks if the query has a 'created_at' less than or equal to condition.
HasCreatedAtLte() bool
// CreatedAtLte returns the 'created_at' less than or equal to condition.
CreatedAtLte() string
// SetCreatedAtLte sets the 'created_at' less than or equal to condition.
SetCreatedAtLte(createdAtLte string) MenuQueryInterface
// HasHandle checks if the query has a 'handle' condition.
HasHandle() bool
// Handle returns the 'handle' condition.
Handle() string
// SetHandle sets the 'handle' condition.
SetHandle(handle string) MenuQueryInterface
// HasID checks if the query has an 'id' condition.
HasID() bool
// ID returns the 'id' condition.
ID() string
// SetID sets the 'id' condition.
SetID(id string) MenuQueryInterface
// HasIDIn checks if the query has an 'id' in condition.
HasIDIn() bool
// IDIn returns the 'id' in condition.
IDIn() []string
// SetIDIn sets the 'id' in condition.
SetIDIn(idIn []string) MenuQueryInterface
// HasNameLike checks if the query has a 'name' like condition.
HasNameLike() bool
// NameLike returns the 'name' like condition.
NameLike() string
// SetNameLike sets the 'name' like condition.
SetNameLike(nameLike string) MenuQueryInterface
// HasOffset checks if the query has an offset condition.
HasOffset() bool
// Offset returns the offset condition.
Offset() int
// SetOffset sets the offset condition.
SetOffset(offset int) MenuQueryInterface
// HasLimit checks if the query has a limit condition.
HasLimit() bool
// Limit returns the limit condition.
Limit() int
// SetLimit sets the limit condition.
SetLimit(limit int) MenuQueryInterface
// HasSortOrder checks if the query has a sort order condition.
HasSortOrder() bool
// SortOrder returns the sort order condition.
SortOrder() string
// SetSortOrder sets the sort order condition.
SetSortOrder(sortOrder string) MenuQueryInterface
// HasOrderBy checks if the query has an order by condition.
HasOrderBy() bool
// OrderBy returns the order by condition.
OrderBy() string
// SetOrderBy sets the order by condition.
SetOrderBy(orderBy string) MenuQueryInterface
// HasSiteID checks if the query has a 'site_id' condition.
HasSiteID() bool
// SiteID returns the 'site_id' condition.
SiteID() string
// SetSiteID sets the 'site_id' condition.
SetSiteID(siteID string) MenuQueryInterface
// HasSoftDeletedIncluded checks if the query includes soft deleted records.
HasSoftDeletedIncluded() bool
// SoftDeletedIncluded returns true if the query includes soft deleted records.
SoftDeletedIncluded() bool
// SetSoftDeletedIncluded sets whether the query should include soft deleted records.
SetSoftDeletedIncluded(includeSoftDeleted bool) MenuQueryInterface
// HasStatus checks if the query has a 'status' condition.
HasStatus() bool
// Status returns the 'status' condition.
Status() string
// SetStatus sets the 'status' condition.
SetStatus(status string) MenuQueryInterface
// HasStatusIn checks if the query has a 'status' in condition.
HasStatusIn() bool
// StatusIn returns the 'status' in condition.
StatusIn() []string
// SetStatusIn sets the 'status' in condition.
SetStatusIn(statusIn []string) MenuQueryInterface
}
MenuQueryInterface defines the methods required for querying menus.
func MenuQuery ¶
func MenuQuery() MenuQueryInterface
MenuQuery returns a new instance of MenuQueryInterface.
type MiddlewareInterface ¶
type MiddlewareInterface interface {
// Identifier is a unique identifier for internal use (e.g., "auth_before").
// Must be unique, and cannot be changed after creation.
Identifier() string
// Name is a human-friendly label for display purposes (e.g., "Authentication Middleware").
Name() string
// Description provides details about the middleware’s functionality.
Description() string
// Type specifies when the middleware is executed:
// - "before" → Runs before rendering page content.
// - "after" → Runs after rendering page content.
Type() string
// Handler returns the middleware function that processes HTTP requests.
Handler() func(next http.Handler) http.Handler
}
MiddlewareInterface defines the structure of a middleware.
type NewStoreOptions ¶
type NewStoreOptions struct {
// Context is the context used if the AutoMigrateEnabled option is true
// If not set, a background context is used
Context context.Context
// DB is the database connection
DB *sql.DB
// DbDriverName is the database driver name
// If not set, an attempt will be made to detect it
DbDriverName string
// AutomigrateEnabled enables automigrate
AutomigrateEnabled bool
// DebugEnabled enables debug
DebugEnabled bool
// BlockTableName is the name of the block database table to be created/used
BlockTableName string
// MenusEnabled enables menus
MenusEnabled bool
// MenuTableName is the name of the menu database table to be created/used
MenuTableName string
// MenuItemTableName is the name of the menu item database table to be created/used
MenuItemTableName string
// PageTableName is the name of the page database table to be created/used
PageTableName string
// SiteTableName is the name of the site database table to be created/used
SiteTableName string
TemplateTableName string
// TranslationsEnabled enables translations
TranslationsEnabled bool
// TranslationTableName is the name of the translation database table to be created/used
TranslationTableName string
// TranslationLanguageDefault is the default language, i.e en
TranslationLanguageDefault string
// TranslationLanguages is the list of supported languages
TranslationLanguages map[string]string
// VersioningEnabled enables versioning
VersioningEnabled bool
// VersioningTableName is the name of the versioning database table to be created/used
VersioningTableName string
// Shortcodes is a list of shortcodes to be registered
Shortcodes []ShortcodeInterface
// Middlewares is a list of middlewares to be registered
Middlewares []MiddlewareInterface
// CustomEntitiesEnabled enables custom entity support
CustomEntitiesEnabled bool
// CustomEntityStoreOptions holds configuration for custom entity store
CustomEntityStoreOptions CustomEntityStoreOptions
// CustomEntityDefinitions is a list of custom entity type definitions to register
CustomEntityDefinitions []CustomEntityDefinition
}
NewStoreOptions defines the options for creating a new block store
type Option ¶
type Option func(*Options)
Option is a function type that modifies an Options instance.
func WithContext ¶
WithContext sets the context for the CMS store operations.
func WithDryRun ¶
WithDryRun sets the dry run flag for the CMS store operations.
func WithTransaction ¶
WithTransaction sets the transaction for the CMS store operations.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options holds various configuration options for the CMS store operations.
type PageInterface ¶
type PageInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
MarshalToVersioning() (string, error)
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
MiddlewaresBefore() []string
SetMiddlewaresBefore(middlewaresBefore []string) PageInterface
MiddlewaresAfter() []string
SetMiddlewaresAfter(middlewaresAfter []string) PageInterface
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
}
type PageQueryInterface ¶
type PageQueryInterface interface {
// Validate checks if the query parameters are valid.
Validate() error
// Columns returns the list of columns to be queried.
Columns() []string
// HasColumns checks if the columns are set.
HasColumns() bool
// SetColumns sets the list of columns to be queried.
SetColumns(columns []string) PageQueryInterface
// HasAlias checks if an alias is set.
HasAlias() bool
// Alias returns the alias if set.
Alias() string
// SetAlias sets the alias.
SetAlias(alias string) PageQueryInterface
// HasAliasLike checks if an alias pattern is set.
HasAliasLike() bool
// AliasLike returns the alias pattern if set.
AliasLike() string
// SetAliasLike sets the alias pattern.
SetAliasLike(nameLike string) PageQueryInterface
// HasCreatedAtGte checks if a 'created at' greater-than-or-equal-to filter is set.
HasCreatedAtGte() bool
// CreatedAtGte returns the 'created at' greater-than-or-equal-to filter if set.
CreatedAtGte() string
// SetCreatedAtGte sets the 'created at' greater-than-or-equal-to filter.
SetCreatedAtGte(createdAtGte string) PageQueryInterface
// HasCreatedAtLte checks if a 'created at' less-than-or-equal-to filter is set.
HasCreatedAtLte() bool
// CreatedAtLte returns the 'created at' less-than-or-equal-to filter if set.
CreatedAtLte() string
// SetCreatedAtLte sets the 'created at' less-than-or-equal-to filter.
SetCreatedAtLte(createdAtLte string) PageQueryInterface
// HasCountOnly checks if count-only mode is set.
HasCountOnly() bool
// IsCountOnly returns the count-only mode setting.
IsCountOnly() bool
// SetCountOnly sets the count-only mode.
SetCountOnly(countOnly bool) PageQueryInterface
// HasHandle checks if a handle is set.
HasHandle() bool
// Handle returns the handle if set.
Handle() string
// SetHandle sets the handle.
SetHandle(handle string) PageQueryInterface
// HasID checks if an ID is set.
HasID() bool
// ID returns the ID if set.
ID() string
// SetID sets the ID.
SetID(id string) PageQueryInterface
// HasIDIn checks if an ID list is set.
HasIDIn() bool
// IDIn returns the ID list if set.
IDIn() []string
// SetIDIn sets the ID list.
SetIDIn(idIn []string) PageQueryInterface
// HasLimit checks if a limit is set.
HasLimit() bool
// Limit returns the limit if set.
Limit() int
// SetLimit sets the limit.
SetLimit(limit int) PageQueryInterface
// HasNameLike checks if a name pattern is set.
HasNameLike() bool
// NameLike returns the name pattern if set.
NameLike() string
// SetNameLike sets the name pattern.
SetNameLike(nameLike string) PageQueryInterface
// HasOffset checks if an offset is set.
HasOffset() bool
// Offset returns the offset if set.
Offset() int
// SetOffset sets the offset.
SetOffset(offset int) PageQueryInterface
// HasOrderBy checks if an order-by clause is set.
HasOrderBy() bool
// OrderBy returns the order-by clause if set.
OrderBy() string
// SetOrderBy sets the order-by clause.
SetOrderBy(orderBy string) PageQueryInterface
// HasSiteID checks if a site ID is set.
HasSiteID() bool
// SiteID returns the site ID if set.
SiteID() string
// SetSiteID sets the site ID.
SetSiteID(siteID string) PageQueryInterface
// HasSortOrder checks if a sort order is set.
HasSortOrder() bool
// SortOrder returns the sort order if set.
SortOrder() string
// SetSortOrder sets the sort order.
SetSortOrder(sortOrder string) PageQueryInterface
// HasSoftDeletedIncluded checks if soft-deleted records are included.
HasSoftDeletedIncluded() bool
// SoftDeletedIncluded returns whether soft-deleted records are included.
SoftDeletedIncluded() bool
// SetSoftDeletedIncluded sets whether to include soft-deleted records.
SetSoftDeletedIncluded(softDeleteIncluded bool) PageQueryInterface
// HasStatus checks if a status is set.
HasStatus() bool
// Status returns the status if set.
Status() string
// SetStatus sets the status.
SetStatus(status string) PageQueryInterface
// HasStatusIn checks if a status list is set.
HasStatusIn() bool
// StatusIn returns the status list if set.
StatusIn() []string
// SetStatusIn sets the status list.
SetStatusIn(statusIn []string) PageQueryInterface
// HasTemplateID checks if a template ID is set.
HasTemplateID() bool
// TemplateID returns the template ID if set.
TemplateID() string
// SetTemplateID sets the template ID.
SetTemplateID(templateID string) PageQueryInterface
}
PageQueryInterface defines methods for querying pages in the CMS store.
func PageQuery ¶
func PageQuery() PageQueryInterface
PageQuery returns a new instance of PageQueryInterface with an initialized map to hold query parameters.
type RelationshipDefinition ¶ added in v1.20.0
type RelationshipDefinition struct {
TargetID string // ID of the related entity
Type string // Relationship type (e.g., "belongs_to", "has_many")
Metadata map[string]interface{} // Additional metadata for the relationship
}
RelationshipDefinition defines a relationship to be created with an entity.
type RenderOption ¶ added in v1.19.0
type RenderOption func(*RenderOptions)
RenderOption configures block rendering behavior.
func WithAttributes ¶ added in v1.19.0
func WithAttributes(attrs map[string]string) RenderOption
WithAttributes passes runtime attributes to the block renderer. Used when blocks are referenced with attribute syntax:
<block id="menu_main" depth="2" style="sidebar" /> [[block id='menu_main' depth='2' style='sidebar']]
type RenderOptions ¶ added in v1.19.0
type RenderOptions struct {
// Attributes contains runtime attributes passed via block reference syntax.
// Example: <block id="menu" depth="2" /> results in {"depth": "2"}
Attributes map[string]string
}
RenderOptions holds rendering configuration.
type ShortcodeInterface ¶
type ShortcodeInterface interface {
// Alias returns a unique identifier for the shortcode.
Alias() string
// Description provides a brief explanation of the shortcode's purpose and usage.
Description() string
// Render generates the final output of the shortcode based on the provided
// HTTP request, shortcode name, and a map of attributes.
// r: HTTP request containing the context in which the shortcode is rendered.
// s: The name of the shortcode.
// m: A map of attributes and their values that configure the shortcode behavior.
Render(r *http.Request, s string, m map[string]string) string
}
ShortcodeInterface defines the methods that a shortcode must implement. A shortcode is a reusable snippet of code or content that can be rendered within a web page or template.
type SiteInterface ¶
type SiteInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
MarshalToVersioning() (string, error)
CreatedAt() string
SetCreatedAt(createdAt string) SiteInterface
CreatedAtCarbon() *carbon.Carbon
DomainNames() ([]string, error)
SetDomainNames(domainNames []string) (SiteInterface, error)
Handle() string
SetHandle(handle string) SiteInterface
ID() string
SetID(id 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
}
type SiteQueryInterface ¶
type SiteQueryInterface interface {
// Validate checks if the query parameters are valid.
Validate() error
// Columns returns the list of columns to be selected in the query.
Columns() []string
// HasColumns checks if the columns are set.
HasColumns() bool
// SetColumns sets the list of columns to be selected in the query.
SetColumns(columns []string) SiteQueryInterface
// HasCountOnly checks if the query is set to return only the count of records.
HasCountOnly() bool
// IsCountOnly returns true if the query is set to return only the count of records.
IsCountOnly() bool
// SetCountOnly sets the query to return only the count of records.
SetCountOnly(countOnly bool) SiteQueryInterface
// HasCreatedAtGte checks if the query has a 'created_at' greater than or equal to condition.
HasCreatedAtGte() bool
// CreatedAtGte returns the 'created_at' greater than or equal to condition.
CreatedAtGte() string
// SetCreatedAtGte sets the 'created_at' greater than or equal to condition.
SetCreatedAtGte(createdAtGte string) SiteQueryInterface
// HasCreatedAtLte checks if the query has a 'created_at' less than or equal to condition.
HasCreatedAtLte() bool
// CreatedAtLte returns the 'created_at' less than or equal to condition.
CreatedAtLte() string
// SetCreatedAtLte sets the 'created_at' less than or equal to condition.
SetCreatedAtLte(createdAtLte string) SiteQueryInterface
// HasDomainName checks if the query has a domain name condition.
HasDomainName() bool
// DomainName returns the domain name condition.
DomainName() string
// SetDomainName sets the domain name condition.
SetDomainName(domainName string) SiteQueryInterface
// HasHandle checks if the query has a handle condition.
HasHandle() bool
// Handle returns the handle condition.
Handle() string
// SetHandle sets the handle condition.
SetHandle(handle string) SiteQueryInterface
// HasID checks if the query has an ID condition.
HasID() bool
// ID returns the ID condition.
ID() string
// SetID sets the ID condition.
SetID(id string) SiteQueryInterface
// HasIDIn checks if the query has an ID in condition.
HasIDIn() bool
// IDIn returns the ID in condition.
IDIn() []string
// SetIDIn sets the ID in condition.
SetIDIn(idIn []string) SiteQueryInterface
// HasLimit checks if the query has a limit condition.
HasLimit() bool
// Limit returns the limit condition.
Limit() int
// SetLimit sets the limit condition.
SetLimit(limit int) SiteQueryInterface
// HasNameLike checks if the query has a name like condition.
HasNameLike() bool
// NameLike returns the name like condition.
NameLike() string
// SetNameLike sets the name like condition.
SetNameLike(nameLike string) SiteQueryInterface
// HasOffset checks if the query has an offset condition.
HasOffset() bool
// Offset returns the offset condition.
Offset() int
// SetOffset sets the offset condition.
SetOffset(offset int) SiteQueryInterface
// HasSortOrder checks if the query has a sort order condition.
HasSortOrder() bool
// SortOrder returns the sort order condition.
SortOrder() string
// SetSortOrder sets the sort order condition.
SetSortOrder(sortOrder string) SiteQueryInterface
// HasOrderBy checks if the query has an order by condition.
HasOrderBy() bool
// OrderBy returns the order by condition.
OrderBy() string
// SetOrderBy sets the order by condition.
SetOrderBy(orderBy string) SiteQueryInterface
// HasSoftDeletedIncluded checks if the query includes soft deleted records.
HasSoftDeletedIncluded() bool
// SoftDeletedIncluded returns true if the query includes soft deleted records.
SoftDeletedIncluded() bool
// SetSoftDeletedIncluded sets the query to include soft deleted records.
SetSoftDeletedIncluded(softDeletedIncluded bool) SiteQueryInterface
// HasStatus checks if the query has a status condition.
HasStatus() bool
// Status returns the status condition.
Status() string
// SetStatus sets the status condition.
SetStatus(status string) SiteQueryInterface
// HasStatusIn checks if the query has a status in condition.
HasStatusIn() bool
// StatusIn returns the status in condition.
StatusIn() []string
// SetStatusIn sets the status in condition.
SetStatusIn(statusIn []string) SiteQueryInterface
}
SiteQueryInterface defines the methods required for querying site data.
func SiteQuery ¶
func SiteQuery() SiteQueryInterface
SiteQuery returns a new instance of SiteQueryInterface with an initialized parameters map.
type StoreInterface ¶
type StoreInterface interface {
AutoMigrate(ctx context.Context, opts ...Option) error
EnableDebug(debug bool)
BlockCreate(ctx context.Context, block BlockInterface) error
BlockCount(ctx context.Context, options BlockQueryInterface) (int64, error)
BlockDelete(ctx context.Context, block BlockInterface) error
BlockDeleteByID(ctx context.Context, id string) error
BlockFindByHandle(ctx context.Context, blockHandle string) (BlockInterface, error)
BlockFindByID(ctx context.Context, blockID string) (BlockInterface, error)
BlockList(ctx context.Context, query BlockQueryInterface) ([]BlockInterface, error)
BlockSoftDelete(ctx context.Context, block BlockInterface) error
BlockSoftDeleteByID(ctx context.Context, id string) error
BlockUpdate(ctx context.Context, block BlockInterface) error
MenusEnabled() bool
MenuCreate(ctx context.Context, menu MenuInterface) error
MenuCount(ctx context.Context, options MenuQueryInterface) (int64, error)
MenuDelete(ctx context.Context, menu MenuInterface) error
MenuDeleteByID(ctx context.Context, id string) error
MenuFindByHandle(ctx context.Context, menuHandle string) (MenuInterface, error)
MenuFindByID(ctx context.Context, menuID string) (MenuInterface, error)
MenuList(ctx context.Context, query MenuQueryInterface) ([]MenuInterface, error)
MenuSoftDelete(ctx context.Context, menu MenuInterface) error
MenuSoftDeleteByID(ctx context.Context, id string) error
MenuUpdate(ctx context.Context, menu MenuInterface) error
MenuItemCreate(ctx context.Context, menuItem MenuItemInterface) error
MenuItemCount(ctx context.Context, options MenuItemQueryInterface) (int64, error)
MenuItemDelete(ctx context.Context, menuItem MenuItemInterface) error
MenuItemDeleteByID(ctx context.Context, id string) error
MenuItemFindByID(ctx context.Context, menuItemID string) (MenuItemInterface, error)
MenuItemList(ctx context.Context, query MenuItemQueryInterface) ([]MenuItemInterface, error)
MenuItemSoftDelete(ctx context.Context, menuItem MenuItemInterface) error
MenuItemSoftDeleteByID(ctx context.Context, id string) error
MenuItemUpdate(ctx context.Context, menuItem MenuItemInterface) error
PageCreate(ctx context.Context, page PageInterface) error
PageCount(ctx context.Context, options PageQueryInterface) (int64, error)
PageDelete(ctx context.Context, page PageInterface) error
PageDeleteByID(ctx context.Context, id string) error
PageFindByHandle(ctx context.Context, pageHandle string) (PageInterface, error)
PageFindByID(ctx context.Context, pageID string) (PageInterface, error)
PageList(ctx context.Context, query PageQueryInterface) ([]PageInterface, error)
PageSoftDelete(ctx context.Context, page PageInterface) error
PageSoftDeleteByID(ctx context.Context, id string) error
PageUpdate(ctx context.Context, page PageInterface) error
SiteCreate(ctx context.Context, site SiteInterface) error
SiteCount(ctx context.Context, options SiteQueryInterface) (int64, error)
SiteDelete(ctx context.Context, site SiteInterface) error
SiteDeleteByID(ctx context.Context, id string) error
SiteFindByDomainName(ctx context.Context, siteDomainName string) (SiteInterface, error)
SiteFindByHandle(ctx context.Context, siteHandle string) (SiteInterface, error)
SiteFindByID(ctx context.Context, siteID string) (SiteInterface, error)
SiteList(ctx context.Context, query SiteQueryInterface) ([]SiteInterface, error)
SiteSoftDelete(ctx context.Context, site SiteInterface) error
SiteSoftDeleteByID(ctx context.Context, id string) error
SiteUpdate(ctx context.Context, site SiteInterface) error
TemplateCreate(ctx context.Context, template TemplateInterface) error
TemplateCount(ctx context.Context, options TemplateQueryInterface) (int64, error)
TemplateDelete(ctx context.Context, template TemplateInterface) error
TemplateDeleteByID(ctx context.Context, id string) error
TemplateFindByHandle(ctx context.Context, templateHandle string) (TemplateInterface, error)
TemplateFindByID(ctx context.Context, templateID string) (TemplateInterface, error)
TemplateList(ctx context.Context, query TemplateQueryInterface) ([]TemplateInterface, error)
TemplateSoftDelete(ctx context.Context, template TemplateInterface) error
TemplateSoftDeleteByID(ctx context.Context, id string) error
TemplateUpdate(ctx context.Context, template TemplateInterface) error
TranslationsEnabled() bool
TranslationCreate(ctx context.Context, translation TranslationInterface) error
TranslationCount(ctx context.Context, options TranslationQueryInterface) (int64, error)
TranslationDelete(ctx context.Context, translation TranslationInterface) error
TranslationDeleteByID(ctx context.Context, id string) error
TranslationFindByHandle(ctx context.Context, translationHandle string) (TranslationInterface, error)
TranslationFindByHandleOrID(ctx context.Context, translationHandleOrID string, language string) (TranslationInterface, error)
TranslationFindByID(ctx context.Context, translationID string) (TranslationInterface, error)
TranslationList(ctx context.Context, query TranslationQueryInterface) ([]TranslationInterface, error)
TranslationSoftDelete(ctx context.Context, translation TranslationInterface) error
TranslationSoftDeleteByID(ctx context.Context, id string) error
TranslationUpdate(ctx context.Context, translation TranslationInterface) error
TranslationLanguageDefault() string
TranslationLanguages() map[string]string
// Versioning
VersioningEnabled() bool
VersioningCreate(ctx context.Context, versioning VersioningInterface) error
// VersioningCount(options VersioningQueryInterface) (int64, error)
VersioningDelete(ctx context.Context, versioning VersioningInterface) error
VersioningDeleteByID(ctx context.Context, id string) error
VersioningFindByID(ctx context.Context, versioningID string) (VersioningInterface, error)
VersioningList(ctx context.Context, query VersioningQueryInterface) ([]VersioningInterface, error)
VersioningSoftDelete(ctx context.Context, versioning VersioningInterface) error
VersioningSoftDeleteByID(ctx context.Context, id string) error
VersioningUpdate(ctx context.Context, versioning VersioningInterface) error
Shortcodes() []ShortcodeInterface
AddShortcode(shortcode ShortcodeInterface)
AddShortcodes(shortcodes []ShortcodeInterface)
SetShortcodes(shortcodes []ShortcodeInterface)
Middlewares() []MiddlewareInterface
AddMiddleware(middleware MiddlewareInterface)
AddMiddlewares(middlewares []MiddlewareInterface)
SetMiddlewares(middlewares []MiddlewareInterface)
// Custom Entities
CustomEntitiesEnabled() bool
CustomEntityStore() *CustomEntityStore
}
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new CMS store based on the provided options.
type TemplateInterface ¶
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 ¶
func NewTemplate() TemplateInterface
func NewTemplateFromExistingData ¶
func NewTemplateFromExistingData(data map[string]string) TemplateInterface
type TemplateQueryInterface ¶
type TemplateQueryInterface interface {
Validate() error
Columns() []string
HasColumns() bool
SetColumns(columns []string) TemplateQueryInterface
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 ¶
func TemplateQuery() TemplateQueryInterface
type TranslationInterface ¶
type TranslationInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
ID() string
SetID(id string) TranslationInterface
CreatedAt() string
SetCreatedAt(createdAt string) TranslationInterface
CreatedAtCarbon() *carbon.Carbon
Content() (languageCodeContent map[string]string, err error)
SetContent(languageCodeContent map[string]string) error
Handle() string
SetHandle(handle string) TranslationInterface
Memo() string
SetMemo(memo string) TranslationInterface
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) TranslationInterface
SiteID() string
SetSiteID(siteID string) TranslationInterface
SoftDeletedAt() string
SetSoftDeletedAt(softDeletedAt string) TranslationInterface
SoftDeletedAtCarbon() *carbon.Carbon
Status() string
SetStatus(status string) TranslationInterface
UpdatedAt() string
SetUpdatedAt(updatedAt string) TranslationInterface
UpdatedAtCarbon() *carbon.Carbon
IsActive() bool
IsInactive() bool
IsSoftDeleted() bool
}
func NewTranslation ¶
func NewTranslation() TranslationInterface
func NewTranslationFromExistingData ¶
func NewTranslationFromExistingData(data map[string]string) TranslationInterface
type TranslationQueryInterface ¶
type TranslationQueryInterface interface {
Validate() error
Columns() []string
HasColumns() bool
SetColumns(columns []string) TranslationQueryInterface
HasCountOnly() bool
IsCountOnly() bool
SetCountOnly(countOnly bool) TranslationQueryInterface
HasCreatedAtGte() bool
CreatedAtGte() string
SetCreatedAtGte(createdAtGte string) TranslationQueryInterface
HasCreatedAtLte() bool
CreatedAtLte() string
SetCreatedAtLte(createdAtLte string) TranslationQueryInterface
HasHandle() bool
Handle() string
SetHandle(handle string) TranslationQueryInterface
HasHandleOrID() bool
HandleOrID() string
SetHandleOrID(handleOrID string) TranslationQueryInterface
HasID() bool
ID() string
SetID(id string) TranslationQueryInterface
HasIDIn() bool
IDIn() []string
SetIDIn(idIn []string) TranslationQueryInterface
HasNameLike() bool
NameLike() string
SetNameLike(nameLike string) TranslationQueryInterface
HasOffset() bool
Offset() int
SetOffset(offset int) TranslationQueryInterface
HasLimit() bool
Limit() int
SetLimit(limit int) TranslationQueryInterface
HasSortOrder() bool
SortOrder() string
SetSortOrder(sortOrder string) TranslationQueryInterface
HasOrderBy() bool
OrderBy() string
SetOrderBy(orderBy string) TranslationQueryInterface
HasSiteID() bool
SiteID() string
SetSiteID(siteID string) TranslationQueryInterface
HasSoftDeletedIncluded() bool
SoftDeletedIncluded() bool
SetSoftDeletedIncluded(includeSoftDeleted bool) TranslationQueryInterface
HasStatus() bool
Status() string
SetStatus(status string) TranslationQueryInterface
HasStatusIn() bool
StatusIn() []string
SetStatusIn(statusIn []string) TranslationQueryInterface
}
func TranslationQuery ¶
func TranslationQuery() TranslationQueryInterface
type VersioningInterface ¶
type VersioningInterface interface {
versionstore.VersionInterface
}
func NewVersioning ¶
func NewVersioning() VersioningInterface
type VersioningQueryInterface ¶
type VersioningQueryInterface interface {
versionstore.VersionQueryInterface
}
func NewVersioningQuery ¶
func NewVersioningQuery() VersioningQueryInterface
Source Files
¶
- block.go
- block_query.go
- block_query_interface.go
- block_table_create_sql.go
- block_type.go
- block_type_adapters.go
- consts.go
- custom_entity_definition.go
- custom_entity_store.go
- id_helpers.go
- interfaces.go
- menu_implementation.go
- menu_item_implementation.go
- menu_item_query.go
- menu_item_query_interface.go
- menu_item_table_create_sql.go
- menu_query.go
- menu_query_interface.go
- menu_table_create_sql.go
- middleware.go
- options.go
- page_implementation.go
- page_query.go
- page_query_interface.go
- page_table_create_sql.go
- shortcode_interface.go
- site_implementation.go
- site_query.go
- site_query_interface.go
- site_table_create_sql.go
- store.go
- store_blocks.go
- store_menu_items.go
- store_menus.go
- store_new.go
- store_pages.go
- store_sites.go
- store_templates.go
- store_translations.go
- store_versioning.go
- template_implementation.go
- template_query.go
- template_query_interface.go
- template_table_create_sql.go
- translation_implementation.go
- translation_query.go
- translation_query_interface.go
- translation_table_create_sql.go
Directories
¶
| Path | Synopsis |
|---|---|
|
development
command
|
|
|
blocks
|
|
|
examples
|
|
|
basic-example
command
|
|
|
custom-block-types
command
|
|
|
customentities/01-basic-usage
command
|
|
|
customentities/02-relationships
command
|
|
|
customentities/03-taxonomy
command
|
|
|
Package frontend provides a CMS frontend rendering system.
|
Package frontend provides a CMS frontend rendering system. |