Session log — Vodalibrary announcements feature and dated outputs
Session log — Vodalibrary announcements feature and dated outputs
What happened, in order
1. The brief
Different problems, both about preserving history: one for the file outputs, one for what gets said to the audience.
2. Dated outputs, no overwriting
Every refresh now writes a brand new file. The filename pattern is YYYYMMDD HHMM Vodac Library.html and the matching xlsx, with the date first (no hyphens, time as four digits) so the files sort chronologically when listed alphabetically in Finder.
The launcher always opens the most recent HTML in the folder, found by a simple newest-first list. Old files stay until Hasmukh archives them by hand, which keeps the history under his control.
3. Announcements, history-style not single-banner
Two reasonable models for site-wide messages: a single live banner that gets edited in place, or a history of announcements where each one stays until expired or archived. We chose history. The reasons: a manager who signs in for the first time after three weeks should see what they missed, dismissal should be per-user (not a binary “everyone has dismissed it”), and an audit trail of what was said and when is just useful.
Each announcement carries an optional title, body, optional expiry date, and dismissal-count tracking. A banner shows e.g. “5 / 12 (42%) dismissed” to the admin so they know how many of the enrolled managers have actually seen it. URLs in the body auto-link, line breaks are preserved, basic HTML is escaped to keep the input safe.
4. What the admin sees, what the user sees
The admin panel gained a new Announcements section: post a new one, archive an old one, restore an archived one, delete one entirely. Each row shows the dismissal count alongside the title and dates.
The library page now renders active announcements as banners between the page heading and the controls bar, each with a small × dismiss button. Once a manager dismisses an announcement it disappears for them only; other managers still see it. A topbar link called Announcements gives every signed-in user access to the full history page for re-reading.
5. Self-installing schema
Two new tables: announcements (id, title, body, created_at, created_by, expires_at, is_archived) and announcement_dismissals (announcement_id, email, dismissed_at, composite primary key). The schema migration runs on every request as a single CREATE TABLE IF NOT EXISTS pair, so existing databases upgrade themselves without a manual migration step.
6. Going forward
One small process note. Hasmukh hit a “Not found” error on the very first attempt to post an announcement because an earlier in-place edit of the router silently failed on shell escaping, and the new routes never made it into the file. Fix was to switch the injection from in-line sed-over-ssh to writing the routes to a temporary file first and reading them in. Worth flagging that nested heredocs plus ssh plus shell-escaped PHP variables is a fragile pattern, prefer file-based injection for any future router edit.
Banner styling currently uses Vodacom red on a soft pink/cream gradient, easy to retune. No moderation or rate limiting on announcements; admins are trusted, fine for current scale. Email notifications for new announcements (a push via SendGrid rather than passive on-login banners) is the obvious next-up feature. Optional Markdown support in the body if plain text plus auto-linked URLs proves limiting.