Files
pages/internal/server/handlers.go
T
2026-05-19 21:30:42 +09:00

76 lines
820 B
Go

package server
import (
"net/http"
"strings"
)
type HomeObject struct {
UUID string
Path string
Kind string
}
func (s *Server) handleHome(
w http.ResponseWriter,
r *http.Request,
) {
objects, err :=
s.store.ListObjects()
if err != nil {
http.Error(
w,
err.Error(),
500,
)
return
}
var semanticObjects []HomeObject
for _, o := range objects {
path := o.UUID
if path == "" {
continue
}
if strings.HasPrefix(
path,
"/system/",
) {
continue
}
if strings.HasPrefix(
path,
"/o/",
) {
continue
}
semanticObjects = append(
semanticObjects,
HomeObject{
UUID: o.UUID,
Path: path,
Kind: o.Kind,
},
)
}
s.render(
w,
"home.gohtml",
map[string]any{
"Title": "Pages Wiki",
"Objects": semanticObjects,
},
)
}