62 Commits

Author SHA1 Message Date
163cbf7eea Implement live collection preview system with contextual template selection
Replace isolated template previews with live collection reconstruction:
- Frontend now reconstructs collection container with all template variants
- Users click directly on rendered templates in proper CSS context
- Perfect preservation of grid/flex layouts and responsive behavior
- Simplified API: preview endpoint returns container_html + templates for frontend reconstruction
- Enhanced UX: WYSIWYG template selection shows exactly what will be added
- Removed redundant templates endpoint in favor of unified preview approach

Backend changes:
- Add GET /api/collections/{id}/preview endpoint
- Remove GET /api/collections/{id}/templates endpoint
- Return container HTML + templates for frontend reconstruction

Frontend changes:
- Replace isolated template modal with live collection preview
- Add generateLivePreview() method for container reconstruction
- Update CollectionManager to use preview API
- Add interactive CSS styling for template selection

This provides true contextual template selection where CSS inheritance,
grid layouts, and responsive design work perfectly in preview mode.
2025-10-31 22:41:12 +01:00
81ec8edf36 Removed individual demo configs. 2025-10-31 21:05:55 +01:00
900f91bc25 Improve collection management: fix template selection UI and item positioning
This commit addresses multiple collection management issues to improve user experience:

## Template Selection Modal Improvements
- Replace inline styles with CSS classes for reliable visual feedback
- Fix default template selection conflicts that showed multiple templates as selected
- Add styled template previews that show actual CSS styling differences
- Improve modal responsiveness and visual hierarchy

## Collection Item Creation Fixes
- Fix empty collection items with no content/height that were unclickable
- Preserve template placeholder content during item creation instead of clearing it
- Implement proper positioning system using GetMaxPosition to place new items at collection end
- Add position calculation logic to prevent new items from jumping to beginning

## Backend Positioning System
- Add GetMaxPosition method to all repository implementations (SQLite, PostgreSQL, HTTPClient)
- Update CreateCollectionItemFromTemplate to calculate correct position (maxPos + 1)
- Maintain reconstruction ordering by position ASC for consistent item placement

## Frontend Template Selection
- CSS class-based selection states replace problematic inline style manipulation
- Template previews now render actual HTML with real page styling
- Improved hover states and selection visual feedback
- Fixed auto-selection interference with user interaction

These changes ensure collection items appear in expected order and template selection
provides clear visual feedback with actual styling previews.
2025-10-30 22:06:44 +01:00
00255cb105 Implement class-based template differentiation and fix collection item creation
- Add class-based template comparison to differentiate styling variants
- Implement template deduplication based on structure + class signatures
- Add GetCollectionTemplate method to repository interface and implementations
- Fix collection item creation by replacing unimplemented CreateCollectionItemAtomic
- Add template selection modal with auto-default selection in frontend
- Generate meaningful template names from distinctive CSS classes
- Fix unique constraint violations with timestamp-based collection item IDs
- Add collection templates API endpoint for frontend template fetching
- Update simple demo with featured/compact/dark testimonial variants for testing
2025-10-27 21:02:59 +01:00
4874849f80 Add comprehensive blog demo showcasing advanced content management features
- Implement complete mushroom foraging blog with chanterelles article
- Add rich demonstration of .insertr and .insertr-add functionality
- Include comprehensive documentation for future .insertr-content vision
- Update project styling and configuration to support blog demo
- Enhance engine and API handlers for improved content management
2025-10-23 21:47:51 +02:00
74de64c66b Clean up codebase: remove unused demos and test files
- Remove dan-eden-portfolio and devigo-web demo sites
- Clean up demo testing infrastructure and scripts
- Remove frontend test files (html-preservation, style-detection tests)
- Update configuration and auth improvements
- Simplify demo structure to focus on core functionality

