Documentation
¶
Index ¶
- Constants
- Variables
- func RegisterNodeType(node interface{}, fn NewNodeFunc)
- type BaseData
- type CallInfo
- type Criteria
- func (c *Criteria) GetSelector() bson.M
- func (c *Criteria) HasTemplate() bool
- func (c Criteria) String() string
- func (c *Criteria) WithMimeType(mimeType string) *Criteria
- func (c *Criteria) WithName(name string) *Criteria
- func (c *Criteria) WithNewObjectId() *Criteria
- func (c *Criteria) WithNodeType(nodeType string) *Criteria
- func (c *Criteria) WithObjectId(id string) *Criteria
- func (c *Criteria) WithOrder(order int) *Criteria
- func (c *Criteria) WithParentId(parentId string) *Criteria
- func (c *Criteria) WithProtoNodeType(nodeType string) *Criteria
- func (c *Criteria) WithScope(scope string) *Criteria
- type CriteriaSet
- type Engine
- func (e *Engine) AddReference(scope, nodeId, refNodeId string) error
- func (e *Engine) AssembleRouteFor(scope, nodeId string) (string, error)
- func (e *Engine) CheckIsChildAllowed(scope, parentId, nodeType string) (bool, error)
- func (e *Engine) CheckNodeIsNoChild(scope, nodeId string, parentNodeId string) (bool, error)
- func (e *Engine) CheckSystemIntegrity() error
- func (e *Engine) CreateInstanceByType(nodeType string, abortNoPrototype bool) (Node, error)
- func (e *Engine) CreateNode(crit *Criteria, abortNoPrototype bool) (Node, error)
- func (e *Engine) EnsureNodeExists(crit *Criteria, abortNoPrototype bool) error
- func (e *Engine) EnumerateChilds(scope, nodeId string, fn EnumFunc) error
- func (e *Engine) Execute(fn EngineFunc) error
- func (e *Engine) ImportSystem(force bool, filePath string) error
- func (e *Engine) MoveNode(scope, srcNodeType, srcNodeId, targetNodeId string) error
- func (e *Engine) NewLogger(praefix string) *Logger
- func (e *Engine) NodeExists(crit *Criteria) (bool, error)
- func (e *Engine) RegisterRoutesForScope(scope string, router *mux.Router) error
- func (e *Engine) RemoveNode(scope, nodeId string) error
- func (e *Engine) Serve() error
- func (e *Engine) Startup(connection string) error
- func (e *Engine) Test() error
- type EngineFunc
- type EnumFunc
- type FileNode
- type FolderNode
- type Loggable
- type Logger
- func (l *Logger) Criticalf(format string, args ...interface{})
- func (l *Logger) Debugf(format string, args ...interface{})
- func (l *Logger) Errorf(format string, args ...interface{})
- func (l *Logger) Infof(format string, args ...interface{})
- func (l *Logger) SetLevel(level int)
- func (l *Logger) Warningf(format string, args ...interface{})
- type NewNodeFunc
- type Node
- type NodeBase
- func (n *NodeBase) Apply(crit *Criteria) error
- func (n *NodeBase) EnumerateChilds(fn EnumFunc) error
- func (n *NodeBase) GetName() string
- func (n *NodeBase) GetObjectId() string
- func (n *NodeBase) GetOrder() int
- func (n *NodeBase) GetParentId() string
- func (n *NodeBase) Init(inst interface{}, e *Engine)
- func (n *NodeBase) Move(parentId string) error
- func (n *NodeBase) NewObjectId()
- func (n *NodeBase) Remove() error
- func (n *NodeBase) RenderEditContent(w *bufio.Writer) error
- func (n *NodeBase) SetEditTemplate(content string)
- func (n *NodeBase) SetName(name string)
- func (n *NodeBase) SetObjectId(objectId string)
- func (n *NodeBase) SetOrder(order int)
- func (n *NodeBase) SetParentId(parentId string)
- type NodeContent
- type NodesConfig
- func (c *NodesConfig) GetConnectionConfig() (map[string]interface{}, error)
- func (c *NodesConfig) GetLibratoConfig() (map[string]interface{}, error)
- func (c *NodesConfig) GetLogglyTokenById(tokenId string) (string, error)
- func (c *NodesConfig) GetMongoConfig() (map[string]interface{}, error)
- func (c *NodesConfig) GetStathatConfig() (map[string]interface{}, error)
- func (c *NodesConfig) Init(fileName string) error
- type PrototypeNode
- type Representation
- type SiteNode
- type StyleNode
- type TextNode
Constants ¶
const ( EMPTY_STRING = "" TAG_DISMISS = "-" )
const ( DURATION_NULL = time.Second * 0 DURATION_DAY = time.Hour * 24 DURATION_WEEK = DURATION_DAY * 7 DURATION_MONTH = DURATION_DAY * 30 )
const ( OBJECTID_SYSTEM_SITE = "54bc1c73618ccf2345600005" OBJECTID_SYSTEM_PROTOTYPES = "54bc1c3456cdf458cc000453" OBJECTID_SYSTEM_TEMPLATES = "54bc1c73618cc458cc0567f5" OBJECTID_SYSTEM_CONTENT = "54bc1c73618cfc345c00fc34" )
const ( LevelDebug = iota LevelInfo LevelWarning LevelError LevelCritical )
////////////////////////////////////////////////////////////////////////////// Log levels to control the logging output.
const (
SYSTEM_SCOPE = "nodes"
)
Variables ¶
var ( NODETYPE_SITE = helper.GetTypeName(SiteNode{}) NODETYPE_TEXT = helper.GetTypeName(TextNode{}) NODETYPE_STYLE = helper.GetTypeName(StyleNode{}) NODETYPE_FOLDER = helper.GetTypeName(FolderNode{}) )
var (
TypeMap map[string]NewNodeFunc
)
Functions ¶
func RegisterNodeType ¶
func RegisterNodeType(node interface{}, fn NewNodeFunc)
//////////////////////////////////////////////////////////////////////////////
Types ¶
type BaseData ¶
type BaseData struct { Id string `bson:"_id,omitempty" toml:"Id" validate:"nonzero"` ParentId string `bson:"p,omitempty" toml:"ParentId"` Name string `bson:"nm,omitempty" toml:"Name" validate:"nonzero"` Order int `bson:"o,omitempty" toml:"Order"` MimeType string `bson:"m,omitempty" toml:"MimeType"` NodeType string `bson:"nt,omitempty" toml:"NodeType" validate:"nonzero"` Route string `bson:"rt,omitempty" toml:"Route"` RegRoute bool `bson:"rr,omitempty" toml:"RegisterRoute"` EditRep Representation `bson:"er,omitempty" toml:"-"` Scope string `bson:"sp,omitempty" toml:"sp" validate:"nonzero"` }
type CallInfo ¶
type CallInfo struct {
// contains filtered or unexported fields
}
callInfo bundles the info about the call environment when a logging statement occured.
func (*CallInfo) ShortFormat ¶
shortFormat returns a string representation in a short variant.
func (*CallInfo) VerboseFormat ¶
verboseFormat returns a string representation in a more verbose variant.
type Criteria ¶
type Criteria struct { BaseData `bson:",inline" toml:"Base"` //Payload for PrototypeNodes Template BaseData `bson:"tp,omitempty" toml:"Template" validate:"-"` }
func NewCriteria ¶
//////////////////////////////////////////////////////////////////////////////
func (*Criteria) GetSelector ¶
//////////////////////////////////////////////////////////////////////////////
func (*Criteria) HasTemplate ¶
////////////////////////////////////////////////////////////////////////////////
func (Criteria) String ¶
////////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithMimeType ¶
////////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithName ¶
////////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithNewObjectId ¶
//////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithNodeType ¶
////////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithObjectId ¶
////////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithOrder ¶
////////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithParentId ¶
////////////////////////////////////////////////////////////////////////////////
func (*Criteria) WithProtoNodeType ¶
//////////////////////////////////////////////////////////////////////////////
type CriteriaSet ¶
type CriteriaSet struct { Scope string `toml:"Scope" validate:"nonzero"` Criteriae []Criteria `toml:"Criteria"` Prototypes []Criteria `toml:"Prototype"` Loggable }
func (*CriteriaSet) Ensure ¶
func (c *CriteriaSet) Ensure(force bool, e *Engine) error
//////////////////////////////////////////////////////////////////////////////
func (*CriteriaSet) Load ¶
func (c *CriteriaSet) Load(data string) error
//////////////////////////////////////////////////////////////////////////////
func (*CriteriaSet) LoadFromFile ¶
func (c *CriteriaSet) LoadFromFile(path string) error
//////////////////////////////////////////////////////////////////////////////
type Engine ¶
type Engine struct { Loggable helper.MongoSessionProvider Config *NodesConfig SystemCriteria *CriteriaSet StartupDir string // contains filtered or unexported fields }
func NewEngine ¶
func NewEngine(config *NodesConfig) (*Engine, error)
//////////////////////////////////////////////////////////////////////////////
func (*Engine) AddReference ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) AssembleRouteFor ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) CheckIsChildAllowed ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) CheckNodeIsNoChild ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) CheckSystemIntegrity ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) CreateInstanceByType ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) CreateNode ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) EnsureNodeExists ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) EnumerateChilds ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) Execute ¶
func (e *Engine) Execute(fn EngineFunc) error
//////////////////////////////////////////////////////////////////////////////
func (*Engine) ImportSystem ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) MoveNode ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) NewLogger ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) NodeExists ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) RegisterRoutesForScope ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) RemoveNode ¶
//////////////////////////////////////////////////////////////////////////////
func (*Engine) Serve ¶
//////////////////////////////////////////////////////////////////////////////
type EngineFunc ¶
//////////////////////////////////////////////////////////////////////////////
type FileNode ¶
type FileNode struct { NodeBase `bson:",inline"` ResourceId string `bson:"rid"` RefNodes []string `bson:"refs"` }
func NewFileNode ¶
//////////////////////////////////////////////////////////////////////////////
func (*FileNode) AddReference ¶
//////////////////////////////////////////////////////////////////////////////
func (*FileNode) IsChildAllowed ¶
//////////////////////////////////////////////////////////////////////////////
type FolderNode ¶
type FolderNode struct {
NodeBase `bson:",inline"`
}
func NewFolderNode ¶
func NewFolderNode(engine *Engine) *FolderNode
//////////////////////////////////////////////////////////////////////////////
func (*FolderNode) IsChildAllowed ¶
func (n *FolderNode) IsChildAllowed(typeName string) bool
//////////////////////////////////////////////////////////////////////////////
func (*FolderNode) RegisterRoute ¶
func (n *FolderNode) RegisterRoute(route string, router *mux.Router)
//////////////////////////////////////////////////////////////////////////////
type Loggable ¶
type Loggable struct {
Logger *Logger
}
//////////////////////////////////////////////////////////////////////////////
type Logger ¶
//////////////////////////////////////////////////////////////////////////////
func (*Logger) Criticalf ¶
////////////////////////////////////////////////////////////////////////////// Criticalf logs a message at critical level.
func (*Logger) Debugf ¶
////////////////////////////////////////////////////////////////////////////// Debugf logs a message at debug level.
func (*Logger) Errorf ¶
////////////////////////////////////////////////////////////////////////////// Errorf logs a message at error level.
func (*Logger) Infof ¶
////////////////////////////////////////////////////////////////////////////// Infof logs a message at info level.
type NewNodeFunc ¶
type Node ¶
type Node interface { RenderEditContent(w *bufio.Writer) error IsChildAllowed(typeName string) bool SetParentId(parentId string) GetParentId() string Move(parentId string) error SetName(name string) Apply(crit *Criteria) error SetOrder(order int) SetEditTemplate(content string) SetObjectId(objectId string) GetObjectId() string NewObjectId() RegisterRoute(route string, router *mux.Router) Remove() error }
type NodeBase ¶
type NodeBase struct { BaseData `bson:",inline"` Render *render.Render `bson:"-" toml:"-"` Engine *Engine `bson:"-" toml:"-"` Loggable `bson:"-" toml:"-"` }
func (*NodeBase) Apply ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) EnumerateChilds ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) GetName ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) GetObjectId ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) GetOrder ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) GetParentId ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) Init ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) Move ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) NewObjectId ¶
func (n *NodeBase) NewObjectId()
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) Remove ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) RenderEditContent ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) SetEditTemplate ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) SetName ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) SetObjectId ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) SetOrder ¶
//////////////////////////////////////////////////////////////////////////////
func (*NodeBase) SetParentId ¶
//////////////////////////////////////////////////////////////////////////////
type NodeContent ¶
type NodeContent struct { Content interface{} `bson:"c"` DisplayReps []Representation `bson:"dr"` }
type NodesConfig ¶
type NodesConfig struct {
*yamlconfig.Config
}
func CreateNodesConfig ¶
func CreateNodesConfig(fileName string) (*NodesConfig, error)
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
func (*NodesConfig) GetConnectionConfig ¶
func (c *NodesConfig) GetConnectionConfig() (map[string]interface{}, error)
///////////////////////////////////////////////////////////////////////////////////////////// GetConnectionConfig /////////////////////////////////////////////////////////////////////////////////////////////
func (*NodesConfig) GetLibratoConfig ¶
func (c *NodesConfig) GetLibratoConfig() (map[string]interface{}, error)
///////////////////////////////////////////////////////////////////////////////////////////////
func (*NodesConfig) GetLogglyTokenById ¶
func (c *NodesConfig) GetLogglyTokenById(tokenId string) (string, error)
/////////////////////////////////////////////////////////////////////////////////////////////
func (*NodesConfig) GetMongoConfig ¶
func (c *NodesConfig) GetMongoConfig() (map[string]interface{}, error)
///////////////////////////////////////////////////////////////////////////////////////////// GetCassandraConfig /////////////////////////////////////////////////////////////////////////////////////////////
func (*NodesConfig) GetStathatConfig ¶
func (c *NodesConfig) GetStathatConfig() (map[string]interface{}, error)
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
func (*NodesConfig) Init ¶
func (c *NodesConfig) Init(fileName string) error
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
type PrototypeNode ¶
func NewPrototypeNode ¶
func NewPrototypeNode(engine *Engine) *PrototypeNode
//////////////////////////////////////////////////////////////////////////////
func (*PrototypeNode) Apply ¶
func (n *PrototypeNode) Apply(crit *Criteria) error
//////////////////////////////////////////////////////////////////////////////
func (*PrototypeNode) IsChildAllowed ¶
func (n *PrototypeNode) IsChildAllowed(typeName string) bool
//////////////////////////////////////////////////////////////////////////////
func (*PrototypeNode) RegisterRoute ¶
func (n *PrototypeNode) RegisterRoute(route string, router *mux.Router)
//////////////////////////////////////////////////////////////////////////////
type Representation ¶
type Representation struct {
Content string `bson:"c"`
}
type SiteNode ¶
type SiteNode struct { NodeBase `bson:",inline"` Domain string `bson:"dm"` EntryNodeId string `bson:"eid"` }
func NewSiteNode ¶
//////////////////////////////////////////////////////////////////////////////
func (*SiteNode) IsChildAllowed ¶
//////////////////////////////////////////////////////////////////////////////
type StyleNode ¶
type StyleNode struct {
TextNode `bson:",inline"`
}
func NewStyleNode ¶
//////////////////////////////////////////////////////////////////////////////
func (*StyleNode) IsChildAllowed ¶
//////////////////////////////////////////////////////////////////////////////
type TextNode ¶
type TextNode struct { NodeBase `bson:",inline"` Content NodeContent `bson:"c"` IsTemplate bool `bson:"ist"` }
func NewTextNode ¶
//////////////////////////////////////////////////////////////////////////////
func (*TextNode) IsChildAllowed ¶
//////////////////////////////////////////////////////////////////////////////