Files
insertr/internal/engine/types.go
Joakim 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

60 lines
1.9 KiB
Go

package engine
import (
"golang.org/x/net/html"
)
// ProcessMode defines how the engine should process content
type ProcessMode int
const (
// Enhancement mode: Parse + Generate IDs + Inject content + Add editor assets
Enhancement ProcessMode = iota
// IDGeneration mode: Parse + Generate IDs only (for API)
IDGeneration
// ContentInjection mode: Parse + Generate IDs + Inject content only
ContentInjection
)
// ContentInput represents input to the content engine
type ContentInput struct {
HTML []byte // Raw HTML or markup
FilePath string // File context (e.g., "index.html")
SiteID string // Site identifier
Mode ProcessMode // Processing mode
}
// ContentResult represents the result of content processing
type ContentResult struct {
Document *html.Node // Processed HTML document
Elements []ProcessedElement // All processed elements
GeneratedIDs map[string]string // Map of element positions to generated IDs
}
// ProcessedElement represents an element that has been processed
type ProcessedElement struct {
Node *html.Node // HTML node
ID string // Generated content ID
Type string // Content type (text, markdown, link)
Content string // Injected content (if any)
Generated bool // Whether ID was generated (vs existing)
Tag string // Element tag name
Classes []string // Element CSS classes
}
// ContentClient interface for accessing content data
// This will be implemented by database clients
type ContentClient interface {
GetContent(siteID, contentID string) (*ContentItem, error)
GetBulkContent(siteID string, contentIDs []string) (map[string]ContentItem, error)
}
// ContentItem represents a piece of content from the database
type ContentItem struct {
ID string
SiteID string
Value string
Type string
LastEditedBy string
}