This cleanup reduces repository size and focuses on essential demos.
2025-10-19 22:38:17 +02:00
87b78a4a69 Implement complete API routes and mock authentication for full CMS functionality
- Add comprehensive nested route structure with proper authentication layers
- Implement UpdateContent and ReorderCollectionItems handlers with repository pattern
- Add automatic mock JWT token fetching for seamless development workflow
- Restore content editing and collection reordering functionality broken after database refactoring
- Provide production-ready authentication architecture with development convenience
- Enable full CMS operations in browser with proper CRUD and bulk transaction support
2025-10-19 14:34:27 +02:00
2959ecedf9 Fix collection manager JavaScript errors after attribute naming changes
- Update collection manager to use data-collection-id instead of data-content-id
- Add safety checks to prevent undefined Map access in addItemControls
- Add validation in editor to only initialize collections with valid collection IDs
- Resolves TypeError and missing attribute errors in frontend collection management
2025-10-08 17:33:44 +02:00
824719f07d Implement collection item reordering with bulk operations and persistent HTML attributes
- Add bulk reorder API endpoint (PUT /api/collections/{id}/reorder) with atomic transactions
- Replace individual position updates with efficient bulk operations in frontend
- Implement unified ID generation and proper data-item-id injection during enhancement
- Fix collection item position persistence through content edit cycles
- Add optimistic UI with rollback capability for better user experience
- Update sqlc queries to include last_edited_by fields in position updates
- Remove obsolete data-content-type attributes and unify naming conventions
2025-10-07 22:59:00 +02:00
3e5cb76d1d Major codebase cleanup after .insertr-add functionality overhaul
Consolidates duplicate code and removes technical debt accumulated during rapid development. This cleanup improves maintainability while preserving all functionality.

Backend cleanup:
- Remove unused legacy function findViableChildrenLegacy()
- Consolidate duplicate SQL null string helper functions into shared utils
- Unify text extraction functions across utils, engine, and id_generator
- Consolidate duplicate attribute getter functions into single implementation

Frontend cleanup:
- Remove duplicate authentication methods (authenticateWithOAuth vs performOAuthFlow)
- Remove unused hasPermission() method from auth.js
- Centralize repetitive API endpoint construction in api-client.js
- Reduce excessive console logging while preserving important error logs

Impact: -144 lines of code, improved maintainability, no functionality changes
All tests pass and builds succeed

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 19:00:41 +02:00
1ae4176f23 Implement atomic collection item creation API with unified content engine approach
Updates collection creation to use database-first atomic operations for reliable collection item management. Replaces manual database calls with unified content engine methods that handle content extraction, storage, and structural template generation consistently.

Key changes:
- Replace manual database operations in CreateCollectionItem handler with DatabaseClient.CreateCollectionItemAtomic()
- Implement unified content engine approach for API-based collection item creation
- Add atomic collection item creation methods across all content clients
- Enhance reconstruction to use stored structural templates with content ID hydration
- Add comprehensive collection management API methods in JavaScript client
- Implement collection manager UI with create, delete, and reorder functionality

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-23 18:39:37 +02:00
2315ba4750 Implement complete collection persistence with database-backed survival across server restarts
• Add full multi-table schema for collections with normalized design (collections, collection_templates, collection_items, collection_item_versions)
• Implement collection detection and processing in enhancement pipeline for .insertr-add elements
• Add template extraction and storage from existing HTML children with multi-variant support
• Enable collection reconstruction from database on server restart with proper DOM rebuilding
• Extend ContentClient interface with collection operations and full database integration
• Update enhance command to use engine.DatabaseClient for collection persistence support
2025-09-22 18:29:58 +02:00
b25663f76b Unify all formatting buttons to use consistent three-layer architecture
- Remove .insertr-default-style special styling (blue background, border, dot indicator)
- Make ALL buttons use .insertr-style-preview with unified appearance
- Maintain authentic style previews in isolated .insertr-style-sample layer
- Bold buttons show bold text, .brand buttons show green uppercase text, etc.
- Eliminate visual inconsistency between semantic and detected style buttons
- Simplify CSS by removing ~50 lines of duplicate button styling
- Provide consistent professional toolbar appearance across all formatting options
2025-09-22 14:18:57 +02:00
479a537f21 Fix button alignment issue in three-layer architecture
- Move padding from .insertr-button-frame to .insertr-style-btn.insertr-style-preview
- Add align-items and justify-content to button container for proper centering
- Remove width: 100% from button frame to prevent unnecessary stretching
- Fix off-center text in default Bold, Italic, and Link buttons
- Maintain style isolation while ensuring consistent button alignment
2025-09-21 22:19:47 +02:00
948ab241ec Fix whitespace issue in default formatting buttons
- Add margin/padding reset to .insertr-style-sample to prevent browser defaults
- Remove unused .insertr-default-preview CSS that was causing confusion
- Ensure consistent spacing across all button types (default vs detected styles)
- Clean up legacy CSS classes that are no longer used with three-layer architecture
2025-09-21 22:13:49 +02:00
551b3fa301 Implement three-layer button architecture for consistent formatting button styling
- Add button frame isolation layer to prevent site CSS from affecting toolbar appearance
- Create style sample container for authentic style previews without layout interference
- Update CSS with proper containment boundaries and !important rules for button structure
- Preserve all authentic styling (color, weight, transform, decoration) in isolated preview
- Fix inconsistent button appearance across different site stylesheets (e.g. .brand class)
- Maintain professional toolbar UX while showing accurate style previews
2025-09-21 22:06:35 +02:00
0cfce1c95a Implement professional smart formatting with toggle logic and whitespace preservation 2025-09-21 21:55:08 +02:00
d44bdd41b4 feat: unify link editing interfaces with comprehensive polish
Multi-Property Editor Polish:
- Add comprehensive form styling (.insertr-form-group, .insertr-form-input, etc.)
- Professional layout with titles, validation, auto-focus, and help text
- Enhanced link/button/image editors with real-time validation
- Consistent spacing, colors, and visual hierarchy

