Files
website/app/cmd/server/main.go
Jimmy 3f5235daaf Improve gallery video UX and add upload-to-publish media workflow.
Stage raw files in upload/, publish with make sync-media/publish, and polish the lightbox: autoplay, remembered volume, Escape to close, and image/video icons without poster or caption clutter.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-04 23:55:43 +12:00

70 lines
1.5 KiB
Go

package main
import (
"flag"
"log"
"net/http"
"os"
"path/filepath"
"technical.kiwi/website/internal/gallery"
"technical.kiwi/website/internal/handlers"
"technical.kiwi/website/internal/mail"
"technical.kiwi/website/internal/middleware"
)
func main() {
thumbsOnly := flag.Bool("thumbs", false, "generate gallery thumbnails and exit")
flag.Parse()
root, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
imagesDir := envOr("IMAGES_DIR", filepath.Join(root, "images"))
staticDir := filepath.Join(root, "static")
if *thumbsOnly {
if err := gallery.EnsureThumbnails(imagesDir); err != nil {
log.Fatal(err)
}
log.Print("thumbnails generated")
return
}
var mailCfg *mail.Config
if mail.Enabled() {
cfg, err := mail.Load()
if err != nil {
log.Fatalf("smtp config: %v", err)
}
mailCfg = &cfg
log.Printf("contact form: smtp relay %s:%d → %s", cfg.Host, cfg.Port, cfg.To)
} else {
log.Print("contact form: disabled (set SMTP_HOST, SMTP_FROM, SMTP_TO to enable)")
}
srv, err := handlers.New(imagesDir, staticDir, mailCfg)
if err != nil {
log.Fatal(err)
}
mux := http.NewServeMux()
srv.RegisterRoutes(mux)
addr := envOr("ADDR", ":8080")
log.Printf("gallery images: %s", imagesDir)
log.Printf("Technical Kiwi website listening on %s", addr)
if err := http.ListenAndServe(addr, middleware.Gzip(mux)); err != nil {
log.Fatal(err)
}
}
func envOr(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}