Files
adamfandClaude Opus 5.5 ba92f1fbda
CI / test (3.10) (push) Successful in 1m20s
CI / test (3.12) (push) Successful in 1m49s
CI / test (3.13) (push) Successful in 1m5s
Add scheduled and event-driven printing with a new web UI
The web server now runs a scheduler over schedules kept in SQLite
(~/.local/share/receipt-maker, outside the clone). A schedule is a
trigger, a receipt made of blocks, and options:

- Triggers: once, recurring (rrule-based, DST-safe), sun times,
  reminders before calendar (ICS) events, RSS/JSON watchers, webhooks
  with per-schedule secrets.
- Blocks, rendered fresh as one job: templated notes ({date},
  {days_until:..}, rotating {choice}, trigger vars), QR, saved images,
  random image, calendar agenda, feed headlines, dividers.
- Rules: quiet hours (hold/skip/ignore), daily cap, pause, catch-up
  window for missed runs (never replayed), retries on connect failure
  only; a mid-job drop (new PrinterDropped) is never resent.

receipt.py renders through composable Blocks (render_note/image/qr are
wrappers, output unchanged). Print history persists, with Print again.
The page moves to web/ with Print (note/image/QR + paper preview),
Schedules (presets, editor with live preview and next runs), History
and Settings tabs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-23 23:58:26 +01:00

36 lines
1.3 KiB
JavaScript

// The receipt preview: a strip of thermal paper drawn from /api/preview's parts.
import {h, clear} from "./dom.js";
export function paper() {
const strip = h("div", {class: "paper-strip"});
const meta = h("div", {class: "paper-meta"});
const root = h("div", {class: "paper-wrap"}, h("div", {class: "paper"}, strip), meta);
return {
root,
show(preview) {
clear(strip, preview.parts.map((part) => {
if (part.image) return h("img", {src: part.image, alt: ""});
const cls = ["t", `s${part.size || 1}`, part.bold ? "b" : "", part.center ? "c" : ""];
return h("pre", {class: cls.join(" ")}, part.text);
}));
const length = `${preview.height_mm} mm of paper`;
clear(meta,
h("span", {class: preview.too_long ? "err" : "muted"},
preview.too_long ? `${length}: over the ${preview.max_mm} mm limit` : length),
(preview.warnings || []).map((w) => h("div", {class: "warn"}, w)));
root.classList.remove("error");
},
error(text) {
clear(strip, h("pre", {class: "t s1 placeholder"}, text));
clear(meta);
root.classList.add("error");
},
empty(text) {
clear(strip, h("pre", {class: "t s1 placeholder"}, text));
clear(meta);
root.classList.remove("error");
},
};
}