feat: implement server-hosted static site enhancement with real-time content updates

- Add SiteManager for registering and managing static sites with file-based enhancement
- Implement EnhanceInPlace method for in-place file modification using database content
- Integrate automatic file enhancement triggers in UpdateContent API handler
- Add comprehensive site configuration support in insertr.yaml with auto-enhancement
- Extend serve command to automatically register and manage configured sites
- Add backup system for original files before enhancement
- Support multi-site hosting with individual auto-enhancement settings
- Update documentation for server-hosted enhancement workflow

This enables real-time content deployment where database content changes
immediately update static files without requiring rebuilds or redeployment.
The database remains the single source of truth while maintaining static
file performance benefits.
This commit is contained in:
2025-09-10 23:05:09 +02:00
parent 21ce92bf61
commit 8d92c6477b
9 changed files with 576 additions and 9 deletions

View File

@@ -395,6 +395,57 @@ mock_content: false # Use mock content instead of real data
- Works with any framework or generator
- Developer experience focused
## 🏗️ **Server-Hosted Static Sites** (NEW)
**Real-time content updates for server-hosted static sites with immediate deployment.**
### **Overview**
Insertr now supports hosting and enhancing static sites directly on the server. When content changes through the editor, static files are automatically updated in-place without requiring rebuilds or redeployment.
### **Key Benefits**
-**Immediate Updates**: Content changes are live instantly
-**Database Source of Truth**: Content stored in database, not files
-**No Rebuilds Required**: Only content updates, templates stay the same
-**Multi-Site Support**: Host multiple enhanced sites on one server
-**Automatic Backups**: Original files backed up before enhancement
### **Workflow**
```
1. Developer deploys static site → Server directory (e.g., /var/www/mysite)
2. Insertr enhances files → Adds editing capabilities + injects content
3. Editor makes changes → API updates database + triggers file enhancement
4. Changes immediately live → Visitors see updated content instantly
```
### **Configuration Example**
```yaml
# insertr.yaml
server:
port: 8080
sites:
- site_id: "mysite"
path: "/var/www/mysite"
domain: "mysite.example.com"
auto_enhance: true
backup_originals: true
- site_id: "blog"
path: "/var/www/blog"
domain: "blog.example.com"
auto_enhance: true
backup_originals: true
```
### **Quick Start**
```bash
# 1. Configure sites in insertr.yaml
# 2. Start the server
./insertr serve --dev-mode
# 3. Your sites are automatically registered and enhanced
# 4. Content changes via editor immediately update static files
```
## ⚙️ Configuration
### **YAML Configuration (insertr.yaml)**
@@ -403,21 +454,34 @@ mock_content: false # Use mock content instead of real data
database:
path: "./insertr.db" # SQLite file path or PostgreSQL connection string
# Server configuration (with site hosting)
server:
port: 8080 # HTTP server port
sites: # Server-hosted static sites
- site_id: "demo"
path: "./demo-site"
domain: "localhost:3000"
auto_enhance: true
backup_originals: true
# API configuration (for remote content API)
api:
url: "" # Content API URL (leave empty to use local database)
key: "" # API authentication key
# Server configuration
server:
port: 8080 # HTTP server port
dev_mode: false # Enable development mode features
# Build configuration
# Build configuration (for CLI enhancement)
build:
input: "./src" # Default input directory for enhancement
output: "./dist" # Default output directory for enhanced files
# Authentication configuration
auth:
provider: "mock" # "mock", "jwt", "authentik"
jwt_secret: "" # JWT signing secret
oidc:
endpoint: "" # https://auth.example.com/application/o/insertr/
client_id: "" # OAuth2 client ID
# Global settings
site_id: "demo" # Default site ID for content lookup
mock_content: false # Use mock content instead of real data