use json files to store data/ get css to work

This commit is contained in:
2025-11-17 03:13:46 +07:00
parent c772904165
commit a4b3f8ce06
9 changed files with 131 additions and 55 deletions

View File

@@ -8,8 +8,8 @@ import (
)
type ApiHandler struct {
Templates *template.Template
ProjectStore *store.SQLiteProjectStore
Templates *template.Template
ProjectStore *store.SQLiteProjectStore
ExperienceStore *store.SQLiteExperienceStore
}
@@ -19,14 +19,14 @@ func (h *ApiHandler) Render(w http.ResponseWriter, tmpl string, data interface{}
return
}
}
func NewApiHandler(db *sql.DB) *ApiHandler {
tmpl := template.Must(template.New("").ParseGlob("views/*.html"))
template.Must(tmpl.ParseGlob("views/partials/*.html"))
return &ApiHandler{
Templates: tmpl,
ProjectStore: store.NewSQLiteProjectStore(db),
Templates: tmpl,
ProjectStore: store.NewSQLiteProjectStore(db),
ExperienceStore: store.NewSQLiteExperienceStore(db),
}
}
@@ -56,7 +56,8 @@ func (h *ApiHandler) ProjectsPage(w http.ResponseWriter, r *http.Request) {
func (h *ApiHandler) ExperiencePage(w http.ResponseWriter, r *http.Request) {
var hxRequest = r.Header.Get("HX-Request")
experiences, err := h.ExperienceStore.GetAllExperiences()
// experiences, err := h.ExperienceStore.GetAllExperiences()
experiences, err := store.GetAllExperiencesJSON()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return