Smart Default Formatting:
- Add Bold, Italic, Link options when not detected in content
- Intelligent detection respects existing developer styles
- Visual distinction for default vs detected styles with info-colored borders
- Content-aware: only adds to elements that benefit from text formatting

Link Interface Unification:
- Create shared createLinkConfigurationForm() component
- Eliminate code duplication between direct editing and popup creation
- Update createLinkEditor() and showLinkConfigPopup() to use shared component
- Fix link button styling to match other style buttons with preview content

Benefits:
- Consistent professional editing experience across all interfaces
- Reduced maintenance burden through code unification
- Enhanced UX with validation, keyboard shortcuts, and visual feedback
- Maintains CLASSES.md philosophy while improving out-of-box experience
2025-09-21 20:47:22 +02:00
b5e601d09f feat: implement Phase 3 container transformation with CLASSES.md compliance
- Add backend container transformation in engine.go following syntactic sugar specification
- Containers with .insertr get class removed and viable children get .insertr added
- Remove incorrect frontend container expansion - frontend only finds enhanced elements
- Fix StyleAwareEditor hasMultiPropertyElements runtime error
- Add addClass/removeClass methods to ContentEngine for class manipulation
- Update frontend to match HTML-first approach with no runtime container logic
- Test verified: container <section class='insertr'> transforms to individual h1.insertr, p.insertr, button.insertr

This completes the container expansion functionality per CLASSES.md:
Developer convenience (one .insertr enables section editing) + granular control (individual element editing)
2025-09-21 19:17:12 +02:00
4ef032cad6 refactor: simplify CSS variables by removing 10 unused/redundant variables
- Remove 6 unused z-index variables (dropdown, sticky, fixed, popover)
- Remove unused font-size-lg and bg-dark variables
- Remove 4 overly-specific input variables, use existing spacing/color vars
- Consolidate form styling to use core variables for consistency
- Add internal CSS file to gitignore to prevent auto-generation conflicts
- Reduces variable count from 38→28 (26% reduction) for easier maintenance
2025-09-20 22:03:08 +02:00
6f682372b5 fix: resolve content update payload parsing and add update vs create logic
- Extract content from formData.content instead of passing whole object
- Add logic to call updateContent() for existing content vs createContent() for new
- Fix 400 Invalid JSON error caused by sending object instead of string
- Handle different formData formats: string, {content: string}, {text: string}

