Implement Knowledge City platform, organizer and DAV integration

Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
This commit is contained in:
Anya Tokugawa committed 2026-09-27 14:44:43 +09:00
1 parent 288e6e94ac
commit c1175d389f
699 files changed
+110197 -4117

No files matched your search

+24 -163
View File
@@ -1,7 +1,6 @@
package server
import (
"database/sql"
"encoding/json"
"net/http"
)
@@ -16,175 +15,37 @@ type renamePreview struct {
Count int `json:"count"`
}
func (s *Server) handleRenamePath(
w http.ResponseWriter,
r *http.Request,
) {
func (s *Server) handleRenamePath(w http.ResponseWriter, r *http.Request) {
if !requirePathMutationPost(w, r) {
return
}
var req renamePathRequest
err := json.NewDecoder(
r.Body,
).Decode(&req)
r.Body = http.MaxBytesReader(w, r.Body, 1<<20)
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
req.OldPath = normalizeAuthorizationPath(req.OldPath)
req.NewPath = normalizeAuthorizationPath(req.NewPath)
if req.OldPath == "" || req.NewPath == "" || req.OldPath == "/" || req.NewPath == "/" {
http.Error(w, "invalid path", http.StatusBadRequest)
return
}
snapshot, err := s.authorizedMutationSnapshot(r, "rename", "create", req.OldPath, req.NewPath, req.Recursive)
if err != nil {
http.Error(
w,
err.Error(),
400,
)
writePathMutationError(w, err)
return
}
if req.OldPath == "" ||
req.NewPath == "" {
http.Error(
w,
"invalid path",
400,
)
if r.URL.Query().Get("preview") == "1" {
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(renamePreview{Count: len(snapshot.Paths())})
return
}
if req.Recursive {
var count int
err :=
s.store.DB.QueryRow(`
SELECT COUNT(*)
FROM paths
WHERE path = ?
OR path LIKE ?
`,
req.OldPath,
req.OldPath+"/%",
).Scan(&count)
if err != nil {
http.Error(
w,
err.Error(),
500,
)
return
}
if r.URL.Query().Get("preview") == "1" {
w.Header().Set(
"Content-Type",
"application/json",
)
json.NewEncoder(w).Encode(
renamePreview{
Count: count,
},
)
return
}
tx, err :=
s.store.DB.BeginTx(
r.Context(),
&sql.TxOptions{},
)
if err != nil {
http.Error(
w,
err.Error(),
500,
)
return
}
_, err = tx.Exec(`
UPDATE paths
SET path =
CASE
WHEN path = ?
THEN ?
ELSE REPLACE(
path,
? || '/',
? || '/'
)
END
WHERE path = ?
OR path LIKE ?
`,
req.OldPath,
req.NewPath,
req.OldPath,
req.NewPath,
req.OldPath,
req.OldPath+"/%",
)
if err != nil {
tx.Rollback()
http.Error(
w,
err.Error(),
500,
)
return
}
err = tx.Commit()
if err != nil {
http.Error(
w,
err.Error(),
500,
)
return
}
w.WriteHeader(200)
return
}
_, err =
s.store.DB.Exec(`
UPDATE paths
SET path = ?
WHERE path = ?
`,
req.NewPath,
req.OldPath,
)
count, err := s.store.RenamePathsInDomainChecked(s.domainUUIDForRequest(r), req.OldPath, req.NewPath, req.Recursive, snapshot)
if err != nil {
http.Error(
w,
err.Error(),
500,
)
writePathMutationError(w, err)
return
}
w.WriteHeader(200)
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(renamePreview{Count: count})
}