Documentation
¶
Overview ¶
Package catalog is what the desktop app knows of a vault's files (docs/design/app.md#data): the files and folders from notesd, the notes' aliases and the tags, kept up to date from its events, with the link text and completions the editor asks for. It imports no window.
Index ¶
- Constants
- type API
- type Catalog
- func (c *Catalog) Aliases(p string) []string
- func (c *Catalog) Event(ev api.Event)
- func (c *Catalog) File(p string) (api.VaultFile, bool)
- func (c *Catalog) Files() []api.VaultFile
- func (c *Catalog) Folders() []string
- func (c *Catalog) Generation() int
- func (c *Catalog) LinkText(p, from string) string
- func (c *Catalog) Loaded() bool
- func (c *Catalog) OnChange(fn func())
- func (c *Catalog) Reload()
- func (c *Catalog) Search(query string, limit int, files bool) []Match
- func (c *Catalog) Sources(from func() string, text func(path string) (string, bool)) *NoteSources
- type Match
- type NoteSources
- func (s *NoteSources) LinkTargets(query string, limit int) []editor.Target
- func (s *NoteSources) Resolve(target string) string
- func (s *NoteSources) Subpaths(target string, blocks bool, done func([]editor.Target))
- func (s *NoteSources) Tags() []string
- func (s *NoteSources) Upload(files []editor.File, done func(embeds string, err error))
Constants ¶
const ( // AliasesDelay is how long after the files change the aliases are // read again. AliasesDelay = time.Second // TagsTTL is how long the tags are kept before they are read again. TagsTTL = 10 * time.Second // ReloadDelay is how long after a new file the files are read again. ReloadDelay = 250 * time.Millisecond )
The catalog's timing, as the web app's.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface {
Files(ctx context.Context, p *api.NoteFilesParams) (*api.VaultFiles, error)
List(ctx context.Context, p *api.NoteListParams) ([]api.NoteEntry, error)
Tags(ctx context.Context, p *api.NoteTagsParams) ([]api.TagCount, error)
Resolve(ctx context.Context, p *api.NoteResolveParams) ([]api.Resolution, error)
Read(ctx context.Context, p *api.NoteReadParams) (*api.Note, error)
Upload(ctx context.Context, p *api.NoteUploadParams) (*api.WriteResult, error)
}
API is what the catalog needs of notesd; api.NoteClient has it.
type Catalog ¶
type Catalog struct {
// LinkFormat is the vault's: shortest, relative or absolute.
LinkFormat string
// AttachmentFolder and Wikilinks are the vault's attachment settings.
AttachmentFolder string
Wikilinks bool
// contains filtered or unexported fields
}
Catalog is one vault's files. UI thread only.
func (*Catalog) Event ¶
Event follows notesd's events for the catalog's vault: a known file's new hash is patched in; anything else reads the files again.
func (*Catalog) Generation ¶
Generation changes whenever the files or their times may have.
func (*Catalog) LinkText ¶
LinkText is what a link from the note at from writes to name p, by the vault's link format: absolute, the path; relative, the path from the note's folder; shortest, the file's name when no other file has it, else the path. A note's ".md" is left out. When the text would resolve to another file from the linking note, the link is the rooted path ("/" and the path).
func (*Catalog) OnChange ¶
func (c *Catalog) OnChange(fn func())
OnChange calls fn on the UI thread when the files, aliases or tags change.
func (*Catalog) Reload ¶
func (c *Catalog) Reload()
Reload reads the files, then the aliases and tags.
type NoteSources ¶
type NoteSources struct {
// contains filtered or unexported fields
}
NoteSources are one note's completions and uploads.
func (*NoteSources) LinkTargets ¶
func (s *NoteSources) LinkTargets(query string, limit int) []editor.Target
LinkTargets lists the notes [[ completes to.
func (*NoteSources) Resolve ¶
func (s *NoteSources) Resolve(target string) string
Tags lists the vault's tags, by count. Resolve is the file a link from the note names, "" for none, by the rules notesd follows (docs/specs/markdown.md#link-resolution).
func (*NoteSources) Subpaths ¶
func (s *NoteSources) Subpaths(target string, blocks bool, done func([]editor.Target))
Subpaths lists the headings or block IDs of the note target leads to ("" is the note being edited), from its text.
func (*NoteSources) Tags ¶
func (s *NoteSources) Tags() []string