The frontend was sending html_content as {type:'html', content:'...'} object
but server expected a plain string. Now properly extracts the content value.
2025-09-20 17:40:23 +02:00
2177055c76 feat: Complete HTML-first architecture implementation with API integration
- Replace value field with html_content for direct HTML storage
- Add original_template field for style detection preservation
- Remove all markdown processing from injector (delete markdown.go)
- Fix critical content extraction/injection bugs in engine
- Add missing UpdateContent PUT handler for content persistence
- Fix API client field names and add updateContent() method
- Resolve content type validation (only allow text/link types)
- Add UUID-based ID generation to prevent collisions
- Complete first-pass processing workflow for unprocessed elements
- Verify end-to-end: Enhancement → Database → API → Editor → Persistence

All 37 files updated for HTML-first content management system.
Phase 3a implementation complete and production ready.
2025-09-20 16:42:00 +02:00
bb5ea6f873 Complete library cleanup and documentation overhaul
## Library Code Cleanup (~1,200+ lines removed)
- Remove legacy markdown system (markdown.js, previewer.js)
- Delete unused EditContext code from ui/editor.js (~400 lines)
- Remove version history UI components from form-renderer.js (~180 lines)
- Clean unused CSS styles from insertr.css (~120 lines)
- Update package.json dependencies (remove marked, turndown)

## Documentation Updates
- README.md: Update from markdown to HTML-first approach
- AGENTS.md: Add current architecture guidance and HTML-first principles
- TODO.md: Complete rewrite with realistic roadmap and current status
- demos/README.md: Update for development demo server usage

## System Reality Alignment
- All documentation now reflects current working system
- Removed aspirational features in favor of actual capabilities
- Clear separation between development and production workflows
- Accurate description of style-aware editor with HTML preservation

## Code Cleanup Benefits
- Simplified codebase focused on HTML-first approach
- Removed markdown conversion complexity
- Cleaner build process without unused dependencies
- Better alignment between frontend capabilities and documentation

Ready for Phase 3a server updates with clean foundation.
2025-09-20 00:02:03 +02:00
01c8dcca76 feat: Implement dynamic style preview buttons
- Add JavaScript-based style copying from original elements to toolbar buttons
- Use getComputedStyle() to dynamically apply color, font-weight, text-decoration, text-transform
- Preserve button clickability with protected backgrounds and hover states
- Support any CSS framework/custom styles without hardcoded mappings
- Add comprehensive documentation to TODO.md for future enhancements

Examples:
- 'Emphasis' button now shows red bold text (from .emph class)
- 'Highlight' button displays with style preview while remaining clickable
- 'Brand' button demonstrates text-transform and color changes

This provides intuitive visual feedback so users immediately understand
what each formatting button will do to their content.
2025-09-19 20:48:01 +02:00
d317e2e1d9 refactor: Replace multi-property forms with popup-based link configuration
- Remove clunky multi-property editor with separate text + URL inputs
- Implement single rich text editor (contentEditable) for all content
- Add popup-based link configuration: select text → click 🔗 Link → configure
- Filter out link styles from formatting toolbar (links use popup, not buttons)
- Consolidate CSS: remove separate style-aware-editor.css, integrate into insertr.css
- Clean up 200+ lines of unused multi-property form code and styles
- Fix duplicate link style detection (no more 'Fancy Link' + 'Link' buttons)

Result: Much cleaner UX similar to modern editors where formatting uses
toolbar buttons and complex elements (links) use dedicated popups.
2025-09-19 20:16:33 +02:00
bf2927fec2 fix: Update positionForm to support new StyleAwareEditor class names
- Fix TypeError when accessing form.style by adding fallback selectors
- Support both legacy (.insertr-edit-form) and new editor class names
- Add null checks to prevent crashes when form element is not found
- Ensure ensureModalVisible works with all editor types

Resolves positioning error when opening style-aware editor interface.
2025-09-19 19:41:30 +02:00
3c4e83b302 feat: Implement complete style-aware editor interface (Phase 2)
- Add StyleAwareEditor class with intelligent editing strategy detection
- Implement three editing modes: simple text, rich content, multi-property forms
- Create dynamic formatting toolbar with buttons for detected styles
- Add multi-property editing forms for complex elements (links, images, buttons)
- Integrate contentEditable with style application/removal functionality
- Replace markdown-based editor.js with style-aware architecture
- Add comprehensive CSS styling for modern, responsive editor interface
- Support fallback editing for error cases with graceful degradation
- Enable real-time style application to selected text in rich editor
- Preserve all element attributes and structure during editing workflow

