nodes

package
v0.0.0-...-7413aa3 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2015 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EMPTY_STRING = ""
	TAG_DISMISS  = "-"
)
View Source
const (
	DURATION_NULL  = time.Second * 0
	DURATION_DAY   = time.Hour * 24
	DURATION_WEEK  = DURATION_DAY * 7
	DURATION_MONTH = DURATION_DAY * 30
)
View Source
const (
	OBJECTID_SYSTEM_SITE       = "54bc1c73618ccf2345600005"
	OBJECTID_SYSTEM_PROTOTYPES = "54bc1c3456cdf458cc000453"
	OBJECTID_SYSTEM_TEMPLATES  = "54bc1c73618cc458cc0567f5"
	OBJECTID_SYSTEM_CONTENT    = "54bc1c73618cfc345c00fc34"
)
View Source
const (
	LevelDebug = iota
	LevelInfo
	LevelWarning
	LevelError
	LevelCritical
)

////////////////////////////////////////////////////////////////////////////// Log levels to control the logging output.

View Source
const (
	SYSTEM_SCOPE = "nodes"
)

Variables

View Source
var (
	NODETYPE_SITE   = helper.GetTypeName(SiteNode{})
	NODETYPE_TEXT   = helper.GetTypeName(TextNode{})
	NODETYPE_STYLE  = helper.GetTypeName(StyleNode{})
	NODETYPE_FOLDER = helper.GetTypeName(FolderNode{})
)
View Source
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 RetrieveCallInfo

func RetrieveCallInfo() *CallInfo

retrieveCallInfo

func (*CallInfo) ShortFormat

func (ci *CallInfo) ShortFormat() string

shortFormat returns a string representation in a short variant.

func (*CallInfo) VerboseFormat

func (ci *CallInfo) VerboseFormat() string

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 NewCriteria(scope string) *Criteria

//////////////////////////////////////////////////////////////////////////////

func (*Criteria) GetSelector

func (c *Criteria) GetSelector() bson.M

//////////////////////////////////////////////////////////////////////////////

func (*Criteria) HasTemplate

func (c *Criteria) HasTemplate() bool

////////////////////////////////////////////////////////////////////////////////

func (Criteria) String

func (c Criteria) String() string

////////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithMimeType

func (c *Criteria) WithMimeType(mimeType string) *Criteria

////////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithName

func (c *Criteria) WithName(name string) *Criteria

////////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithNewObjectId

func (c *Criteria) WithNewObjectId() *Criteria

//////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithNodeType

func (c *Criteria) WithNodeType(nodeType string) *Criteria

////////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithObjectId

func (c *Criteria) WithObjectId(id string) *Criteria

////////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithOrder

func (c *Criteria) WithOrder(order int) *Criteria

////////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithParentId

func (c *Criteria) WithParentId(parentId string) *Criteria

////////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithProtoNodeType

func (c *Criteria) WithProtoNodeType(nodeType string) *Criteria

//////////////////////////////////////////////////////////////////////////////

func (*Criteria) WithScope

func (c *Criteria) WithScope(scope string) *Criteria

////////////////////////////////////////////////////////////////////////////////

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 (e *Engine) AddReference(scope, nodeId, refNodeId string) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) AssembleRouteFor

func (e *Engine) AssembleRouteFor(scope, nodeId string) (string, error)

//////////////////////////////////////////////////////////////////////////////

func (*Engine) CheckIsChildAllowed

func (e *Engine) CheckIsChildAllowed(scope, parentId, nodeType string) (bool, error)

//////////////////////////////////////////////////////////////////////////////

func (*Engine) CheckNodeIsNoChild

func (e *Engine) CheckNodeIsNoChild(scope, nodeId string, parentNodeId string) (bool, error)

//////////////////////////////////////////////////////////////////////////////

func (*Engine) CheckSystemIntegrity

func (e *Engine) CheckSystemIntegrity() error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) CreateInstanceByType

func (e *Engine) CreateInstanceByType(nodeType string, abortNoPrototype bool) (Node, error)

//////////////////////////////////////////////////////////////////////////////

func (*Engine) CreateNode

func (e *Engine) CreateNode(crit *Criteria, abortNoPrototype bool) (Node, error)

//////////////////////////////////////////////////////////////////////////////

func (*Engine) EnsureNodeExists

func (e *Engine) EnsureNodeExists(crit *Criteria, abortNoPrototype bool) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) EnumerateChilds

func (e *Engine) EnumerateChilds(scope, nodeId string, fn EnumFunc) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) Execute

func (e *Engine) Execute(fn EngineFunc) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) ImportSystem

func (e *Engine) ImportSystem(force bool, filePath string) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) MoveNode

func (e *Engine) MoveNode(scope, srcNodeType, srcNodeId, targetNodeId string) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) NewLogger

func (e *Engine) NewLogger(praefix string) *Logger

//////////////////////////////////////////////////////////////////////////////

func (*Engine) NodeExists

func (e *Engine) NodeExists(crit *Criteria) (bool, error)

//////////////////////////////////////////////////////////////////////////////

func (*Engine) RegisterRoutesForScope

func (e *Engine) RegisterRoutesForScope(scope string, router *mux.Router) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) RemoveNode

func (e *Engine) RemoveNode(scope, nodeId string) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) Serve

func (e *Engine) Serve() error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) Startup

func (e *Engine) Startup(connection string) error

//////////////////////////////////////////////////////////////////////////////

func (*Engine) Test

