Documentation
¶
Index ¶
- Constants
- func ContentFindIdsByPatternPrefix(content, prefix string) []string
- func WebpageComplete(title, content string) *hb.HtmlWebpage
- type Cms
- func (cms *Cms) BlockFindByID(blockID string) (types.WebBlockInterface, error)
- func (cms *Cms) ContentRenderBlockByID(content string, blockID string) (string, error)
- func (cms *Cms) ContentRenderBlocks(content string) (string, error)
- func (cms *Cms) ContentRenderShortcodes(req *http.Request, content string) (string, error)
- func (cms *Cms) ContentRenderTranslationByIdOrHandle(content string, translationID string, language string) (string, error)
- func (cms *Cms) ContentRenderTranslations(content string, language string) (string, error)
- func (cms *Cms) FrontendHandler(w http.ResponseWriter, r *http.Request)
- func (cms *Cms) FrontendHandlerRenderAsString(w http.ResponseWriter, r *http.Request) string
- func (cms *Cms) PageFindByAlias(alias string) (*entitystore.Entity, error)
- func (cms *Cms) PageFindByAliasWithPatterns(alias string) (*entitystore.Entity, error)
- func (cms *Cms) PageRenderHtmlByAlias(r *http.Request, alias string, language string) string
- func (cms Cms) Router(w http.ResponseWriter, r *http.Request)
- func (c *Cms) SetFuncLayout(funcLayout func(content string) string) *Cms
- func (cms *Cms) ShortcodeAdd(shortcode ShortcodeInterface)
- func (cms *Cms) ShortcodesAdd(shortcodes []ShortcodeInterface)
- func (cms *Cms) TemplateContentFindByID(templateID string) (string, error)
- func (cms *Cms) TemplateFindByID(templateID string) (*entitystore.Entity, error)
- func (cms *Cms) TemplateRenderHtmlByID(r *http.Request, templateID string, options struct{ ... }) (string, error)
- func (cms *Cms) TranslationFindByIdOrHandle(idOrHandle string, language string) (string, error)
- func (cms *Cms) WebPageCount(options WebPageQueryOptions) (int64, error)
- func (cms *Cms) WebPageCreate(page types.WebPageInterface) error
- func (cms *Cms) WebPageFindByID(pageID string) (types.WebPageInterface, error)
- func (cms *Cms) WebPageList(options WebPageQueryOptions) ([]types.WebPageInterface, error)
- func (cms *Cms) WebPageUpdate(page types.WebPageInterface) error
- type Config
- type CustomAttributeStructure
- type CustomEntityStructure
- type LanguageKey
- type ShortcodeInterface
- type WebPageQueryOptions
Constants ¶
const ( // PathHome contains the path to admin CMS home page PathHome string = "home" // PathUsersHome contains the path to admin user home page PathUsersHome string = "user-home" // START: Blocks // PathBlocksBlockCreateAjax contains the path to admin block create page PathBlocksBlockCreateAjax string = "blocks/block-create-ajax" // PathBlocksBlockDeleteAjax contains the path to admin block delete page PathBlocksBlockDeleteAjax string = "blocks/block-delete-ajax" // PathBlocksBlockManager contains the path to admin block create page PathBlocksBlockManager string = "blocks/block-manager" // PathBlocksBlockTrashAjax contains the path to admin block trash page PathBlocksBlockTrashAjax string = "blocks/block-trash-ajax" // PathBlocksBlockUpdate contains the path to admin block update page PathBlocksBlockUpdate string = "blocks/block-update" // PathBlocksBlockUpdateAjax contains the path to admin block update page PathBlocksBlockUpdateAjax string = "blocks/block-update-ajax" // START: Menus // PathMenusMenuManager contains the path to admin block update page PathMenusMenuManager string = "menus/menu-manager" // PathMenusMenuCreateAjax contains the path to admin block update page PathMenusMenuCreateAjax string = "manus/menu-create-ajax" // PathMenusMenuUpdate contains the path to admin block update page PathMenusMenuUpdate string = "manus/menu-update" // PathMenusMenuItemsFetchAjax contains the path to admin block update page PathMenusMenuItemsFetchAjax string = "menus/menu-items-fetch-ajax" // PathMenusMenuItemsUpdateAjax contains the path to admin block update page PathMenusMenuItemsUpdateAjax string = "menus/menu-items-update-ajax" // PathMenusMenuItemsUpdate contains the path to admin block update page PathMenusMenuItemsUpdate string = "manus/menu-items-update" // PathMenusMenuUpdateAjax contains the path to admin block update page PathMenusMenuUpdateAjax string = "menus/menu-update-ajax" // START: Pages // PathPagesPageManager contains the path to admin page manager page PathPagesPageManager string = "pages/page-manager" // PathPagesPageCreateAjax contains the path to admin page update page PathPagesPageCreateAjax string = "pages/page-create-ajax" // PathPagesPageTrashAjax contains the path to admin move page to trash PathPagesPageTrashAjax string = "pages/page-trash-ajax" // PathPagesPageUpdate contains the path to admin page update page PathPagesPageUpdate string = "pages/page-update" // PathPagesPageUpdateAjax contains the path to admin page update ajax page PathPagesPageUpdateAjax string = "pages/page-update-ajax" // START: Templates // PathTemplatesTemplateCreateAjax contains the path to admin template create page ajax PathTemplatesTemplateCreateAjax string = "templates/template-create-ajax" // PathTemplatesTemplateManager contains the path to admin template manager page PathTemplatesTemplateManager string = "templates/template-manager" // PathTemplatesTemplateTrashAjax contains the path to template trash page PathTemplatesTemplateTrashAjax string = "templates/template-trash-ajax" // PathTemplatesTemplateUpdate contains the path to admin template update page PathTemplatesTemplateUpdate string = "templates/template-update" // PathTemplatesTemplateUpdateAjax contains the path to admin template update page ajax PathTemplatesTemplateUpdateAjax string = "templates/template-update-ajax" // START: Widgets // PathWidgetsWidgetManager contains the path to admin widget manager page PathWidgetsWidgetManager string = "widgets/widget-manager" // PathWidgetsWidgetCreateAjax contains the path to admin widget create page PathWidgetsWidgetCreateAjax string = "widgets/widget-create-ajax" // PathWidgetsWidgetUpdate contains the path to admin widget update page PathWidgetsWidgetUpdate string = "widgets/widget-update" // PathWidgetsWidgetUpdateAjax contains the path to admin widget update ajax PathWidgetsWidgetUpdateAjax string = "widgets/widget-update-ajax" // START: Settings // PathSettingsSettingManager contains the path to admin settings manager page PathSettingsSettingManager string = "settings/setting-manager" // PathSettingsSettingCreateAjax contains the path to admin settings create page PathSettingsSettingCreateAjax string = "settings/setting-create-ajax" // PathSettingsSettingDeleteAjax contains the path to admin settings delete page PathSettingsSettingDeleteAjax string = "settings/setting-delete-ajax" // PathSettingsSettingUpdate contains the path to admin settings update page PathSettingsSettingUpdate string = "settings/setting-update" // PathSettingsSettingUpdateAjax contains the path to admin settings update page PathSettingsSettingUpdateAjax string = "settings/setting-update-ajax" // START: Translations // PathTranslationsTranslationManager contains the path to admin translations manager page PathTranslationsTranslationManager string = "translations/translation-manager" // PathTranslationsTranslationCreateAjax contains the path to admin translations create page PathTranslationsTranslationCreateAjax string = "translations/translation-create-ajax" // PathTranslationsTranslationDeleteAjax contains the path to admin translations delete page PathTranslationsTranslationDeleteAjax string = "translations/translation-delete-ajax" // PathTranslationsTranslationTrashAjax contains the path to admin translations trash page PathTranslationsTranslationTrashAjax string = "translations/translation-trash-ajax" // PathTranslationsTranslationUpdate contains the path to admin translations update page PathTranslationsTranslationUpdate string = "translations/translation-update" // PathTranslationsTranslationUpdateAjax contains the path to admin translations update page PathTranslationsTranslationUpdateAjax string = "translations/translation-update-ajax" // START: Users // PathUsersUserManager contains the path to admin users manager page PathUsersUserManager string = "users/user-manager" // PathUsersUserCreateAjax contains the path to admin users create page PathUsersUserCreateAjax string = "users/user-create-ajax" // PathUsersUserDeleteAjax contains the path to admin users delete page PathUsersUserTrashAjax string = "users/user-trash-ajax" // PathUsersUserUpdate contains the path to admin users update page PathUsersUserUpdate string = "users/user-update" // PathUsersUserUpdateAjax contains the path to admin users update page PathUsersUserUpdateAjax string = "users/user-update-ajax" // START: Websites // PathWebsitesWebsiteManager contains the path to admin websites manager page PathWebsitesWebsiteManager string = "websites/website-manager" // START: Custom Entities // PathEntitiesEntityManager contains the path to admin entities update page PathEntitiesEntityManager string = "entities/entity-manager" // PathWidgetsWidgetCreateAjax contains the path to admin block update page PathEntitiesEntityCreateAjax string = "entities/entity-create-ajax" // PathWidgetsWidgetUpdate contains the path to admin block update page PathEntitiesEntityUpdate string = "entities/entity-update" // PathWidgetsWidgetUpdateAjax contains the path to admin block update page PathEntitiesEntityUpdateAjax string = "entities/entity-update-ajax" )
const COLUMN_ID = "id"
const ENTITY_TYPE_BLOCK = "block"
const ENTITY_TYPE_MENU = "menu"
const ENTITY_TYPE_MENUITEM = "menuitem"
const ENTITY_TYPE_PAGE = "page"
const ENTITY_TYPE_TEMPLATE = "template"
const ENTITY_TYPE_TRANSLATION = "translation"
const ENTITY_TYPE_USER = "user"
const ENTITY_TYPE_WEBSITE = "website"
const ENTITY_TYPE_WIDGET = "widget"
Variables ¶
This section is empty.
Functions ¶
func ContentFindIdsByPatternPrefix ¶
returns the IDs in the content who have the following format [[prefix_id]]
func WebpageComplete ¶ added in v1.4.1
func WebpageComplete(title, content string) *hb.HtmlWebpage
WebpageComplete returns the webpage template for the website
Types ¶
type Cms ¶
type Cms struct { Database sb.DatabaseInterface CacheStore cachestore.StoreInterface EntityStore entitystore.StoreInterface LogStore logstore.StoreInterface SessionStore sessionstore.StoreInterface SettingStore settingstore.StoreInterface TaskStore taskstore.StoreInterface UserStore entitystore.StoreInterface // contains filtered or unexported fields }
Cms defines the cms
func NewCms ¶
NewCms creates a new CMS instance based on the given configuration
Parameters: - config Config - the CMS configuration
Returns: - *Cms - the new CMS instance - error - any error if occurred, nil otherwise
func (*Cms) BlockFindByID ¶
func (cms *Cms) BlockFindByID(blockID string) (types.WebBlockInterface, error)
func (*Cms) ContentRenderBlockByID ¶
ContentRenderBlockByID renders the block specified by the ID in a content if the blockID is empty or not found the initial content is returned
func (*Cms) ContentRenderBlocks ¶
RenderBlocks renders the blocks in a string
func (*Cms) ContentRenderShortcodes ¶
ContentRenderShortcodes renders the shortcodes in a string
func (*Cms) ContentRenderTranslationByIdOrHandle ¶
func (cms *Cms) ContentRenderTranslationByIdOrHandle(content string, translationID string, language string) (string, error)
ContentRenderTranslationByIdOrHandle renders the translation specified by the ID in a content if the blockID is empty or not found the initial content is returned
func (*Cms) ContentRenderTranslations ¶
ContentRenderTranslations renders the translations in a string
func (*Cms) FrontendHandler ¶
func (cms *Cms) FrontendHandler(w http.ResponseWriter, r *http.Request)
FrontendHandler is the main handler for the CMS frontend.
It handles the routing of the request to the appropriate page.
If the URI ends with ".ico", it will return a blank response, as the browsers (at least Chrome and Firefox) will always request the favicon even if it's not present in the HTML.
func (*Cms) FrontendHandlerRenderAsString ¶
FrontendHandlerRenderAsString is the same as FrontendHandler but returns a string instead of writing to the http.ResponseWriter.
It handles the routing of the request to the appropriate page.
If the URI ends with ".ico", it will return a blank response, as the browsers (at least Chrome and Firefox) will always request the favicon even if it's not present in the HTML.
If the translations are enabled, it will use the language from the request context. If the language is not valid, it will use the default language for the translations.
func (*Cms) PageFindByAlias ¶
func (cms *Cms) PageFindByAlias(alias string) (*entitystore.Entity, error)
PageFindByAlias helper method to find a page by alias
=====================================================================
- It will attempt to find the page by the provided alias exactly as provided
- It will attempt to find the page with the alias prefixed with "/" in case of error
=====================================================================
func (*Cms) PageFindByAliasWithPatterns ¶
func (cms *Cms) PageFindByAliasWithPatterns(alias string) (*entitystore.Entity, error)
PageFindByAliasWithPatterns helper method to find a page by matching patterns
=====================================================================
The following patterns are supported: :any :num :all :string :number :numeric :alpha
=====================================================================
func (*Cms) PageRenderHtmlByAlias ¶
PageRenderHtmlByAlias builds the HTML of a page based on its alias
func (Cms) Router ¶
func (cms Cms) Router(w http.ResponseWriter, r *http.Request)
Router shows the admin page
func (*Cms) SetFuncLayout ¶
SetFuncLayout sets a layout for the CMS to display inside
func (*Cms) ShortcodeAdd ¶
func (cms *Cms) ShortcodeAdd(shortcode ShortcodeInterface)
func (*Cms) ShortcodesAdd ¶
func (cms *Cms) ShortcodesAdd(shortcodes []ShortcodeInterface)
func (*Cms) TemplateContentFindByID ¶
func (*Cms) TemplateFindByID ¶
func (cms *Cms) TemplateFindByID(templateID string) (*entitystore.Entity, error)
func (*Cms) TemplateRenderHtmlByID ¶ added in v1.4.2
func (cms *Cms) TemplateRenderHtmlByID(r *http.Request, templateID string, options struct { PageContent string PageCanonicalURL string PageMetaDescription string PageMetaKeywords string PageMetaRobots string PageTitle string Language string }) (string, error)
TemplateRenderHtmlByID builds the HTML of a template based on its ID
func (*Cms) TranslationFindByIdOrHandle ¶
func (*Cms) WebPageCount ¶ added in v1.6.0
func (cms *Cms) WebPageCount(options WebPageQueryOptions) (int64, error)
func (*Cms) WebPageCreate ¶ added in v1.6.0
func (cms *Cms) WebPageCreate(page types.WebPageInterface) error
func (*Cms) WebPageFindByID ¶ added in v1.6.0
func (cms *Cms) WebPageFindByID(pageID string) (types.WebPageInterface, error)
func (*Cms) WebPageList ¶ added in v1.6.0
func (cms *Cms) WebPageList(options WebPageQueryOptions) ([]types.WebPageInterface, error)
func (*Cms) WebPageUpdate ¶ added in v1.6.0
func (cms *Cms) WebPageUpdate(page types.WebPageInterface) error
type Config ¶
type Config struct { Database sb.DatabaseInterface DbInstance *sql.DB DbDriver string DbDsn string CustomEntityList []CustomEntityStructure Prefix string BlocksEnable bool BlockEditorDefinitions []blockeditor.BlockDefinition BlockEditorRenderer func(blocks []ui.BlockInterface) string CacheAutomigrate bool CacheEnable bool EntitiesAutomigrate bool LogsEnable bool LogsAutomigrate bool MenusEnable bool PagesEnable bool SessionAutomigrate bool SessionEnable bool SettingsAutomigrate bool SettingsEnable bool Shortcodes []ShortcodeInterface TasksEnable bool TasksAutomigrate bool TasksQueueTableName string TasksTaskTableName string TemplatesEnable bool TranslationsEnable bool TranslationLanguageDefault string TranslationLanguages map[string]string UsersEnable bool UsersAutomigrate bool DashboardEnable bool WidgetsEnable bool FuncLayout func(content string) string }
type CustomAttributeStructure ¶
type CustomAttributeStructure struct { // Name the name of the attribute Name string // Type of the attribute - string, float, int Type string // FormControlLabel label to display for the control FormControlLabel string // FormControlType the type of form control - input, textarea. etc FormControlType string // FormControlHelp help message to display for the control FormControlHelp string // BelongsToType describes a Belong To relationsip BelongsToType string // HasOneType describes a Has One relationsip HasOneType string // HasManyType describes a Has Many relationsip HasManyType string }
type CustomEntityStructure ¶
type CustomEntityStructure struct { // Type of the entity Type string // Label to display referencing the entity TypeLabel string // Name of the entity Name string // AttributeList list of attributes AttributeList []CustomAttributeStructure // Group to which this entity belongs (i.e. Shop, Users, etc) Group string }
type LanguageKey ¶
type LanguageKey struct{}
type ShortcodeInterface ¶
Source Files
¶
- BlockFindByID.go
- Cms.go
- Config.go
- ContentFindIdsByPatternPrefix.go
- ContentRenderBlocks.go
- ContentRenderShortcodes.go
- ContentRenderTranslations.go
- FrontendHandler.go
- NewCms.go
- PageFindByAlias.go
- PageRenderHtmlByAlias.go
- ShortcodeAdd.go
- ShortcodeInterface.go
- ShortcodesAdd.go
- TemplateContentFindByID.go
- TemplateFindByID.go
- TemplateRenderByID.go
- TranslationFindByIdOrHandle.go
- WebpageFuncs.go
- admin.go
- admin_consts.go
- admin_entity_routes.go
- admin_users_user.go
- cms_custom_entities.go
- consts.go
- isNumeric.go