Add version command

This commit is contained in:
Marek S. Lukasiewicz
2025-01-05 17:57:27 +01:00
parent d28bd28efc
commit 529c534d4a
3 changed files with 12 additions and 2 deletions

View File

@@ -56,7 +56,6 @@ select summary, description
## Roadmap
- Command for plug version with lower priority (cf. `silverbullet-grep`)
- Cache the calendar according to `REFRESH-INTERVAL` or `X-PUBLISHED-TTL`, command for manual update
- More query sources:
- `ical-todo` for `VTODO` components

View File

@@ -2,6 +2,11 @@ name: icalendar
requiredPermissions:
- fetch
functions:
showVersion:
path: ./icalendar.ts:showVersion
command:
name: "iCalendar: Version"
priority: -2
queryEvents:
path: ./icalendar.ts:queryEvents
events:

View File

@@ -1,8 +1,10 @@
import { system } from "@silverbulletmd/silverbullet/syscalls";
import { editor, system } from "@silverbulletmd/silverbullet/syscalls";
import { QueryProviderEvent } from "@silverbulletmd/silverbullet/types";
import { applyQuery } from "@silverbulletmd/silverbullet/lib/query";
import { parseIcsCalendar, type VCalendar } from "ts-ics";
const VERSION = "0.1.0";
// Try to match SilverBullet properties where possible.
// Timestamps should be strings formatted with `localDateString`
interface Event {
@@ -119,3 +121,7 @@ export function localDateString(d: Date): string {
":" + String(d.getSeconds()).padStart(2, "0") +
"." + String(d.getMilliseconds()).padStart(3, "0");
}
export async function showVersion() {
await editor.flashNotification(`iCalendar Plug ${VERSION}`);
}