func (e *Engine) Test() error

type EngineFunc

type EngineFunc func(engine *Engine) error

//////////////////////////////////////////////////////////////////////////////

type EnumFunc

type EnumFunc func(node Node) error

type FileNode

type FileNode struct {
	NodeBase   `bson:",inline"`
	ResourceId string   `bson:"rid"`
	RefNodes   []string `bson:"refs"`
}

func NewFileNode

func NewFileNode(engine *Engine) *FileNode

//////////////////////////////////////////////////////////////////////////////

func (*FileNode) AddReference

func (n *FileNode) AddReference(refNodeId string) error

//////////////////////////////////////////////////////////////////////////////

func (*FileNode) IsChildAllowed

func (n *FileNode) IsChildAllowed(typeName string) bool

//////////////////////////////////////////////////////////////////////////////

func (*FileNode) RegisterRoute

func (n *FileNode) RegisterRoute(route string, router *mux.Router)

//////////////////////////////////////////////////////////////////////////////

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
}

//////////////////////////////////////////////////////////////////////////////

func (*Loggable) SetLogger

func (l *Loggable) SetLogger(logger *Logger)

//////////////////////////////////////////////////////////////////////////////

type Logger

type Logger struct {
	Loggly  *loggly.Client
	Level   int
	Praefix string
}

//////////////////////////////////////////////////////////////////////////////

func (*Logger) Criticalf

func (l *Logger) Criticalf(format string, args ...interface{})

////////////////////////////////////////////////////////////////////////////// Criticalf logs a message at critical level.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

////////////////////////////////////////////////////////////////////////////// Debugf logs a message at debug level.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

////////////////////////////////////////////////////////////////////////////// Errorf logs a message at error level.

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

////////////////////////////////////////////////////////////////////////////// Infof logs a message at info level.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

//////////////////////////////////////////////////////////////////////////////

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...interface{})

////////////////////////////////////////////////////////////////////////////// Warningf logs a message at warning level.

type NewNodeFunc

type NewNodeFunc func(engine *Engine) Node

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 (n *NodeBase) Apply(crit *Criteria) error

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) EnumerateChilds

func (n *NodeBase) EnumerateChilds(fn EnumFunc) error

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) GetName

func (n *NodeBase) GetName() string

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) GetObjectId

func (n *NodeBase) GetObjectId() string

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) GetOrder

func (n *NodeBase) GetOrder() int

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) GetParentId

func (n *NodeBase) GetParentId() string

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) Init

func (n *NodeBase) Init(inst interface{}, e *Engine)

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) Move

func (n *NodeBase) Move(parentId string) error

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) NewObjectId

func (n *NodeBase) NewObjectId()

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) Remove

func (n *NodeBase) Remove() error

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) RenderEditContent

func (n *NodeBase) RenderEditContent(w *bufio.Writer) error

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) SetEditTemplate

func (n *NodeBase) SetEditTemplate(content string)

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) SetName

func (n *NodeBase) SetName(name string)

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) SetObjectId

func (n *NodeBase) SetObjectId(objectId string)

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) SetOrder

func (n *NodeBase) SetOrder(order int)

//////////////////////////////////////////////////////////////////////////////

func (*NodeBase) SetParentId

func (n *NodeBase) SetParentId(parentId string)

//////////////////////////////////////////////////////////////////////////////

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

type PrototypeNode struct {
	NodeBase `bson:",inline"`
	Template BaseData `bson:"tp"`
}

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"`
}

func (*Representation) Render

func (r *Representation) Render(w *bufio.Writer) error

//////////////////////////////////////////////////////////////////////////////

type SiteNode

type SiteNode struct {
	NodeBase    `bson:",inline"`
	Domain      string `bson:"dm"`
	EntryNodeId string `bson:"eid"`
}

func NewSiteNode

func NewSiteNode(engine *Engine) *SiteNode

//////////////////////////////////////////////////////////////////////////////

func (*SiteNode) IsChildAllowed

func (n *SiteNode) IsChildAllowed(typeName string) bool

//////////////////////////////////////////////////////////////////////////////

func (*SiteNode) RegisterRoute

func (n *SiteNode) RegisterRoute(route string, router *mux.Router)

//////////////////////////////////////////////////////////////////////////////

type StyleNode

type StyleNode struct {
	TextNode `bson:",inline"`
}

func NewStyleNode

func NewStyleNode(engine *Engine) *StyleNode

//////////////////////////////////////////////////////////////////////////////

func (*StyleNode) IsChildAllowed

func (n *StyleNode) IsChildAllowed(typeName string) bool

//////////////////////////////////////////////////////////////////////////////

func (*StyleNode) RegisterRoute

func (n *StyleNode) RegisterRoute(route string, router *mux.Router)

//////////////////////////////////////////////////////////////////////////////

type TextNode

type TextNode struct {
	NodeBase   `bson:",inline"`
	Content    NodeContent `bson:"c"`
	IsTemplate bool        `bson:"ist"`
}

func NewTextNode

func NewTextNode(engine *Engine) *TextNode

//////////////////////////////////////////////////////////////////////////////

func (*TextNode) IsChildAllowed

func (n *TextNode) IsChildAllowed(typeName string) bool

//////////////////////////////////////////////////////////////////////////////

func (*TextNode) RegisterRoute

func (n *TextNode) RegisterRoute(route string, router *mux.Router)

//////////////////////////////////////////////////////////////////////////////

Jump to

Keyboard shortcuts

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