Add automatic template versioning system

- Add TEMPLATE_VERSION constant (1.3.0) to track UI changes
- Create check_template_version() to compare embedded vs current version
- Embed version marker as HTML comment in generated template
- Auto-regenerate template when version mismatch detected
- Show clear status messages: "Template up-to-date" or "regenerating"
- Document versioning system in CLAUDE.md with usage guidelines

Benefits:
- No manual template deletion required when code updates
- Users automatically get latest UI features on restart
- Clear version tracking for template changes
- Prevents stale template issues

To update template: increment TEMPLATE_VERSION when HTML/CSS/JS changes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-27 12:28:34 +07:00
parent c68c8d2885
commit 4282b0f7ee
2 changed files with 54 additions and 11 deletions

View File

@@ -121,11 +121,28 @@ The entire Flask application lives in `rotary_phone_web.py` (~2000 lines). This
- **Extra Button Sounds**: Separate PyAudio instance to prevent blocking main recording
- **Hook Detection**: Direct GPIO reads during playback/recording loops for immediate response
### HTML Template Generation
The Flask app generates `templates/index.html` programmatically on first run. The template is defined as a string in the Python code and written to disk. To update the UI:
1. Delete `templates/` directory
2. Restart the application
3. Updated template will be regenerated
### HTML Template Generation and Versioning
The Flask app generates `templates/index.html` programmatically with automatic version tracking:
**Version System:**
- `TEMPLATE_VERSION` constant (line ~84) tracks template changes
- Version embedded as HTML comment: `<!-- TEMPLATE_VERSION: 1.3.0 -->`
- `check_template_version()` compares embedded version with current code version
- Template auto-regenerates on version mismatch
**How It Works:**
1. On startup, `check_template_version()` reads existing template
2. If version matches `TEMPLATE_VERSION`, template is up-to-date
3. If version mismatches or template missing, regeneration occurs automatically
4. User sees: "Template up-to-date (v1.3.0)" or "Template version mismatch - regenerating"
**When to Update:**
- Increment `TEMPLATE_VERSION` whenever HTML/CSS/JS changes are made
- Format: "X.Y.Z" (major.minor.patch)
- Add comment describing the change
**Manual Regeneration:**
If needed, delete `templates/` directory and restart - not required with version system
## Configuration