add i18n for system/home nav editor, improve link manager

This commit is contained in:
Anya Tokugawa committed 2026-05-31 23:07:15 +09:00
1 parent e8e9b505af
commit 2b4e1dbc57
9 files changed
+517 -52

No files matched your search

+114 -4
View File
@@ -2,6 +2,7 @@ package server
import (
"net/http"
"strings"
)
func (s *Server) handleLinkManager(
@@ -9,14 +10,123 @@ func (s *Server) handleLinkManager(
r *http.Request,
) {
objects, _ := s.store.ListObjects()
objectUUID := ""
if strings.HasPrefix(r.URL.Path, "/l/uuid:") {
objectUUID =
strings.TrimPrefix(
r.URL.Path,
"/l/uuid:",
)
}
if objectUUID == "" {
http.NotFound(
w,
r,
)
return
}
if r.Method == http.MethodPost {
err := r.ParseForm()
if err != nil {
http.Error(w, err.Error(), 400)
return
}
action :=
r.FormValue(
"action",
)
path :=
strings.TrimSpace(
r.FormValue("path"),
)
switch action {
case "add":
if path == "" {
http.Error(w, "path is required", 400)
return
}
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
err = s.store.AddPathLink(
objectUUID,
path,
)
case "delete":
err = s.store.DeletePathLink(
objectUUID,
path,
)
case "primary":
err = s.store.SetPrimaryPathLink(
objectUUID,
path,
)
default:
http.Error(w, "unknown action", 400)
return
}
if err != nil {
http.Error(w, err.Error(), 500)
return
}
http.Redirect(
w,
r,
"/l/uuid:"+objectUUID,
http.StatusFound,
)
return
}
links, err :=
s.store.ListPathLinks(
objectUUID,
)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
s.render(
w,
"links.gohtml",
"link_manager.gohtml",
map[string]any{
"Title": "Link Manager",
"Objects": objects,
"NavItems": resolveNavItems(
s.getSystemNavItems(),
NavContext{
ObjectUUID: objectUUID,
ObjectURI: "uuid:" + objectUUID,
},
),
"ObjectUUID": objectUUID,
"ObjectURI": "uuid:" + objectUUID,
"Links": links,
},
)
}