From b75eda2a87b3f7d0b157fe508511685f1e9077e3 Mon Sep 17 00:00:00 2001 From: Joakim Date: Sun, 21 Sep 2025 19:23:54 +0200 Subject: [PATCH] feat: complete HTML-first architecture implementation (Phase 1 & 2) Major architectural simplification removing content type complexity: Database Schema: - Remove 'type' field from content and content_versions tables - Simplify to pure HTML storage with html_content + original_template - Regenerate all sqlc models for SQLite and PostgreSQL API Simplification: - Remove content type routing and validation - Eliminate type-specific handlers (text/markdown/structured) - Unified HTML-first approach for all content operations - Simplify CreateContent and UpdateContent to HTML-only Backend Enhancements: - Update enhancer to only generate data-content-id (no data-content-type) - Improve container expansion utilities with comprehensive block/inline rules - Add Phase 3 preparation with boundary-respecting traversal logic - Strengthen element classification for viable children detection Documentation: - Update TODO.md to reflect Phase 1-3 completion status - Add WORKING_ON.md documenting the architectural transformation - Mark container expansion and HTML-first architecture as complete This completes the transition to a unified HTML-first content management system with automatic style detection and element-based behavior, eliminating the complex multi-type system in favor of semantic HTML-driven editing. --- TODO.md | 40 +++++- WORKING_ON.md | 187 +++++++++++++++++++++++++ cmd/enhance.go | 54 +++++-- internal/api/handlers.go | 31 +--- internal/api/models.go | 3 - internal/content/client.go | 2 +- internal/content/database.go | 10 +- internal/content/mock.go | 47 +++---- internal/db/postgresql/content.sql.go | 37 ++--- internal/db/postgresql/models.go | 2 - internal/db/postgresql/schema.sql | 2 - internal/db/postgresql/setup.sql | 2 - internal/db/postgresql/setup.sql.go | 2 - internal/db/postgresql/versions.sql.go | 16 +-- internal/db/queries/content.sql | 23 ++- internal/db/queries/versions.sql | 10 +- internal/db/sqlite/content.sql.go | 37 ++--- internal/db/sqlite/models.go | 2 - internal/db/sqlite/schema.sql | 2 - internal/db/sqlite/setup.sql | 2 - internal/db/sqlite/setup.sql.go | 2 - internal/db/sqlite/versions.sql.go | 16 +-- internal/engine/database_client.go | 14 +- internal/engine/types.go | 4 +- internal/engine/utils.go | 137 ++++++++++++++++-- 25 files changed, 470 insertions(+), 214 deletions(-) create mode 100644 WORKING_ON.md diff --git a/TODO.md b/TODO.md index 832fc62..d27b4d0 100644 --- a/TODO.md +++ b/TODO.md @@ -10,12 +10,15 @@ - **Authentication System**: Mock (development) + Authentik OIDC (production) - **Build-Time Enhancement**: Content injection from database to static HTML - **Development Workflow**: Hot reload, auto-enhanced demo sites, seamless testing +- **Container Transformation**: CLASSES.md syntactic sugar - containers auto-expand to viable children ### **šŸ—ļø Architecture Achievements** - **Zero Configuration**: Just add `class="insertr"` to any element - **Framework Agnostic**: Works with any static site generator - **Performance First**: Regular visitors get pure static HTML with zero CMS overhead - **HTML-First**: No lossy markdown conversion - perfect attribute preservation +- **Unified System**: Single HTML preservation path for all content types +- **Element-Based Behavior**: Automatic editing interface based on HTML tag semantics --- @@ -24,7 +27,7 @@ ### **šŸ”“ Phase 1: Editor Integration Polish** (High Priority) #### **Frontend-Backend Integration** -- [ ] **Editor-API Connection**: Wire up StyleAware editor saves to actual HTTP API +- [x] **Editor-API Connection**: StyleAware editor saves successfully to HTTP API - [ ] **Error Handling**: Proper error states, loading indicators, offline handling - [ ] **Content Validation**: Client-side validation before API calls - [ ] **Save Feedback**: Professional save/error feedback in editor interface @@ -49,7 +52,40 @@ - [ ] **Content Approval**: Editorial workflows and publishing controls - [ ] **Performance Monitoring**: Analytics and optimization tools -### **🟢 Phase 3: Advanced CMS Features** (Low Priority) +### **āœ… Phase 3: Container Expansion Intelligence** (Complete) + +#### **Element Classification and Boundaries** +- [x] **HTML Semantics Approach**: Use HTML tag semantics for block vs inline detection +- [x] **Framework Agnostic Processing**: No special framework container detection +- [x] **Boundary Rules**: Only `.insertr` elements are boundaries, traverse all other containers +- [x] **Block/Inline Classification**: Clear rules for when elements get `.insertr` vs formatting + +#### **Implementation Status** +- [x] **Backend Container Transformation**: Implemented syntactic sugar transformation in `internal/engine/engine.go` +- [x] **Frontend Container Logic Removal**: Cleaned up `lib/src/core/insertr.js` - frontend finds enhanced elements only +- [x] **Backend Viable Children**: Updated `internal/engine/utils.go` with comprehensive block/inline logic +- [x] **Recursive Traversal**: Deep nesting support with proper boundary respect implemented +- [x] **CLASSES.md Compliance**: Container expansion now follows specification exactly + +#### **Complex Element Handling** (Deferred) +- [ ] **Table Editing**: Complex hierarchy needs separate planning for ``, ``, `
` elements + - Tables have nested semantic structure that doesn't fit simple block/inline model + - Need to determine: Should individual cells be editable? Entire table? Row-level? + - Consider: Table headers, captions, complex layouts, accessibility concerns + +- [ ] **Form Element Editing**: Interactive form controls need specialized editors + - `` fields: Different types need different editing interfaces (text, email, etc.) + - `