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:
1 parent
288e6e94ac
commit
c1175d389f
699 files changed
+110197
-4117
No files matched your search
@@ -0,0 +1,85 @@
|
||||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type bookmarkSection struct {
|
||||
Label string
|
||||
Source string
|
||||
Links []NavItem
|
||||
}
|
||||
|
||||
func (s *Server) bookmarkSections(r *http.Request) []bookmarkSection {
|
||||
sections := []bookmarkSection{}
|
||||
for i, item := range s.homeBookmarks(s.domainUUIDForRequest(r)) {
|
||||
if item.Kind == "section" {
|
||||
section := bookmarkSection{Label: item.Label}
|
||||
if item.Children {
|
||||
section.Source = "/v/bookmarks?section=" + strconv.Itoa(i)
|
||||
}
|
||||
sections = append(sections, section)
|
||||
continue
|
||||
}
|
||||
if !validHomeBookmarkURL(item.Href) {
|
||||
continue
|
||||
}
|
||||
u, _ := url.Parse(item.Href)
|
||||
if u.Host == "" && !s.requestCanReadPath(r, u.Path) {
|
||||
continue
|
||||
}
|
||||
if len(sections) == 0 {
|
||||
sections = append(sections, bookmarkSection{Label: translate(s.getLocale(s.domainUUIDForRequest(r)), "home.bookmarks")})
|
||||
}
|
||||
section := §ions[len(sections)-1]
|
||||
if section.Source == "" {
|
||||
section.Links = append(section.Links, item)
|
||||
}
|
||||
}
|
||||
return sections
|
||||
}
|
||||
|
||||
// A small, keyset-paged listing: no revision bodies, stats, or preview work.
|
||||
// The section index is resolved against domain config, not a caller's URL.
|
||||
func (s *Server) handleBookmarkChildren(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
http.Error(w, "method not allowed", 405)
|
||||
return
|
||||
}
|
||||
items := s.homeBookmarks(s.domainUUIDForRequest(r))
|
||||
i, err := strconv.Atoi(r.URL.Query().Get("section"))
|
||||
if err != nil || i < 0 || i >= len(items) || items[i].Kind != "section" || !items[i].Children {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
u, err := url.Parse(items[i].Href)
|
||||
if err != nil || u.Host != "" || u.Scheme != "" || !strings.HasPrefix(u.Path, "/") || !s.requestCanReadPath(r, u.Path) {
|
||||
http.Error(w, "forbidden", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
names, more, err := s.store.ListBookmarkChildren(r.Context(), s.domainUUIDForRequest(r), u.Path, r.URL.Query().Get("after"))
|
||||
if err != nil {
|
||||
http.Error(w, "could not load bookmarks", 500)
|
||||
return
|
||||
}
|
||||
links := []NavItem{}
|
||||
prefix := strings.TrimRight(u.Path, "/") + "/"
|
||||
for _, name := range names {
|
||||
p := prefix + name
|
||||
if prefix == "/" && (name == "u" || name == "_" || name == "-") {
|
||||
continue
|
||||
}
|
||||
if s.requestCanReadPath(r, p) {
|
||||
links = append(links, NavItem{Label: name, Href: (&url.URL{Path: p}).String()})
|
||||
}
|
||||
}
|
||||
next := ""
|
||||
if more && len(names) > 0 {
|
||||
next = names[len(names)-1]
|
||||
}
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
writeEventJSON(w, 200, map[string]any{"links": links, "next": next})
|
||||
}
|
||||
Reference in new issue
Block a user