From abd85b71acd21eb3c7d20b4d04c0d77511cc09c8 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 26 Nov 2026 10:23:59 +0100 Subject: feat(calendar): a dropped .ics opens the event editor, filled in A lone .ics dropped on the island's sliver goes to the calendar rather than the assistant canvas: the panel opens on the event's month with the new-event form filled from the file, for review before Save. The bubble says where the drop will go while the drag is over it. calctl gains `read FILE`, which returns the file's master VEVENT in the same shape as `get`, with no UID so saving creates a new event in the default calendar. A rule or alarm the form cannot express reads `none`: `custom` would tell apply() to keep what is there, and a new event has nothing there to keep. The drop no longer needs the assistant to be present for .ics files. Co-Authored-By: Claude Opus 5.5 --- desktop/island/calendar/calctl | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'desktop/island/calendar/calctl') diff --git a/desktop/island/calendar/calctl b/desktop/island/calendar/calctl index ce98098..a28b20a 100755 --- a/desktop/island/calendar/calctl +++ b/desktop/island/calendar/calctl @@ -18,6 +18,7 @@ # calctl calendars {default, calendars: [{name, color, path}]} # calctl list FROM TO occurrences in [FROM, TO), local time # calctl get UID CAL the series itself, for the editor +# calctl read FILE an outside .ics as a new event, for the editor # calctl new EVENT-JSON {uid} # calctl edit UID CAL EVENT-JSON {uid}; CAL is where it is now # calctl delete UID CAL {} @@ -61,7 +62,7 @@ COLORS = { "cyan": "teal", "dark cyan": "teal", "light cyan": "teal", } -USAGE = ("usage: calctl calendars | list FROM TO | get UID CAL | new JSON" +USAGE = ("usage: calctl calendars | list FROM TO | get UID CAL | read FILE | new JSON" " | edit UID CAL JSON | delete UID CAL") @@ -293,6 +294,28 @@ def cmd_get(uid, cal_name): return to_json(cal, ev, start, end, all_day, overrides()) +def cmd_read(file): + """A dropped .ics (an invite, a booking) as a draft for the editor: no + UID, so saving creates a new event in the default calendar. A rule or + alarm the form cannot show reads `none`: a new event has nothing to keep.""" + try: + ev = master(icalendar.Calendar.from_ical(Path(file).read_bytes())) + except OSError as e: + raise Fail(f"cannot read {file}: {e.strerror}") + except ValueError as e: + raise Fail(f"not a calendar file: {e}") + if ev is None or "DTSTART" not in ev: + raise Fail("no event in that file") + cals, default = calendars() + cal = next(c for c in cals if c["name"] == default) + d = to_json(cal, ev, *span(ev), set()) + d["uid"] = "" + for key in ("repeat", "alarm"): + if d[key] == "custom": + d[key] = "none" + return d + + def parse_payload(text, cals): """The form's JSON, checked. Dates become date/datetime; an all-day end becomes exclusive.""" @@ -470,6 +493,8 @@ def main(argv): data = cmd_list(*args) elif cmd == "get" and len(args) == 2: data = cmd_get(*args) + elif cmd == "read" and len(args) == 1: + data = cmd_read(*args) elif cmd == "new" and len(args) == 1: data = cmd_new(*args) elif cmd == "edit" and len(args) == 3: -- cgit v1.2.3