Documentation ¶
Index ¶
- func InitZK(root string) error
- type GrepResult
- type Note
- type NoteMeta
- type ZK
- func (z *ZK) AddAlias(id int, name string) error
- func (z *ZK) AddFile(id int, path string, dstName string) error
- func (z *ZK) Aliases() map[string]int
- func (z *ZK) Close()
- func (z *ZK) GetFilePath(id int, name string) (string, error)
- func (z *ZK) GetFileReader(id int, name string) (io.Reader, error)
- func (z *ZK) GetNote(id int) (note Note, err error)
- func (z *ZK) GetNoteBodyPath(id int) (path string, err error)
- func (z *ZK) GetNoteMeta(id int) (md NoteMeta, err error)
- func (z *ZK) GetOrphans() (orphans []NoteMeta)
- func (z *ZK) Grep(pattern string, notes []int) (c chan *GrepResult, err error)
- func (z *ZK) LinkNote(parent, id int) error
- func (z *ZK) MetadataDump() map[int]NoteMeta
- func (z *ZK) NewNote(parent int, body string) (int, error)
- func (z *ZK) RemoveAlias(name string)
- func (z *ZK) RemoveFile(id int, name string) error
- func (z *ZK) Rescan() error
- func (z *ZK) ResolveNoteId(name string) (int, error)
- func (z *ZK) TreeGrep(pattern string, root int) (c chan *GrepResult, err error)
- func (z *ZK) UnlinkNote(parent, id int) error
- func (z *ZK) UpdateNote(id int, body string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GrepResult ¶
GrepResult contains a single matching line returned from the Grep function. The Note field is the id of the note which matched The Line field is the text of the note which matched.
type ZK ¶
type ZK struct {
// contains filtered or unexported fields
}
func NewZK ¶
NewZK creates a ZK object rooted at the specified directory. The directory should have been previously initialized with the InitZK function.
func (*ZK) AddAlias ¶
AddAlias installs an alias, allowing the note with the given id to be referred to by the specified name.
func (*ZK) AddFile ¶
AddFile copies the file at the specified path into the given note's files. If dstName is not empty, the resulting file will be given that name.
func (*ZK) GetFilePath ¶
GetFilePath returns an absolute path to a given file within a note
func (*ZK) GetFileReader ¶
GetFileReader returns an io.Reader attached to the specified file within a note
func (*ZK) GetNote ¶
GetNote returns the full contents of the specified note ID, including the body. Unlike GetNoteMeta, it actually reads from the disk and will update the in-memory state if out of sync.
func (*ZK) GetNoteBodyPath ¶
GetNoteBodyPath returns an absolute path to the given note's body file, suitable for passing to an editor. Note that changing the note's title here by editing this file will not change the title in the in-memory metadata until GetNote, Rescan, or another function which reads and parses the on-disk files is called.
func (*ZK) GetOrphans ¶
GetOrphans returns a list of "orphaned" notes, notes which are not the subnote of any other note.
func (*ZK) Grep ¶
func (z *ZK) Grep(pattern string, notes []int) (c chan *GrepResult, err error)
Grep searches note bodies for a regular expression and returns a channel of *GrepResult. If the notes parameter is non-empty, it will restrict the search to only the specified note IDs.
func (*ZK) MetadataDump ¶
MetadataDump returns the entire contents of the in-memory state. This can be useful when walking the entire tree.
func (*ZK) RemoveAlias ¶
RemoveAlias removes the specified alias.
func (*ZK) RemoveFile ¶
RemoveFile removes the specified file from the note.
func (*ZK) Rescan ¶
Rescan will attempt to re-derive the state from the contents of the zk directory. Useful if you have manually messed with the directories, or if things just seem out of sync.
func (*ZK) ResolveNoteId ¶
ResolveNoteId returns the numeric ID from a string name. You'll use this to determine if the user has specified an exact ID or an alias.
func (*ZK) TreeGrep ¶
func (z *ZK) TreeGrep(pattern string, root int) (c chan *GrepResult, err error)
TreeGrep searches note bodies for a regular expression. It takes as arguments a regular expression string and a note ID. That note, and the entire tree of subnotes below it, are searched.
func (*ZK) UnlinkNote ¶
UnlinkNote removes the specified note from the parent note's subnotes