Complete implementation of CLASSES.md style preservation specification.
Phase 2 foundation ready for final testing and refinement.
2025-09-19 19:37:39 +02:00
67f9f242b5 feat: Implement complete style detection and preservation foundation
- Add StyleDetectionEngine with one-layer-deep nested element analysis
- Add HTMLPreservationEngine for direct HTML manipulation without lossy conversion
- Implement structure-preserving content parsing that maintains element positions
- Add multi-property element support for links (href + content), images (src + alt), buttons
- Create comprehensive test suite with real DOM element validation
- Replace markdown-based system foundation with HTML-first architecture
- Preserve all element attributes (classes, IDs, data-*, aria-*) during editing
- Generate human-readable style names from detected nested elements
- Support template extraction with multiple insertion points for complex elements

Foundation complete for Phase 2 style-aware editor interface per CLASSES.md specification.
2025-09-19 19:33:56 +02:00
968e64a57e refactor: Complete UI cleanup and simplify editor architecture
- Remove complex style preservation system from editor
- Simplify markdown conversion back to straightforward approach
- Remove StyleContext class and style-aware conversion methods
- Switch content type from 'html' back to 'markdown' for consistency
- Clean up editor workflow to focus on core markdown editing
- Remove ~500 lines of unnecessary style complexity

This completes the UI unification cleanup by removing the overly complex
style preservation system that was making the editor harder to maintain.
2025-09-19 16:15:56 +02:00
b7998a4b3c feat: Implement HTML-first style preservation system
- Add StyleContext class for extracting and applying HTML attributes/styles
- Enhance MarkdownConverter with style-aware conversion methods
- Switch backend storage from markdown to HTML with 'html' content type
- Update editor workflow to preserve CSS classes, IDs, and attributes
- Maintain markdown editing UX while storing HTML for style preservation
- Support complex attributes like rel, data-*, aria-*, etc.

This enables editing styled content like <a class="fancy" rel="me">text</a>
while preserving all styling attributes through the markdown editing process.
2025-09-19 16:03:05 +02:00
2a0915dda0 build: Update library assets with UI visibility fix
- Rebuild JavaScript library with delayed control panel initialization
- Update server assets to include latest UI behavior changes
- Ensure built assets reflect invisible UI for regular visitors

The control panel now only appears after gate activation, maintaining
the invisible CMS principle for end users.
2025-09-17 19:12:52 +02:00
988f99f58b fix: Hide control panel from regular visitors
- Move control panel initialization from start() to startEditor()
- Ensure UI only appears after successful gate activation
- Regular visitors now see zero indication of insertr presence
- Maintains 'invisible CMS' principle for end users

User Experience:
- Before gate: Website appears completely normal
- After gate: Control panel slides in for authenticated editors
- Gates remain the only trigger mechanism for editors
2025-09-17 17:08:35 +02:00
39b9c533fd refactor: Extract UI into dedicated control panel module
- Create InsertrControlPanel class for unified UI management
- Separate business logic from presentation layer
- Remove DOM manipulation from auth.js and editor.js
- Add comprehensive CSS for status indicators and editing effects
- Implement consistent kebab-case file naming
- Add event-driven communication between core and UI layers

UI Architecture:
- Unified control panel with status indicator and action buttons
- Color-coded status dots (gray/blue/green for visitor/auth/editing)
- Professional editing hover effects with tooltips
- Responsive design for mobile devices
- Proper z-index and accessibility management

