Remove internal/content package and use engine directly

- Eliminate content.Enhancer wrapper around engine.ContentEngine
- Update cmd/enhance.go to call engine.ProcessFile/ProcessDirectory directly
- Update sites/manager.go to use engine.NewContentEngineWithAuth directly
- Remove unused EnhancementConfig and discovery configuration logic
- Simplify enhance command to use input path as site ID
- Remove CLI config dependency from config package
This commit is contained in:
2025-10-23 22:32:42 +02:00
parent 4874849f80
commit dc801fb26b
6 changed files with 16 additions and 258 deletions

View File

@@ -3,7 +3,6 @@ package config
type Config struct {
Database DatabaseConfig `yaml:"database" mapstructure:"database"`
API APIConfig `yaml:"api" mapstructure:"api"`
CLI CLIConfig `yaml:"cli" mapstructure:"cli"`
Server ServerConfig `yaml:"server" mapstructure:"server"`
Auth AuthConfig `yaml:"auth" mapstructure:"auth"`
Library LibraryConfig `yaml:"library" mapstructure:"library"`
@@ -18,10 +17,6 @@ type APIConfig struct {
Key string `yaml:"key" mapstructure:"key"`
}
type CLIConfig struct {
SiteID string `yaml:"site_id" mapstructure:"site_id"`
}
type ServerConfig struct {
Port int `yaml:"port" mapstructure:"port"`
Host string `yaml:"host" mapstructure:"host"`
@@ -29,18 +24,10 @@ type ServerConfig struct {
}
type AuthConfig struct {
DevMode bool `yaml:"dev_mode" mapstructure:"dev_mode"`
Provider string `yaml:"provider" mapstructure:"provider"`
JWTSecret string `yaml:"jwt_secret" mapstructure:"jwt_secret"`
OAuthConfigs map[string]OAuthConfig `yaml:"oauth_configs" mapstructure:"oauth_configs"`
OIDC *OIDCConfig `yaml:"oidc" mapstructure:"oidc"`
}
type OAuthConfig struct {
ClientID string `yaml:"client_id" mapstructure:"client_id"`
ClientSecret string `yaml:"client_secret" mapstructure:"client_secret"`
RedirectURL string `yaml:"redirect_url" mapstructure:"redirect_url"`
Scopes []string `yaml:"scopes" mapstructure:"scopes"`
DevMode bool `yaml:"dev_mode" mapstructure:"dev_mode"`
Provider string `yaml:"provider" mapstructure:"provider"`
JWTSecret string `yaml:"jwt_secret" mapstructure:"jwt_secret"`
OIDC *OIDCConfig `yaml:"oidc" mapstructure:"oidc"`
}
type OIDCConfig struct {

View File

@@ -69,9 +69,6 @@ func (l *viperLoader) LoadWithFlags(dbPath, apiURL, apiKey, siteID string) (*Con
if apiKey != "" {
config.API.Key = apiKey
}
if siteID != "" {
config.CLI.SiteID = siteID
}
return config, validate(config)
}
@@ -81,10 +78,6 @@ func (l *viperLoader) setDefaults(config *Config) error {
config.Database.Path = "./insertr.db"
}
if config.CLI.SiteID == "" {
config.CLI.SiteID = "demo"
}
if config.Server.Port == 0 {
config.Server.Port = 8080
}

View File

@@ -5,6 +5,7 @@ import (
"net/url"
"os"
"path/filepath"
"slices"
"strings"
)
@@ -17,10 +18,6 @@ func validate(config *Config) error {
return fmt.Errorf("api config: %w", err)
}
if err := validateCLI(config.CLI); err != nil {
return fmt.Errorf("cli config: %w", err)
}
if err := validateServer(config.Server); err != nil {
return fmt.Errorf("server config: %w", err)
}
@@ -66,18 +63,6 @@ func validateAPI(config APIConfig) error {
return nil
}
func validateCLI(config CLIConfig) error {
if config.SiteID == "" {
return fmt.Errorf("site_id is required")
}
if strings.TrimSpace(config.SiteID) != config.SiteID {
return fmt.Errorf("site_id cannot have leading or trailing whitespace")
}
return nil
}
func validateServer(config ServerConfig) error {
if config.Port < 1 || config.Port > 65535 {
return fmt.Errorf("port must be between 1 and 65535, got %d", config.Port)
@@ -136,13 +121,7 @@ func validateAuth(config AuthConfig) error {
}
validProviders := []string{"mock", "authentik"}
valid := false
for _, provider := range validProviders {
if config.Provider == provider {
valid = true
break
}
}
valid := slices.Contains(validProviders, config.Provider)
if !valid {
return fmt.Errorf("invalid provider %q, must be one of: %s", config.Provider, strings.Join(validProviders, ", "))
}