notesy::cards

When the pointer rests on a note, a file or a folder in the tree, notesy shows a card about it: its words and dates, its tags, a folder's counts. A plugin's script can add a part of its own, under notesy's. It takes the ui permission, and notes.read as well: a card shows what's in the vault.

rustuse notesy::{cards, notes, view};

pub fn ready() {
    cards::add("tasks", #{ on: ["note"] }, |target| {
        let note = notes::read(target.path)?;
        let tasks = note.tasks().len();
        if tasks == 0 {
            return None;
        }
        view::columns([view::stats([[tasks, "tasks"]]), view::note("left in this note")])
    });
}

#Adding one

Function What it does
cards::add(key, options, build) Adds its part to the cards its options name, and returns it. build(target) makes what it shows, a view (notesy::view), or None to show nothing on this one.

key names it as a menu item's does (notesy::menus). options is #{ on }: note, file or folder, one or a list; all three unless it says. target is #{ place, path }: place is note, file or folder, and path is within the vault.

#When it's built

notesy asks the script for it when the pointer first rests on something, again once that's changed on disk, and after refresh. In between it shows the last one built, so a card never waits on a script: a plugin's part shows a moment after notesy's own, once it's built. It's built within a view's budget of 5,000,000 instructions (Scripts); one that fails shows why in its place, and counts as a failure. notesy keeps the last few dozen built.

A card is only looked at (the pointer leaves it to click anything), so nothing in it is heard: its targets and inputs do nothing there.

#A card

Method What it does
refresh() Builds it again wherever it shows: after the script's own data changed.
remove() Takes it away.

Every page