catalog

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

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 New

func New(env notes.Env, client func() API, vault int64) *Catalog

New makes the catalog of a vault; Reload reads it.

func (*Catalog) Aliases

func (c *Catalog) Aliases(p string) []string

Aliases are a note's aliases.

func (*Catalog) Event

func (c *Catalog) Event(ev api.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) File

func (c *Catalog) File(p string) (api.VaultFile, bool)

File is the file at p.

func (*Catalog) Files

func (c *Catalog) Files() []api.VaultFile

Files are the vault's files, by path.

func (*Catalog) Folders

func (c *Catalog) Folders() []string

Folders are its folders, by path.

func (*Catalog) Generation

func (c *Catalog) Generation() int

Generation changes whenever the files or their times may have.

func (*Catalog) LinkText

func (c *Catalog) LinkText(p, from string) string

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.

func (*Catalog) Loaded

func (c *Catalog) Loaded() bool

Loaded reports whether the files have been read once.

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.

func (*Catalog) Search

func (c *Catalog) Search(query string, limit int, files bool) []Match

Search ranks the files and aliases for query, best first, at most limit: the quick switcher's and [['s results. Non-notes are left out unless files is true.

func (*Catalog) Sources

func (c *Catalog) Sources(from func() string, text func(path string) (string, bool)) *NoteSources

Sources are a note's completions and uploads, from the catalog: what the editor asks. text gives a note's text when a tab has it open.

type Match

type Match struct {
	Path  string
	Alias string // "" when the path matched
	Score int
}

Match is a note a query found: by its path, or by one of its aliases.

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

func (*NoteSources) Upload

func (s *NoteSources) Upload(files []editor.File, done func(embeds string, err error))

Upload stores files beside the note (ADR-0023), by the vault's settings, and gives the embeds to insert, one per line.

Jump to

Keyboard shortcuts

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