resources

package
v0.0.0-...-fbd7fd2 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2023 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	YAML = 1 << iota
	JSON
	MST
)

Variables

View Source
var SUPPORTED_TAGS map[string]bool = map[string]bool{
	"!!str":   true,
	"!!bool":  true,
	"!!int":   true,
	"!!float": true,
	"!!seq":   true,
	"!!map":   true,
}

Functions

func DefaultLoadYaml

func DefaultLoadYaml(file string) []byte

func EnsureUniqueTitles

func EnsureUniqueTitles(yrs []*YamlResource) error

func GetAnchor

func GetAnchor(spaceDir string) string

func GlobYaml

func GlobYaml(glob string) string

func IsYamlFile

func IsYamlFile(file string) bool

func PrettyPrint

func PrettyPrint(target RenderTarget, page *Page, w *os.File)

func PrettyPrintYaml

func PrettyPrintYaml(node *yaml.Node, w io.Writer)

Types

type Ancestor

type Ancestor struct {
	Id    string
	Title string
}

type Asset

type Asset struct {
	// contains filtered or unexported fields
}

func (Asset) GetName

func (a Asset) GetName() string

func (Asset) GetPath

func (a Asset) GetPath() string

func (Asset) IsBuiltin

func (a Asset) IsBuiltin() bool

func (Asset) ReadBytes

func (a Asset) ReadBytes() []byte

func (Asset) ReadString

func (a Asset) ReadString() string

type ChangeType

type ChangeType int
const (
	CREATE ChangeType = iota
	UPDATE
	DELETE
	NOOP
)

type Encoder

type Encoder interface {
	SetIndent(string, string)
	Encode(interface{}) error
}

type Hook

type Hook struct {
	Asset  IAsset
	Config *HookConfig
}

type HookConfig

type HookConfig struct {
	Target    string    `yaml:"target"`
	Priority  int       `yaml:"priority"`
	ListFiles ListFiles `yaml:"listFiles"`
	Defaults  yaml.Node `yaml:"defaults"`
	Overrides yaml.Node `yaml:"overrides"`
	Merges    yaml.Node `yaml:"merges"`
	YqWhile   string    `yaml:"yqWhile"`
	Yq        []string  `yaml:"yq"`
	Jq        []string  `yaml:"jq"`
	Header    string    `yaml:"header"`
	Footer    string    `yaml:"footer"`
}

type HookProcessor

type HookProcessor struct {
	// contains filtered or unexported fields
}

func NewHookProcessor

func NewHookProcessor(hooksDir string, precompile bool) *HookProcessor

func (*HookProcessor) Get

func (hp *HookProcessor) Get(hookName string) *Hook

func (*HookProcessor) GetAll

func (hp *HookProcessor) GetAll() []*Hook

func (*HookProcessor) GetHookSet

func (hp *HookProcessor) GetHookSet(kind string) HookSet

func (*HookProcessor) GetHooks

func (hp *HookProcessor) GetHooks(kind string) []*Hook

type HookSet

type HookSet struct {
	Jq     []JqCommand
	Yq     []YqHooks
	Ls     Ls
	Header string
	Footer string
}

type IAsset

type IAsset interface {
	GetName() string
	GetPath() string
	IsBuiltin() bool
	ReadString() string
	ReadBytes() []byte
}

func GetBuiltinHooks

func GetBuiltinHooks() []IAsset

func GetBuiltinTemplates

func GetBuiltinTemplates() []IAsset

func LoadAssets

func LoadAssets(dir string, exts []string, optional bool) []IAsset

type JqCommand

type JqCommand struct {
	Cmd  string
	Hook *Hook
	// contains filtered or unexported fields
}

func (*JqCommand) Run

func (jc *JqCommand) Run(json string) (string, error)

type KindAndTitle

type KindAndTitle struct {
	Kind  string `json:"kind"`
	Title string `json:"title"`
}

type Labels

type Labels struct {
	Labels []string `json:"labels"`
}

type ListFiles

type ListFiles struct {
	EnvVar string `yaml:"envVar"`
	Glob   string `yaml:"glob"`
}

type Ls

type Ls struct {
	// contains filtered or unexported fields
}

func (*Ls) Run

func (ls *Ls) Run()

type LsCache

type LsCache struct {
	// contains filtered or unexported fields
}

func (*LsCache) Get

func (c *LsCache) Get(lf ListFiles) (string, bool)

func (*LsCache) Set

func (c *LsCache) Set(lf ListFiles, data string)

type Page

type Page struct {
	Key      string
	Resource *YamlResource
	Content  PageContent
	Remote   *RemoteResource
	Parent   *Page
	// childrenByTitle map[string]*Page
	Children []*Page
}

func NewPage

func NewPage(key string, yr *YamlResource) *Page

func (*Page) AppendChild

func (parent *Page) AppendChild(p *Page) *Page

func (*Page) GetAncestorId

func (p *Page) GetAncestorId() string

func (*Page) GetChangeType

func (p *Page) GetChangeType() ChangeType

func (*Page) GetChildByTitle

func (p *Page) GetChildByTitle(title string) *Page

func (*Page) GetChildren

func (p *Page) GetChildren() []*Page

func (*Page) GetContent

func (p *Page) GetContent() string

func (*Page) GetId

func (p *Page) GetId() string

func (*Page) GetIncrementedVersion

func (p *Page) GetIncrementedVersion() int

func (*Page) GetKeyArray

func (p *Page) GetKeyArray() []string

func (*Page) GetLabels

func (p *Page) GetLabels() []string

func (*Page) GetParent

func (p *Page) GetParent() *Page

func (*Page) GetRemoteId

