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]>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Shared test fakes."""
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
from escpos import printer
|
||||
|
||||
@@ -54,3 +55,34 @@ def make_args(**overrides):
|
||||
}
|
||||
defaults.update(overrides)
|
||||
return argparse.Namespace(**defaults)
|
||||
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures"
|
||||
CALENDAR_URL = "https://calendar.test/work.ics"
|
||||
FEED_URL = "https://feed.test/rss.xml"
|
||||
|
||||
|
||||
class FakeCache:
|
||||
"""Stands in for receipt_sources.SourceCache: canned bodies by URL, no network."""
|
||||
|
||||
def __init__(self, bodies=None):
|
||||
self.bodies = {
|
||||
CALENDAR_URL: (FIXTURES / "calendar.ics").read_bytes(),
|
||||
FEED_URL: (FIXTURES / "feed.xml").read_bytes(),
|
||||
**(bodies or {}),
|
||||
}
|
||||
self.gets = []
|
||||
|
||||
def get(self, url, max_age):
|
||||
from receipt_sources import SourceError
|
||||
|
||||
self.gets.append(url)
|
||||
body = self.bodies.get(url)
|
||||
if isinstance(body, Exception):
|
||||
raise body
|
||||
if body is None:
|
||||
raise SourceError("couldn't connect")
|
||||
return body
|
||||
|
||||
def forget(self, url):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user