Business Logic:
- Pure auth.js focused on authentication state and OAuth flows
- Pure editor.js focused on content editing workflow
- Event emitters for state changes between modules
- Clean separation of concerns and testable architecture
2025-09-17 16:52:49 +02:00
10c755efca Simplify CSS architecture by removing cascade layers and !important declarations
- Remove @layer declarations and complex hybrid approach
- Eliminate all !important usage - rely on natural CSS specificity
- Add explicit color declarations to prevent inheritance issues
- Class selectors (0,0,1,0) naturally beat universal selectors (0,0,0,0)
- Fixes white-on-white modal issues on sites with CSS resets
- Works in all browsers without 2022+ cascade layer requirements
- Cleaner, more maintainable CSS architecture
2025-09-17 16:32:46 +02:00
1bf597266e Implement hybrid CSS architecture to fix white-on-white modal issue on sites with CSS resets
- Migrate from inline CSS to external insertr.css with cascade layer architecture
- Add CSS CDN serving capability (ServeInsertrCSS handler and /insertr.css route)
- Implement hybrid approach: @layer insertr for modern browsers + html body selectors for legacy browsers
- Remove scattered inline CSS from JavaScript modules for better maintainability
- Solve form element spacing conflicts with aggressive site CSS resets like '* {margin:0; padding:0}'
- Enable proper CSS caching and separation of concerns
2025-09-17 14:39:34 +02:00
71561316da Fix demo site auto-enhancement and content persistence
- Restructure demo directory from test-sites/ to demos/ with flattened layout
- Add auto-enhancement on server startup for all sites with auto_enhance: true
- Fix inconsistent content ID generation that prevented dan-eden-portfolio content persistence
- Update server configuration to enhance from source to separate output directories
- Remove manual enhancement from justfile in favor of automatic server enhancement
- Clean up legacy test files and unused restore command
- Update build system to use CDN endpoint instead of file copying
2025-09-17 00:07:40 +02:00
1fa607c47c Fix site_id isolation for demo sites
- Auto-derive site_id from demo directory paths (demos/demo-site -> 'demo', demos/simple/test-simple -> 'simple')
- Add validation requiring explicit site_id for non-demo paths with helpful error messages
- Remove JavaScript 'demo' fallback and add proper error messaging for missing site_id
- Ensure each demo site uses isolated content namespace to prevent content mixing

Resolves issue where /sites/simple and /sites/demo both used site_id=demo
2025-09-16 22:23:41 +02:00
fe00a13780 Simplify script injection to single script with data attribute configuration
- Replace dual script injection (external + inline) with single script approach
- Pass site configuration via data attributes instead of inline JavaScript
- Update library auto-initialization to read config from script data attributes
- Reduce HTML bloat by eliminating 30+ lines of inline initialization code
- Maintain future-proof CDN compatibility and duplication prevention

Enhanced files now contain only one clean script tag with configuration.
2025-09-16 20:10:53 +02:00
a3fc3089d2 Simplify development workflow and fix content editing conflicts
- Replace complex multi-server setup (live-server + API) with unified Go server
- Serve all sites at /sites/{site_id} endpoints, eliminating port conflicts
- Fix content-type middleware to serve proper MIME types for static files
- Prevent script injection duplication with future-proof CDN-compatible detection
- Remove auto page reload from enhance button to eliminate editing interruptions
- Enable seamless content editing workflow with manual enhancement control

Development now requires only 'just dev' instead of complex demo commands.
All sites immediately available at localhost:8080 without hot reload conflicts.
2025-09-16 19:10:57 +02:00
d877366be0 Consolidate type definitions and fix API contract
- Move all ContentItem, ContentClient, ContentResponse types to engine/types.go as single source of truth
- Remove duplicate type definitions from content/types.go
- Update all imports across codebase to use engine types
- Enhance engine to extract existing data-content-id from HTML markup
- Simplify frontend to always send html_markup, let server handle ID extraction/generation
- Fix contentId reference errors in frontend error handling
- Add getAttribute helper method to engine for ID extraction
- Add GetAllContent method to engine.DatabaseClient
- Update enhancer to use engine.ContentClient interface
- All builds and API endpoints verified working

This resolves the 400 Bad Request errors and creates a unified architecture where the server is the single source of truth for all ID generation and content type management.
2025-09-16 16:45:29 +02:00
d0ac3088b4 refactor: consolidate database structure and move injector to engine
Database Structure Cleanup:
- Move all SQL files from ./db/ to ./internal/db/
- Update sqlc.yaml to use new paths (preserving schema+setup.sql hack)
- Consolidate database-related code in single directory
- Remove empty ./db/ directory

