package content import ( "fmt" "os" "path/filepath" "github.com/insertr/insertr/internal/engine" ) // Enhancer combines parsing and content injection using unified engine type Enhancer struct { engine *engine.ContentEngine // injector functionality will be integrated into engine } // NewEnhancer creates a new HTML enhancer using unified engine func NewEnhancer(client ContentClient, siteID string) *Enhancer { // Create database client for engine var engineClient engine.ContentClient if dbClient, ok := client.(*DatabaseClient); ok { engineClient = engine.NewDatabaseClient(dbClient.db) } else { // For non-database clients, we'll implement proper handling later engineClient = engine.NewDatabaseClient(nil) // This will need to be fixed } return &Enhancer{ engine: engine.NewContentEngine(engineClient), } } // EnhanceFile processes an HTML file and injects content func (e *Enhancer) EnhanceFile(inputPath, outputPath string) error { // TODO: Implement with unified engine // For now, just copy the file to maintain functionality return e.copyFile(inputPath, outputPath) } // EnhanceDirectory processes all HTML files in a directory func (e *Enhancer) EnhanceDirectory(inputDir, outputDir string) error { // Create output directory if err := os.MkdirAll(outputDir, 0755); err != nil { return fmt.Errorf("creating output directory: %w", err) } // Walk input directory and copy files for now return filepath.Walk(inputDir, func(path string, info os.FileInfo, err error) error { if err != nil { return err } // Calculate relative path and output path relPath, err := filepath.Rel(inputDir, path) if err != nil { return err } outputPath := filepath.Join(outputDir, relPath) // Handle directories if info.IsDir() { return os.MkdirAll(outputPath, info.Mode()) } // Copy files (HTML processing will be implemented later) return e.copyFile(path, outputPath) }) } // EnhanceInPlace performs in-place enhancement of static site files func (e *Enhancer) EnhanceInPlace(sitePath string, siteID string) error { // TODO: Implement with unified engine // For now, just log that enhancement was requested fmt.Printf("📄 Enhancement requested for site %s at %s (stub implementation)\n", siteID, sitePath) return nil } // copyFile copies a file from src to dst func (e *Enhancer) copyFile(src, dst string) error { // Create directory for destination if err := os.MkdirAll(filepath.Dir(dst), 0755); err != nil { return err } // Read source data, err := os.ReadFile(src) if err != nil { return err } // Write destination return os.WriteFile(dst, data, 0644) }