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
- Overview
- plugin.toml: Every field of plugin.toml
- Permissions: What a plugin can ask for, when notesy asks, and what changes it
- Scripts: How a script runs: its lifecycle, events, limits and errors
- Packing and installing: Making, checking, signing, packing and installing
- notesy::log: Lines for its log on the Plugins page
- notesy::events: Hearing what happens, and every event
- notesy::commands: Adding commands, and running notesy's
- notesy::store: Keeping its own data
- notesy::settings: Reading its settings
- notesy::secrets: Keys and tokens, in the system keychain
- notesy::notes: Reading and changing the vault's notes
- notesy::editor: The note in front
- notesy::files: A folder of its own
- notesy::links: Opening pages in the browser
- notesy::clipboard: Copying and pasting
- notesy::view: What panels, tabs and sections show
- notesy::panels and notesy::views: Adding side panels and tabs
- notesy::sections: Sidebar sections
- notesy::menus: Items in notesy's right-click menus
- notesy::status: Status bar items
- notesy::notices: Notices
- notesy::dialogs: Asking in a dialog, notesy's kinds or its own
- notesy::cards: Its part of the tree's hover cards
- notesy::boards: Boards' cards and arrows, and kinds of card of its own
- notesy::blocks: Drawing its fenced blocks
- notesy::icons: Drawing its own icons
- notesy::net: Requests to the sites it names
- notesy::accounts: Signing in to a service
- notesy::json: Reading and writing JSON
- notesy::toml: Reading and writing TOML
- notesy::yaml: Reading and writing YAML, and a note's front matter
- notesy::time: Now, written in the user's time zone, dates read, how long ago
- notesy::math: Trigonometry and the like, for drawing
- Names: Icon, Color, Tone, Side, Method, Command, Menu, Sidebar, Event: Notesy's names as enums
- notesy::preview: Its own screens for notesy preview
- notesy::perf: Timing its own work
- notesy::tex: Math macros for every note's formulas