Injector Migration:
- Move injector.go from content package to engine package
- Update ContentClient interface to return map instead of slice for GetBulkContent
- Update database client implementation to match interface
- Remove injector dependency from enhancer (stub implementation)

Demo-Site Consolidation:
- Move demo-site to test-sites/demo-site for better organization
- Update build scripts to use new demo-site location
- Maintain all functionality while improving project structure

This continues the unified architecture consolidation by moving core content
processing logic to the engine and organizing related files properly.
2025-09-16 15:39:25 +02:00
84c90f428d feat: implement unified content engine to eliminate ID generation inconsistencies
- Create internal/engine module as single source of truth for content processing
- Consolidate 4 separate ID generation systems into one unified engine
- Update API handlers to use engine for consistent server-side ID generation
- Remove frontend client-side ID generation, delegate to server engine
- Ensure identical HTML markup + file path produces identical content IDs
- Resolve content persistence failures caused by ID fragmentation between manual editing and enhancement processes
2025-09-16 15:04:27 +02:00
cfb744f091 feat: enable markdown processing for span elements
Backend changes:
- Updated parser to treat <span> elements as markdown by default
- Changed span content type detection from ContentText to ContentMarkdown
- Spans now support **bold**, *italic*, and [links](url) formatting

Frontend changes:
- Updated content type detection to match backend behavior
- Frontend now treats spans as markdown elements for consistent processing
- Editor preview behavior now matches server-side enhancement

Benefits:
- <span class='highlight'>**bold** text</span> now processes markdown correctly
- Inline elements maintain all styling while supporting rich formatting
- Complete frontend/backend consistency for span element handling
- Expands markdown support to common inline wrapper elements

Tested and verified:
- Span elements preserve all classes, IDs, and styles
- Bold, italic, and link formatting works in span elements
- Content type properly detected as 'markdown' in both systems
2025-09-11 16:55:39 +02:00
350c3f6160 feat: implement minimal server-first markdown processing
Backend implementation:
- Add goldmark dependency for markdown processing
- Create MarkdownProcessor with minimal config (bold, italic, links only)
- Update content injector with HTML injection capabilities
- Add injectHTMLContent() for safe DOM manipulation
- Server now converts **bold**, *italic*, [links](url) to HTML during enhancement

Frontend alignment:
- Restrict marked.js to match server capabilities
- Disable unsupported features (headings, lists, code blocks, tables)
- Update turndown rules to prevent unsupported markdown generation
- Frontend editor preview now matches server output exactly

Server as source of truth:
- Build-time markdown→HTML conversion during enhancement
- Zero runtime overhead for end users
- Consistent formatting between editor preview and final output
- Raw markdown stored in database, HTML served to visitors

Tested features:
- **bold** → <strong>bold</strong> 
- *italic* → <em>italic</em> 
- [text](url) → <a href="url">text</a> 
2025-09-11 16:43:40 +02:00
3db1340cce feat: implement single POST upsert API with automatic ID generation
- Replace separate POST/PUT endpoints with unified POST upsert
- Add automatic content ID generation from element context when no ID provided
- Implement version history preservation before content updates
- Add element context support for backend ID generation
- Update frontend to use single endpoint for all content operations
- Enhanced demo site with latest database content including proper content IDs
2025-09-11 16:36:42 +02:00
74a54e4b5e feat: add restore command integration and development workflow improvements
- Add restore command to CLI root (cmd/root.go)
- Add restore-clean justfile target for development workflow
- Update justfile clean command to remove backups
- Improve auth UI status display and enhance button visibility
- Clean up auth.js formatting and enhance button management
2025-09-11 14:16:17 +02:00
ef1d1083ce fix: systematic element matching bug in enhancement pipeline
- Problem: Element ID collisions between similar elements (logo h1 vs hero h1)
  causing content to be injected into wrong elements
- Root cause: Enhancer used naive tag+class matching instead of parser's
  sophisticated semantic analysis for element identification

Systematic solution:
- Enhanced parser architecture with exported utilities (GetClasses, ContainsClass)
- Added FindElementInDocument() with content-based semantic matching
- Replaced naive findAndInjectNodes() with parser-based element matching
- Removed code duplication between parser and enhancer packages

