1# DokuWiki Calendar Plugin — Project History 2 3**Version 6.6.0** — Complete development history from v1.0 through v6.6.0. 4 5--- 6 7## Origins (v1.0–v4.x) 8 9The Calendar Plugin started as a basic DokuWiki calendar allowing users to add, edit, and delete events on specific dates within wiki pages. Events were stored as JSON files in DokuWiki's `data/meta/calendar/` directory, organized by month (`YYYY-MM.json`). Early versions established the core architecture: a `syntax.php` parser for `{{calendar}}` wiki markup, an `action.php` AJAX handler for event CRUD operations, and a `style.css` for layout. 10 11Key milestones in the early versions included namespace support (events scoped to wiki namespaces), multi-day events, task/checkbox support, event descriptions with wiki markup rendering, and a basic admin panel for management. 12 13--- 14 15## v5.0–v5.4: Feature Expansion 16 17### Sidebar Widget & Event Lists 18- `{{eventlist sidebar}}` — compact week-grid widget for DokuWiki sidebars showing today, tomorrow, and upcoming events 19- `{{eventpanel}}` — standalone scrollable event list 20- `{{eventlist range=N}}` — upcoming events for the next N days 21- `{{eventlist compact}}` — minimal event listing 22 23### Recurring Events 24- Events can be marked as recurring with a `recurring: true` flag and `recurringId` 25- Admin panel section for viewing and managing recurring series 26 27### Outlook Sync 28- Two-way sync with Microsoft Outlook calendars via `sync_outlook.php` 29- OAuth2 authentication flow, configurable sync intervals 30- Admin configuration panel for credentials and sync settings 31 32### Conflict Detection 33- Overlapping events on the same date/time flagged with ⚠️ badge 34- Tooltip showing conflicting event details 35 36### Admin Panel 37- Full admin interface at Admin → Calendar Management 38- Tabs: Overview, Settings, Manage, Sync, About 39- Event statistics, namespace management, import/export, cleanup tools 40 41--- 42 43## v5.5–v5.5.x: CSS Refactor 44 45Complete refactoring of the styling system from hardcoded colors to CSS custom properties (variables). Introduced the semantic color system with variables like `--text-primary`, `--text-bright`, `--text-dim`, `--bg-main`, `--cell-bg`, `--cell-today-bg`, `--border-main`, `--border-color`, etc. This laid the groundwork for the theming system. 46 47--- 48 49## v6.0.0: GitHub Publication & Theme System 50 51### Five Visual Themes 521. **Matrix** — Dark background, bright green text, green glow effects, monospace feel 532. **Purple** — Dark background, purple accents, violet glow 543. **Pink** — Dark background, hot pink accents, heart today indicator with pulse animation, firework button hover effects 554. **Professional** — Clean light theme, blue accents, no glow 565. **Wiki** — Inherits colors from the active DokuWiki template (reads `__text__`, `__background__`, `__link__`, `__border__`, etc. from `tpl_style.ini`) 57 58### Theme Architecture 59- PHP reads theme setting from `calendar_theme.txt` 60- `getThemeStyles()` returns a color array per theme 61- CSS variables injected inline into calendar, sidebar, and eventlist containers 62- Wiki theme dynamically reads DokuWiki template style variables at render time 63 64--- 65 66## v6.0.1–v6.0.9: Text, Badge & Glow Theming 67 68Progressive theming of every UI element: 69 70- **v6.0.1–v6.0.3**: Header text, day numbers, event titles, meta text, descriptions all converted from hardcoded colors to CSS variables 71- **v6.0.4–v6.0.5**: Event panel (clicked-day detail view) fully themed — header, event items, descriptions, time displays, action buttons 72- **v6.0.6**: Calendar header month/year, month picker, event list items, completed/past event states, scrollbars, namespace filter indicator 73- **v6.0.7**: All badges (TODAY, namespace, conflict ⚠️), conflict tooltips, month picker buttons, header hover states 74- **v6.0.8**: Links themed with `.cal-link` class, text glow consistency across dark themes, pink glow intensity toned down 75- **v6.0.9**: Form input text visibility on dark themes, cell hover effects, button hover/active states, glow values fine-tuned 76 77--- 78 79## v6.1.0–v6.1.6: Interactive Elements & Dark Reader 80 81- **v6.1.0**: Today indicator (filled circle like Google Calendar), themed button hover/click with brightness filters, custom checkbox styling with theme accent colors, form input placeholder text 82- **v6.1.1**: Complete CSS variable audit — 41 remaining hardcoded colors converted 83- **v6.1.2–v6.1.5**: Section header theming (Today/Tomorrow/Important), semantic color variables (`--pastdue-color`, `--tomorrow-bg`), pink heart today indicator and firework effects, all-theme checkbox glow 84- **v6.1.6**: System tooltips themed using `style.setProperty` with `!important` 85 86--- 87 88## v6.2.0–v6.2.6: Dark Reader Compatibility 89 90The Dark Reader browser extension was aggressively overriding theme colors, making dark themes unreadable. The solution evolved through several approaches: 91 92- **v6.2.0–v6.2.1**: Initial Dark Reader protection attempts using meta tags and `data-darkreader-mode` 93- **v6.2.2–v6.2.6**: Final approach — targeted inline `!important` styles and `-webkit-text-fill-color` overrides on specific elements. No page-wide locks, no filter manipulation. Protected: section headers, badges, event text, day numbers, nav buttons, status bars, tooltips, color indicator bars 94- Wiki theme intentionally left unlocked so Dark Reader can adjust it (since wiki theme is already light-friendly) 95 96--- 97 98## v6.3.0: Consolidated Dark Reader Release 99 100Merged all Dark Reader compatibility work into a single stable release. Full protection for all three dark themes across calendar, sidebar widget, and eventlist. Wiki theme headers/badges unlocked for Dark Reader mapping. 101 102--- 103 104## v6.3.1–v6.3.9: Wiki Theme Refinement 105 106Fine-tuning the Wiki theme to correctly inherit DokuWiki template colors: 107 108- **v6.3.1**: Eventlist containers receive theme class and CSS variable injection 109- **v6.3.2**: Fixed caching — added `$renderer->nocache()` so theme changes take effect immediately 110- **v6.3.3**: Section header text uses template's `__text__` instead of hardcoded white 111- **v6.3.4**: Border/accent color remapping — `border` maps to `__border__`, `text_bright` to `__link__` 112- **v6.3.5**: Allowed Dark Reader to freely adjust wiki theme headers 113- **v6.3.6–v6.3.7**: Checkbox border color from template's `__border__`, fixed shorthand override 114- **v6.3.8**: Button and section header colors from template palette 115- **v6.3.9**: Section bar fallback color fix 116 117--- 118 119## v6.4.0–v6.4.4: Wiki Theme Polish 120 121- **v6.4.0**: Section bar uses `background` div instead of `border-left` so Dark Reader maps colors identically 122- **v6.4.1**: Event highlight uses template's `__background_alt__` instead of hardcoded blue 123- **v6.4.2–v6.4.3**: Day headers (SMTWTFS) use `__background_neu__` and `__text__` 124- **v6.4.4**: Past events toggle background uses `__background_neu__` 125 126--- 127 128## v6.4.5: Admin Version History Overhaul 129 130- Replaced all purple accents with green in the version history viewer 131- Enhanced changelog parser to handle `###` subsection headers and plain bullets 132- Added "Current Release" button that jumps to the card matching the running version 133- Running version card shows green "RUNNING" badge 134 135--- 136 137## v6.4.6: Recurring Events Rescan & Detection Improvements 138 139- Added green " Rescan" button to refresh recurring events table via AJAX 140- Rewrote detection logic: two-phase approach (flagged events first, then pattern detection) 141- New "Source" column: ️ Flagged vs Detected 142- Median interval for robust pattern detection (Daily, Weekly, Bi-weekly, Monthly, Quarterly, Semi-annual, Yearly, custom) 143- Recursive namespace scanning, date deduplication, alphabetical sorting 144 145--- 146 147## v6.4.7: Recurring Events Management Controls 148 149Added an orange "Manage" button per series opening a comprehensive dialog with five operations: 150 1511. ** Extend Series** — Add N future occurrences at a chosen interval, using the last event as a template 1522. **✂️ Trim Past Events** — Remove occurrences before a cutoff date 1533. ** Change Pattern** — Respace future events to a new interval (past untouched) 1544. ** Change Start Date** — Shift all occurrences by offset between old and new start 1555. **⏸ Pause/Resume** — Toggle ⏸ prefix on future events 156 157All operations are AJAX-powered with inline status messages. 158 159--- 160 161## v6.4.8–v6.4.9: Bug Fixes 162 163- **v6.4.8**: Fixed PHP parse error — JS template literals (`${...}`) inside PHP echo blocks caused parse failures. Rewrote manage dialog using string concatenation. 164- **v6.4.9**: Fixed recurring edit/delete returning "0 changes" — root cause was directory path mismatch between event's namespace field and filesystem location. Both handlers now search ALL calendar directories recursively via `findCalendarDirs()`. 165 166--- 167 168## v6.5.0–v6.5.1: Bulk Trim All Past Recurring 169 170- Red "✂️ Trim All Past" button in recurring events section header 171- Removes all past recurring event occurrences across every namespace in one click 172- Only events with `recurring` or `recurringId` flag are removed 173- Dry-run count shown in confirmation dialog before deletion 174 175--- 176 177## v6.5.2–v6.5.6: Namespace Cleanup & AJAX Routing Fix 178 179- **v6.5.2**: " Cleanup" button to remove empty namespace calendar folders 180 - Dry-run scan shows exactly what will be removed 181 - Removes empty calendar directories and empty parent namespace directories 182 - Root calendar directory is never removed 183- **v6.5.3–v6.5.4**: Fixed PHP parse errors caused by unescaped single quotes in JS within PHP echo blocks. Added `adminColors` JS object for theme-aware runtime colors. 184- **v6.5.5**: Fixed "Unknown action" error — AJAX calls route through `action.php`, not `admin.php`. Added `routeToAdmin()` bridge in `action.php` and public `handleAjaxAction()` in `admin.php`. Moved cleanup button inline next to "➕ New Namespace". 185- **v6.5.6**: Cleanup results now display as standard message banner at page top instead of inline. Fixed button text flash. 186 187--- 188 189## v6.6.0: Package Cleanup 190 191- Removed all auxiliary documentation files (.md/.txt) except README.md 192- Consolidated project history into this document 193- Clean package containing only essential plugin files 194 195--- 196 197## v7.0.0–v7.0.8: Stability & Architecture 198 199### Class-Based Architecture (v7.0.0) 200- Introduced modular PHP classes: `FileHandler` (atomic file I/O with locking), `EventCache` (5-min TTL caching), `RateLimiter` (60/30 req/min read/write), `EventManager` (consolidated CRUD), `AuditLogger` (admin audit trail) 201- Custom date/time pickers replacing native browser inputs 202- Accessibility improvements (ARIA labels, keyboard navigation, focus management) 203 204### Google Calendar Sync (v7.0.7) 205- `GoogleCalendarSync.php` class — OAuth 2.0 flow, import/export, calendar selection 206- Admin panel Google Sync tab 207 208### Timezone Fix (v7.0.8) 209- Fixed timezone-related date rendering issues 210 211--- 212 213## v7.1.0–v7.2.x: Features & Farm Compatibility 214 215### New Features 216- **Default Search Scope** (v7.1.0) — Admin setting for "This Month" vs "All Dates" default 217- **Namespace Exclude** (v7.1.1) — `exclude=` parameter for wildcard/multi-namespace views 218- **Sunday Recurring Fix** (v7.1.0) — PHP falsy `'0'` caused Sunday-only recurring events to generate 365 daily events 219 220### DokuWiki Farm Compatibility (v7.1.3–v7.2.1) 221- Replaced 77 hardcoded `DOKU_INC . 'data/meta/'` paths with `$conf['metadir']` via `metaDir()` helper 222- Cache/rate-limit paths use `$conf['cachedir']` 223- Per-animal sync credentials with `syncConfigPath()` fallback 224- CLI-safe `sync_outlook.php` with regex-based `local.php` parsing (no `init.php` bootstrap) 225- Temp files (`.event_stats_cache`, `.sync_abort`) moved from shared plugin dir to per-animal data dir 226 227### Security Hardening (v7.1.4–v7.2.6) 228- ACL enforcement on all AJAX read (`AUTH_READ`) and write (`AUTH_EDIT`) operations 229- CSRF token validation on admin `handle()` method 230- `formSecurityToken()` on all 12 HTML forms and `JSINFO.sectok` on all JS dynamic forms/fetch calls 231- Google sync AJAX actions (`google_disconnect`, `google_import`, `google_export`) added to `$writeActions` 232- Removed `get_system_stats.php` endpoint (exposed server internals via `shell_exec`) 233- Removed all system stats inline JS, HTML bars, CSS, and admin UI 234 235### Performance (v7.1.7–v7.1.8) 236- Replaced recursive `findSubNamespaces` (scanned every dir in `data/meta/`) with `findCalendarNamespaces` using iterative `glob()` — orders of magnitude faster on large wikis 237 238--- 239 240## v7.3.0–v7.5.1: Multi-Day Events & Bar Alignment 241 242### Multi-Day Past Detection Fix (v7.3.0) 243- Events spanning multiple days now check `endDate` instead of start date when determining if past 244- A March 4–6 event is no longer marked past on March 5 245 246### Multi-Day Bar Alignment (v7.5.0–v7.5.1) 247- Stable slot assignment algorithm: multi-day events reserve a consistent vertical row across all days they span 248- Single-day events fill remaining slots, sorted by time 249- Invisible spacer elements maintain alignment on days where a slot is occupied by a spanning event on neighboring days but not the current day 250- Removed CSS `order: -1` on `.event-bar-no-time` which was overriding the slot-based DOM order 251- Algorithm implemented in both JS (`rebuildCalendar`) and PHP (initial page render) for consistency 252 253--- 254 255## Architecture Summary 256 257### Files 258| File | Purpose | 259|------|---------| 260| `plugin.info.txt` | DokuWiki plugin metadata | 261| `syntax.php` | Wiki markup parser — renders `{{calendar}}`, `{{eventlist}}`, `{{eventpanel}}` with slot-based bar alignment | 262| `action.php` | AJAX handlers for event CRUD, month loading, task toggling, admin action routing, ACL enforcement | 263| `admin.php` | Full admin panel — settings, namespace management, recurring events, sync, backup, themes, CSRF-protected | 264| `style.css` | All CSS with theme-aware custom properties, Dark Reader protection, responsive design | 265| `calendar-main.js` | Client-side calendar rendering, slot-based multi-day bar alignment, event dialogs, month navigation | 266| `script.js` | Bootstrap loader with version-based cache key | 267| `sync_outlook.php` | CLI Outlook calendar sync via Microsoft Graph API (cron-safe) | 268| `classes/FileHandler.php` | Atomic file operations with locking | 269| `classes/EventCache.php` | Caching layer with TTL, uses `$conf['cachedir']` | 270| `classes/EventManager.php` | Consolidated event CRUD operations | 271| `classes/RateLimiter.php` | AJAX rate limiting, uses `$conf['cachedir']` | 272| `classes/AuditLogger.php` | Admin operation audit trail | 273| `classes/GoogleCalendarSync.php` | Google Calendar OAuth 2.0 integration | 274 275### Data Storage (Farm-Safe) 276- Events: `$conf['metadir']/[namespace]/calendar/YYYY-MM.json` 277- Theme: `$conf['metadir']/calendar_theme.txt` 278- Search default: `$conf['metadir']/calendar_search_default.txt` 279- Sync credentials: `$conf['metadir']/calendar/sync_config.php` (per-animal) or `DOKU_PLUGIN/calendar/sync_config.php` (shared fallback) 280- Cache: `$conf['cachedir']/calendar/` 281- Rate limits: `$conf['cachedir']/calendar/ratelimit/` 282 283### Security 284- ACL: `checkNamespaceRead()` / `checkNamespaceEdit()` on all AJAX endpoints 285- CSRF: `checkSecurityToken()` in admin `handle()`, `formSecurityToken()` on forms, `JSINFO.sectok` on fetch calls 286- Rate limiting: 60 req/min reads, 30 req/min writes 287- Path traversal: regex validation on namespace names 288 289--- 290 291*This document covers the complete development from initial creation through version 7.6.0.* 292