feat: exclude PSD files from version control

This commit is contained in:
juanatsap
2025-11-11 13:53:14 +00:00
parent 97aa8971c1
commit 1f5aeb1c4c
13 changed files with 1200 additions and 25 deletions
+58 -2
View File
@@ -4,7 +4,11 @@ import (
"encoding/json"
"fmt"
"html/template"
"log"
"os"
"time"
"github.com/juanatsap/cv-site/internal/cache"
)
// CV represents the complete curriculum vitae structure
@@ -189,14 +193,41 @@ type TechStack struct {
CSS3 string `json:"css3"`
}
// Global cache instance (initialized in main.go)
var cvCache *cache.CVCache
// InitCache initializes the global cache with specified TTL
func InitCache(ttl time.Duration) {
cvCache = cache.New(ttl)
log.Printf("✓ Cache initialized (TTL: %v)", ttl)
}
// GetCache returns the cache instance (for stats/management)
func GetCache() *cache.CVCache {
return cvCache
}
// LoadCV loads CV data from a JSON file for the specified language
// Uses cache if available, falls back to disk on cache miss
func LoadCV(lang string) (*CV, error) {
// Validate language
if lang != "en" && lang != "es" {
return nil, fmt.Errorf("unsupported language: %s", lang)
}
// Determine which JSON file to load
// Try cache first if available
if cvCache != nil {
cacheKey := cache.BuildKey("cv", lang)
if cached, found := cvCache.Get(cacheKey); found {
if cv, ok := cached.(*CV); ok {
return cv, nil
}
// Invalid cache entry, invalidate it
cvCache.Invalidate(cacheKey)
}
}
// Cache miss or no cache - load from disk
filename := fmt.Sprintf("data/cv-%s.json", lang)
// Read the JSON file
@@ -211,17 +242,36 @@ func LoadCV(lang string) (*CV, error) {
return nil, fmt.Errorf("error parsing JSON: %w", err)
}
// Store in cache if available
if cvCache != nil {
cacheKey := cache.BuildKey("cv", lang)
cvCache.Set(cacheKey, &cv)
}
return &cv, nil
}
// LoadUI loads UI translations from a JSON file for the specified language
// Uses cache if available, falls back to disk on cache miss
func LoadUI(lang string) (*UI, error) {
// Validate language
if lang != "en" && lang != "es" {
return nil, fmt.Errorf("unsupported language: %s", lang)
}
// Determine which JSON file to load
// Try cache first if available
if cvCache != nil {
cacheKey := cache.BuildKey("ui", lang)
if cached, found := cvCache.Get(cacheKey); found {
if ui, ok := cached.(*UI); ok {
return ui, nil
}
// Invalid cache entry, invalidate it
cvCache.Invalidate(cacheKey)
}
}
// Cache miss or no cache - load from disk
filename := fmt.Sprintf("data/ui-%s.json", lang)
// Read the JSON file
@@ -236,5 +286,11 @@ func LoadUI(lang string) (*UI, error) {
return nil, fmt.Errorf("error parsing JSON: %w", err)
}
// Store in cache if available
if cvCache != nil {
cacheKey := cache.BuildKey("ui", lang)
cvCache.Set(cacheKey, &ui)
}
return &ui, nil
}