Backend improvements:
- Moved ID generation to backend for single source of truth
- Added ElementContext struct for frontend-backend communication
- Updated API handlers to support context-based content ID generation

Frontend improvements:
- Enhanced getElementMetadata() to extract semantic context
- Updated save flow to handle both enhanced and non-enhanced elements
- Improved API client to use backend-generated content IDs

Result:
- Unique content IDs: navbar-logo-200530 vs hero-title-a1de7b
- Precise element matching using content validation
- Single source of truth for DOM utilities in parser package
- Eliminated 40+ lines of duplicate code while fixing core bug
2025-09-11 14:14:57 +02:00
f73e21ce6e feat: add manual file enhancement with development mode support
- Add manual enhance API endpoint (POST /api/enhance?site_id={site}) for triggering file enhancement
- Implement enhance button in JavaScript library status indicator (🔄 Enhance)
- Disable auto-enhancement in development mode to prevent live-reload conflicts
- Add dev mode parameter to SiteManager to control enhancement behavior
- Update API routing structure to support /api/enhance endpoint
- Include enhance button styling and user feedback (loading, success, error states)
- Button triggers file enhancement and page reload to show updated static files

Development workflow improvements:
- Content edits → Immediate editor preview (no unwanted page reloads)
- Manual enhance button → Intentional file updates + reload for testing
- Production mode maintains automatic enhancement on content changes

This resolves the live-reload conflict where automatic file enhancement
was causing unwanted page reloads during content editing in development.
2025-09-10 23:38:46 +02:00
b0c4a33a7c feat: implement unified editor with content persistence and server-side upsert
- Replace dual update systems with single markdown-first editor architecture
- Add server-side upsert to eliminate 404 errors on PUT operations
- Fix content persistence race condition between preview and save operations
- Remove legacy updateElementContent system entirely
- Add comprehensive authentication with JWT scaffolding and dev mode
- Implement EditContext.updateOriginalContent() for proper baseline management
- Enable markdown formatting in all text elements (h1-h6, p, div, etc)
- Clean terminology: remove 'unified' references from codebase

Technical changes:
* core/editor.js: Remove legacy update system, unify content types as markdown
* ui/Editor.js: Add updateOriginalContent() method to fix save persistence
* ui/Previewer.js: Clean live preview system for all content types
* api/handlers.go: Implement UpsertContent for idempotent PUT operations
* auth/*: Complete authentication service with OAuth scaffolding
* db/queries/content.sql: Add upsert query with ON CONFLICT handling
* Schema: Remove type constraints, rely on server-side validation

Result: Clean content editing with persistent saves, no 404 errors, markdown support in all text elements
2025-09-10 20:19:54 +02:00
bab329b429 refactor: implement database-specific schema architecture with schema-as-query pattern
🏗️ **Major Database Schema Refactoring**

**Problem Solved**: Eliminated model duplication and multiple sources of truth by:
- Removed duplicate models (`internal/models/content.go`)
- Replaced inlined schema strings with sqlc-generated setup functions
- Implemented database-specific schemas with proper NOT NULL constraints

**Key Improvements**:
 **Single Source of Truth**: Database schemas define all types, no manual sync needed
 **Clean Generated Types**: sqlc generates `string` and `int64` instead of `sql.NullString/sql.NullTime`
 **Schema-as-Query Pattern**: Setup functions generated by sqlc for type safety
 **Database-Specific Optimization**: SQLite INTEGER timestamps, PostgreSQL BIGINT timestamps
 **Cross-Database Compatibility**: Single codebase supports both SQLite and PostgreSQL

**Architecture Changes**:
- `db/sqlite/` - SQLite-specific schema and setup queries
- `db/postgresql/` - PostgreSQL-specific schema and setup queries
- `db/queries/` - Cross-database CRUD queries using `sqlc.arg()` syntax
- `internal/db/database.go` - Database abstraction with runtime selection
- `internal/api/models.go` - Clean API models for requests/responses

**Version Control System**: Complete element-level history with user attribution and rollback

**Verification**:  Full API workflow tested (create → update → rollback → versions)
**Production Ready**: Supports SQLite (development) → PostgreSQL (production) migration
2025-09-09 00:25:07 +02:00