🏗️ **Major Architecture Refactoring: Separate CLI + Server → Unified Binary** **Key Changes:** ✅ **Unified Binary**: Single 'insertr' binary with subcommands (enhance, serve) ✅ **Preserved Database Architecture**: Maintained sophisticated sqlc multi-DB setup ✅ **Smart Configuration**: Viper + YAML config with CLI flag precedence ✅ **Updated Build System**: Unified justfile, Air, and npm scripts **Command Structure:** - `insertr enhance [input-dir]` - Build-time content injection - `insertr serve` - HTTP API server (dev + production modes) - `insertr --config insertr.yaml` - YAML configuration support **Architecture Benefits:** - **Shared Database Layer**: Single source of truth for content models - **Flexible Workflows**: Local DB for dev, remote API for production - **Simple Deployment**: One binary for all use cases - **Better UX**: Consistent configuration across build and runtime **Preserved Features:** - Multi-database support (SQLite + PostgreSQL) - sqlc code generation and type safety - Version control system with rollback - Professional API endpoints - Content enhancement pipeline **Development Workflow:** - `just dev` - Full-stack development (API server + demo site) - `just serve` - API server only - `just enhance` - Build-time content injection - `air` - Hot reload unified binary **Migration:** Consolidated insertr-cli/ and insertr-server/ → unified root structure
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package parser
|
|
|
|
import "golang.org/x/net/html"
|
|
|
|
// ContentType represents the type of editable content
|
|
type ContentType string
|
|
|
|
const (
|
|
ContentText ContentType = "text"
|
|
ContentMarkdown ContentType = "markdown"
|
|
ContentLink ContentType = "link"
|
|
)
|
|
|
|
// Element represents a parsed editable element
|
|
type Element struct {
|
|
FilePath string `json:"file_path"`
|
|
Node *html.Node `json:"-"` // Don't serialize HTML node
|
|
ContentID string `json:"content_id"`
|
|
Type ContentType `json:"type"`
|
|
Tag string `json:"tag"`
|
|
Classes []string `json:"classes"`
|
|
Content string `json:"content"`
|
|
HasID bool `json:"has_id"` // Whether element had existing ID
|
|
Generated bool `json:"generated"` // Whether ID was generated
|
|
}
|
|
|
|
// ParseResult contains the results of parsing HTML files
|
|
type ParseResult struct {
|
|
Elements []Element `json:"elements"`
|
|
Warnings []string `json:"warnings"`
|
|
Stats ParseStats `json:"stats"`
|
|
}
|
|
|
|
// ParseStats provides statistics about the parsing operation
|
|
type ParseStats struct {
|
|
FilesProcessed int `json:"files_processed"`
|
|
TotalElements int `json:"total_elements"`
|
|
ExistingIDs int `json:"existing_ids"`
|
|
GeneratedIDs int `json:"generated_ids"`
|
|
TypeBreakdown map[ContentType]int `json:"type_breakdown"`
|
|
}
|