feat: Implement syntactic sugar and site-specific discovery config
- Add syntactic sugar for container transformation: .insertr containers → children get .insertr - Fix discovery auto-running when disabled with site-specific config loading - Add comprehensive styling test examples for HTML attribute preservation - Include test input for syntactic sugar validation - Update discovery defaults to respect developer intent (disabled by default)
This commit is contained in:
@@ -92,8 +92,49 @@ func runEnhance(cmd *cobra.Command, args []string) {
|
||||
client = content.NewMockClient()
|
||||
}
|
||||
|
||||
// Create enhancer
|
||||
enhancer := content.NewDefaultEnhancer(client, siteID)
|
||||
// Load site-specific configuration
|
||||
enhancementConfig := content.EnhancementConfig{
|
||||
Discovery: content.DiscoveryConfig{
|
||||
Enabled: false, // Default: disabled for explicit class="insertr" markings only
|
||||
Aggressive: false,
|
||||
Containers: true,
|
||||
Individual: true,
|
||||
},
|
||||
ContentInjection: true,
|
||||
GenerateIDs: true,
|
||||
}
|
||||
|
||||
// Override with site-specific discovery config if available
|
||||
if siteConfigs := viper.Get("server.sites"); siteConfigs != nil {
|
||||
if configs, ok := siteConfigs.([]interface{}); ok {
|
||||
for _, configInterface := range configs {
|
||||
if configMap, ok := configInterface.(map[string]interface{}); ok {
|
||||
if configSiteID, ok := configMap["site_id"].(string); ok && configSiteID == siteID {
|
||||
// Found matching site config, load discovery settings
|
||||
if discoveryMap, ok := configMap["discovery"].(map[string]interface{}); ok {
|
||||
if enabled, ok := discoveryMap["enabled"].(bool); ok {
|
||||
enhancementConfig.Discovery.Enabled = enabled
|
||||
fmt.Printf("🔧 Site '%s': discovery.enabled=%v\n", siteID, enabled)
|
||||
}
|
||||
if aggressive, ok := discoveryMap["aggressive"].(bool); ok {
|
||||
enhancementConfig.Discovery.Aggressive = aggressive
|
||||
}
|
||||
if containers, ok := discoveryMap["containers"].(bool); ok {
|
||||
enhancementConfig.Discovery.Containers = containers
|
||||
}
|
||||
if individual, ok := discoveryMap["individual"].(bool); ok {
|
||||
enhancementConfig.Discovery.Individual = individual
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create enhancer with loaded configuration
|
||||
enhancer := content.NewEnhancer(client, siteID, enhancementConfig)
|
||||
|
||||
fmt.Printf("🚀 Starting enhancement process...\n")
|
||||
fmt.Printf("📁 Input: %s\n", inputDir)
|
||||
|
||||
20
cmd/serve.go
20
cmd/serve.go
@@ -138,6 +138,26 @@ func runServe(cmd *cobra.Command, args []string) {
|
||||
if autoEnhance, ok := configMap["auto_enhance"].(bool); ok {
|
||||
site.AutoEnhance = autoEnhance
|
||||
}
|
||||
// Parse discovery config if present
|
||||
if discoveryMap, ok := configMap["discovery"].(map[string]interface{}); ok {
|
||||
discovery := &content.DiscoveryConfig{
|
||||
Containers: true, // defaults
|
||||
Individual: true,
|
||||
}
|
||||
if enabled, ok := discoveryMap["enabled"].(bool); ok {
|
||||
discovery.Enabled = enabled
|
||||
}
|
||||
if aggressive, ok := discoveryMap["aggressive"].(bool); ok {
|
||||
discovery.Aggressive = aggressive
|
||||
}
|
||||
if containers, ok := discoveryMap["containers"].(bool); ok {
|
||||
discovery.Containers = containers
|
||||
}
|
||||
if individual, ok := discoveryMap["individual"].(bool); ok {
|
||||
discovery.Individual = individual
|
||||
}
|
||||
site.Discovery = discovery
|
||||
}
|
||||
if site.SiteID != "" && site.Path != "" {
|
||||
sites = append(sites, site)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user