Documentation ¶
Index ¶
- Constants
- func Edit(library *Library, container *Container, endpoint string) string
- func View(library *Library, container *Container) string
- type Action
- type AddItem
- type ChangeType
- type Container
- func (container *Container) AddFirstReference(itemID int, newItemID int)
- func (container *Container) AddLastReference(itemID int, newItemID int)
- func (container *Container) AddReference(parentID int, place string, referenceID int, newItemID int)
- func (container *Container) Compact()
- func (container *Container) DeleteReference(parentID int, referenceID int)
- func (container *Container) Get(library *Library, input map[string]interface{}, endpoint string) string
- func (container *Container) GetChecksum(itemID int) string
- func (container *Container) GetItem(itemID int) Item
- func (container *Container) GetParentID(itemID int) int
- func (container *Container) GetRefs(itemID int) []int
- func (container *Container) GetType(itemID int) string
- func (container *Container) IsNil(itemID int) bool
- func (container *Container) Len() int
- func (container *Container) NewChecksum(itemID int)
- func (container *Container) NewItem(itemType string, data maps.Map) int
- func (container *Container) NewItemWithInit(library *Library, itemType string, data maps.Map) int
- func (container *Container) Post(library *Library, input map[string]interface{}) (int, error)
- type DeleteItem
- type Getter
- type GetterSetter
- type HTML
- type Item
- func (item *Item) AddFirstReference(id int)
- func (item *Item) AddLastReference(id int)
- func (item *Item) AddReference(id int, index int)
- func (item *Item) DeleteReference(itemID int)
- func (item *Item) GetBytes(key string) []byte
- func (item *Item) GetInt(key string) int
- func (item *Item) GetInterface(key string) interface{}
- func (item *Item) GetPath(path string) (interface{}, bool)
- func (item *Item) GetSliceOfInt(key string) []int
- func (item *Item) GetSliceOfString(key string) []string
- func (item *Item) GetString(key string) string
- func (item *Item) IsEmpty() bool
- func (item *Item) Set(key string, value interface{}) *Item
- func (item *Item) SetPath(path string, value interface{}) error
- func (item *Item) UnmarshalMap(value map[string]interface{})
- func (item *Item) UpdateReference(from int, to int)
- func (item *Item) Validate(checksum string) error
- type ItemType
- type Layout
- type Library
- func (library *Library) Edit(builder *html.Builder, container *Container, id int, endpoint string)
- func (library *Library) Init(container *Container, id int)
- func (library *Library) Register(name string, widget Widget)
- func (library *Library) Validate(container *Container)
- func (library *Library) View(builder *html.Builder, container *Container, id int)
- func (library *Library) Widget(name string) Widget
- type Markdown
- func (w Markdown) Edit(b *html.Builder, container *Container, id int, endpoint string)
- func (w Markdown) Init(container *Container, id int)
- func (w Markdown) Prop(container *Container, id int, params url.Values) (string, error)
- func (w Markdown) Validate(container *Container, index int)
- func (w Markdown) View(b *html.Builder, container *Container, id int)
- type MoveItem
- type NilAction
- type NilWidget
- type OEmbed
- type Setter
- type SortChildren
- type Tabs
- type Text
- type UpdateItem
- type UploadFile
- type WYSIWYG
- func (w WYSIWYG) Edit(b *html.Builder, container *Container, id int, endpoint string)
- func (w WYSIWYG) Init(container *Container, id int)
- func (w WYSIWYG) Prop(container *Container, id int, params url.Values) (string, error)
- func (w WYSIWYG) Validate(container *Container, index int)
- func (w WYSIWYG) View(b *html.Builder, container *Container, id int)
- type Widget
- type WidgetIniter
Constants ¶
const ItemTypeHTML = "HTML"
ItemTypeHTML describes an HTML code editor
const ItemTypeLayout = "LAYOUT"
ItemTypeLayout represents a Layout widget
const ItemTypeMarkdown = "Markdown"
ItemTypeMarkdown describes a what-you-see-is-what-you-get content editor
const ItemTypeOEmbed = "OEMBED"
ItemTypeOEmbed describes an oEmbed object (see https://oembed.com)
const ItemTypeTabs = "TABS"
ItemTypeTabs describes a multi-tab container layout
const ItemTypeText = "TEXT"
ItemTypeText describes a plain text editor
const ItemTypeWYSIWYG = "WYSIWYG"
ItemTypeWYSIWYG describes a what-you-see-is-what-you-get content editor
const LayoutPlaceAbove = "ABOVE"
LayoutPlaceAbove represents the placement of a new item above the reference item
const LayoutPlaceAfter = "AFTER"
LayoutPlaceAfter represents the placement of a new item after the reference item
const LayoutPlaceBefore = "BEFORE"
LayoutPlaceBefore represents the placement of a new item before the reference item
const LayoutPlaceBelow = "BELOW"
LayoutPlaceAbove represents the placement of a new item below the reference item
const LayoutPlaceLeft = "LEFT"
LayoutPlaceAbove represents the placement of a new item to the left of the reference item
const LayoutPlaceRight = "RIGHT"
LayoutPlaceAbove represents the placement of a new item to the right of the reference item
const LayoutStyleColumns = "COLS"
LayoutStyle Colums represents a group of content items organized into responsive columns
const LayoutStyleRows = "ROWS"
LayoutStyleRows represents a group of content items organized into rows
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action interface { Get(library *Library, container *Container, endpoint string) string // Execute performs an update to the content data. It returns // the ID of the element to be re-rendered on the client, along // with an error (if present). Implementations can use this to // selectively re-render portions of the content structure without // reloading the entire page. Post(library *Library, container *Container) (int, error) }
Action interface wraps the "Execute" method, which takes some non-reversible, non-idempotent action on the container.
type AddItem ¶
type AddItem struct { ItemID int `json:"itemId" form:"itemId"` // ID of the layout that will hold the new item SubItemID int `json:"subItemID" form:"subItemId"` // ID of the item used for relative positioning Place string `json:"place" form:"place"` // Position of the new element (BEFORE, AFTER) relative to the index ItemType string `json:"itemType" form:"itemType"` // Type of content item to add Style string `json:"style" form:"style"` // Optional "style" aregument for certain types (like layouts) Check string `json:"check" form:"check"` // Checksum to validation transaction. }
type ChangeType ¶
type ChangeType struct { ItemID int `json:"itemId" form:"itemId"` // ID of the root item that will be added to ItemType string `json:"itemType" form:"itemType"` // Type of content item to add Check string `json:"check" form:"check"` // Checksum to validation transaction. }
type Container ¶
type Container []Item
Container represents a complete package of container
func NewContainer ¶
func NewContainer() Container
NewContainer returns a fully initialized Container object
func (*Container) AddFirstReference ¶
func (*Container) AddLastReference ¶
func (*Container) AddReference ¶
func (container *Container) AddReference(parentID int, place string, referenceID int, newItemID int)
AddReference links the newItemID into the parent's reference list, placed relative to the referenceID
func (*Container) Compact ¶
func (container *Container) Compact()
Compact removes any unused items in the container slice and reorganizes references
func (*Container) DeleteReference ¶
func (*Container) Get ¶ added in v0.2.0
func (container *Container) Get(library *Library, input map[string]interface{}, endpoint string) string
Execute parses and executes a new Action against this container.
func (*Container) GetChecksum ¶
GetChecksum returns the checksum of the designated item
func (*Container) GetParentID ¶
GetParent searches for the ID of a parent item
func (*Container) NewChecksum ¶ added in v0.2.0
NewChecksum assigns a new checksum value to the designated item
func (*Container) NewItemWithInit ¶
NewItem creates a new item of the designated type and initializes it with the default Init() method from the corresponding widget library
type DeleteItem ¶
type DeleteItem struct { ItemID int `json:"itemId" form:"itemId"` Check string `json:"check" form:"check"` }
Delete action removes a single item from a container
type Getter ¶
type Getter interface {
GetContainer() Container
}
Getter wraps the "GetContainer" method, which allows an object to safely expose it's underlying container data
type GetterSetter ¶
GetterSetter wraps both "GetContainer" and "SetContainer" methods, allowing read/write access to an object's underlying container data.
type HTML ¶
type HTML struct{}
HTML widget displays plain HTML content
type Item ¶
type Item struct { Type string `json:"type" bson:"type"` // The type of contem item (WYSIWYG, CONTAINER, OEMBED, ETC...) Check string `json:"check" bson:"check"` // A random code or nonce to authenticate requests Refs []int `json:"refs,omitempty" bson:"refs"` // Indexes of sub-items contained by this item Data maps.Map `json:"data,omitempty" bson:"data"` // Additional data specific to this item type. }
Item represents a single piece of content. It will be rendered by one of several rendering Libraries, using the custom data it contains.
func (*Item) AddFirstReference ¶
AddFirstReference adds an itemID to the beginning of the reference list
func (*Item) AddLastReference ¶
AddLastReference adds and itemID to the end of the reference list
func (*Item) AddReference ¶
AddReference adds a new item into the middle of the reference list
func (*Item) DeleteReference ¶
DeleteReference removes a reference from this Item.
func (*Item) GetInterface ¶
func (*Item) GetSliceOfInt ¶
func (*Item) GetSliceOfString ¶
func (*Item) UnmarshalMap ¶
UnmarshalMap extracts data from a map[string]interface{} to populate this Item
func (*Item) UpdateReference ¶
UpdateReference migrates references from an old value to a new one
type Layout ¶
type Layout struct {
// contains filtered or unexported fields
}
type Library ¶
func NewLibrary ¶
func NewLibrary() Library
func (*Library) Validate ¶ added in v0.3.0
Validate scans all content in the container, removing invalid content before it is saved.
type Markdown ¶ added in v0.6.2
type Markdown struct{}
type MoveItem ¶
type MoveItem struct { ItemID int `json:"itemId" form:"itemId"` NewParentID int `json:"newParentId" form:"newParentId"` Position int `json:"position" form:"position"` Check string `json:"check" form:"check"` }
type NilWidget ¶
type NilWidget struct{}
NilWidget is a default/empty widget that does nothing.
type OEmbed ¶
type OEmbed struct{}
type Setter ¶
type Setter interface {
SetContainer(Container)
}
Setter wraps the "SetContent" method, which allows an object to safely expose it's underlying container data
type SortChildren ¶ added in v0.2.0
type SortChildren struct { ItemID int `json:"itemId" form:"itemId"` // ID of the layout that will hold the new item ChildIDs []int `json:"childIds" form:"childIds"` // Sorted list of IDs to use for child references Check string `json:"check" form:"check"` // Checksum to validation transaction. }
type Tabs ¶
type Tabs struct {
// contains filtered or unexported fields
}
type Text ¶
type Text struct{}
type UpdateItem ¶
type UpdateItem struct { ItemID int `json:"itemId" form:"itemId"` Data map[string]interface{} `json:"data" form:"data"` Check string `json:"hash" form:"hash"` }
type UploadFile ¶
type UploadFile struct { ItemID int `json:"itemId" form:"itemId"` File string `json:"file" form:"file"` Check string `json:"hash" form:"hash"` }
type WYSIWYG ¶
type WYSIWYG struct{}
type Widget ¶
type Widget interface { // View writes the widget HTML into the provided HTML builder View(*html.Builder, *Container, int) // Edit writes an editable widget into the provided HTML builder Edit(*html.Builder, *Container, int, string) // Validate cleans/updates each item, stripping strip away invalid content Validate(*Container, int) }
type WidgetIniter ¶
Source Files ¶
- action.go
- action_add.go
- action_delete.go
- action_move.go
- action_nil.go
- action_sort.go
- action_type.go
- action_update.go
- action_upload.go
- container.go
- interfaces.go
- item.go
- library.go
- nebula.go
- widget.go
- widget_html.go
- widget_itemTypes.go
- widget_layout.go
- widget_markdown.go
- widget_nil.go
- widget_oembed.go
- widget_tabs.go
- widget_text.go
- widget_validators.go
- widget_wysiwyg.go