- Replace type switching with clean repository pattern using sqlc-generated code - Move ContentRepository interface and domain models to db package - Create separate SQLiteRepository and PostgreSQLRepository implementations - Remove unnecessary RepositoryAdapter and ContentClient interface duplication - Update all clients (HTTP, Mock) to implement db.ContentRepository directly - Add context.Context parameters to all repository methods (Go best practice) - Eliminate duplicate domain models and type conversions - Remove type aliases - use db package types directly throughout codebase - Update engine, content managers, and API handlers to use repositories directly Benefits: - Zero runtime type switching overhead - Single source of truth for domain models - Clean package boundaries and separation of concerns - Standard Go interface patterns with context support - Easier testing with mockable repository interface - Maintainable: adding new database types requires no changes to existing code
51 lines
1.5 KiB
Go
51 lines
1.5 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
|
|
Content string // Injected content (if any)
|
|
Generated bool // Whether ID was generated (vs existing)
|
|
Tag string // Element tag name
|
|
Classes []string // Element CSS classes
|
|
}
|
|
|
|
// ContentEntry represents a content item to be created for collection templates
|
|
type ContentEntry struct {
|
|
ID string
|
|
SiteID string
|
|
HTMLContent string
|
|
Template string
|
|
}
|