func (p *Page) GetRemoteId() string

func (*Page) GetRemoteSha256Version

func (p *Page) GetRemoteSha256Version() int

func (*Page) GetRemoteVersion

func (p *Page) GetRemoteVersion() int

func (*Page) GetSha256Property

func (p *Page) GetSha256Property() Property

func (*Page) GetTitle

func (p *Page) GetTitle() string

func (*Page) IsRoot

func (p *Page) IsRoot() bool

func (*Page) IsUpdate

func (p *Page) IsUpdate() bool

func (*Page) LabelsDiffer

func (p *Page) LabelsDiffer() bool

func (*Page) Sha256Differs

func (p *Page) Sha256Differs() bool

type PageContent

type PageContent struct {
	Markup string
	Sha256 string
}

type PageTree

type PageTree struct {
	// contains filtered or unexported fields
}

func NewPageTree

func NewPageTree(yr []*YamlResource, anchor string) *PageTree

func (*PageTree) AddPage

func (pt *PageTree) AddPage(yr *YamlResource)

func (*PageTree) AddRemotes

func (pt *PageTree) AddRemotes(remotes []*RemoteResource)

func (*PageTree) GetAnchor

func (pt *PageTree) GetAnchor() string

func (*PageTree) GetChanges

func (pt *PageTree) GetChanges() [][]PageUpdate

func (*PageTree) GetLevels

func (pt *PageTree) GetLevels() [][]string

func (*PageTree) GetPage

func (pt *PageTree) GetPage(key string) *Page

func (*PageTree) GetPageFromTitlePath

func (pt *PageTree) GetPageFromTitlePath(titles []string) *Page

func (*PageTree) GetPages

func (pt *PageTree) GetPages() []*Page

func (*PageTree) HasAnchor

func (pt *PageTree) HasAnchor() bool

func (*PageTree) SetAnchor

func (pt *PageTree) SetAnchor(id string)

type PageUpdate

type PageUpdate struct {
	Operation ChangeType
	Page      *Page
}

type Property

type Property struct {
	// contains filtered or unexported fields
}

func NewProperty

func NewProperty(id, key, value string, version int) Property

func (Property) GetId

func (p Property) GetId() string

func (Property) GetIncrementedVersion

func (p Property) GetIncrementedVersion() int

func (Property) GetKey

func (p Property) GetKey() string

func (Property) GetValue

func (p Property) GetValue() string

func (Property) IsUpdate

func (p Property) IsUpdate() bool

type RemoteResource

type RemoteResource struct {
	Id        string
	Title     string
	Labels    []string
	Link      string
	Version   int
	Ancestors []Ancestor
	Sha256    RemoteSha256
}

func (*RemoteResource) GetTitlePath

func (rr *RemoteResource) GetTitlePath(anchorId string) []string

type RemoteSha256

type RemoteSha256 struct {
	Id      string
	Value   string
	Version int
}

type RenderTarget

type RenderTarget uint32

type RenderTools

type RenderTools struct {
	// contains filtered or unexported fields
}

func NewRenderTools

func NewRenderTools(dirProps utils.DirectoryProperties, precompileJqHooks bool) *RenderTools

func (*RenderTools) RenderAll

func (rt *RenderTools) RenderAll(pt *PageTree)

func (*RenderTools) RenderTo

func (rt *RenderTools) RenderTo(target RenderTarget, p *Page)

type Template

type Template struct {
	Asset IAsset
	Data  string
}

type TemplateProcessor

type TemplateProcessor struct {
	// contains filtered or unexported fields
}

func NewTemplateProcessor

func NewTemplateProcessor(templatesDir string) *TemplateProcessor

func (TemplateProcessor) Get

func (tp TemplateProcessor) Get(kind string) (string, error)

func (TemplateProcessor) GetAll

func (tp TemplateProcessor) GetAll() []Template

type YamlResource

type YamlResource struct {
	Kind  string
	Title string
	Path  string
	Node  *yaml.Node
	Json  string
}

func LoadSingleYamlResource

func LoadSingleYamlResource(file string) *YamlResource

func LoadYamlResources

func LoadYamlResources(dir string) []*YamlResource

func NewYamlResource

func NewYamlResource(path string, node *yaml.Node) *YamlResource

func (*YamlResource) GetLabels

func (yr *YamlResource) GetLabels() []string

func (*YamlResource) GetParentPath

func (yr *YamlResource) GetParentPath() string

func (*YamlResource) ToObject

func (yr *YamlResource) ToObject() map[string]interface{}

func (*YamlResource) ToOrderedMap

func (yr *YamlResource) ToOrderedMap() orderedjson.Map

func (*YamlResource) UpdateJson

func (yr *YamlResource) UpdateJson()

func (*YamlResource) UpdateKindAndTitle

func (yr *YamlResource) UpdateKindAndTitle()

this is ugly, but it works for now

type YamlResourceLoader

type YamlResourceLoader struct {
	Walk     func(root string, fn filepath.WalkFunc) error
	LoadYaml func(file string) []byte
}

func DefaultYamlResourceLoader

func DefaultYamlResourceLoader() YamlResourceLoader

func (YamlResourceLoader) LoadYamlResource

func (yrl YamlResourceLoader) LoadYamlResource(spaceRootDir, relFilePath string) *YamlResource

type YqHooks

type YqHooks struct {
	// contains filtered or unexported fields
}

func NewYqHook

func NewYqHook(defaults, overrides, merges yaml.Node, while string, yqCmds []string) (YqHooks, error)

func (YqHooks) Run

func (yh YqHooks) Run(node *yaml.Node) (*yaml.Node, error)

Jump to

Keyboard shortcuts

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