Extract Grammaratur, Dregarnuhr, Geduldh, Mestionora, Ordoschnellic, Schutzaria, Kunstzeal and Seheweit behind compatible application contracts. Include accumulated editor resilience, navigation and theme UX, remote CLI, storage/schema and DR groundwork, tests and design/operations documentation. Verified: uncached full Go suite; go vet ./...; race tests for all eight components; 11 targeted Chromium tests; Node suites; 19 Python CLI tests; reproducible editor build. No push, release tag or deployment in this checkpoint.
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package server
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
|
|
"pageswiki/internal/store"
|
|
)
|
|
|
|
// Names identify Streets only within their parent Quartier. UUID references
|
|
// remain available for stable identity across renames and moves.
|
|
func cityDetailHref(kind, name, quartierName, uuid string) string {
|
|
prefix := map[string]string{"quartier": "q", "street": "s", "spot": "p"}[strings.ToLower(kind)]
|
|
if prefix == "" {
|
|
return "/v/city"
|
|
}
|
|
ref := "uuid:" + uuid
|
|
if name != "" && (prefix != "s" || quartierName != "") {
|
|
ref = url.PathEscape(name)
|
|
if prefix == "s" {
|
|
ref = url.PathEscape(quartierName) + "/" + ref
|
|
}
|
|
} else {
|
|
ref = url.PathEscape(ref)
|
|
}
|
|
return "/v/city/" + prefix + "/" + ref
|
|
}
|
|
|
|
func canReadCityNode(node store.CityNodeDetail, allowed func(string) bool) bool {
|
|
return allowed(node.PathPrefix) && (node.Quartier == nil || allowed(node.Quartier.PathPrefix)) && (node.Street == nil || allowed(node.Street.PathPrefix))
|
|
}
|
|
|
|
func cityPageHref(path string) string {
|
|
return (&url.URL{Path: path}).EscapedPath()
|
|
}
|
|
|
|
// Search is a reading entry point, not a locality management shortcut. Both
|
|
// title and Path links use this projection; no additional per-hit DB reads.
|
|
func cityContentHref(result store.CitySearchResult) string {
|
|
path := result.ContentPath()
|
|
if !strings.HasPrefix(path, "/") || strings.HasPrefix(path, "//") {
|
|
return "/v/browser"
|
|
}
|
|
if result.HasPage {
|
|
return cityPageHref(path)
|
|
}
|
|
return cityPageHref("/v/browser" + path)
|
|
}
|
|
|
|
type cityPageView struct {
|
|
store.CityPagePlacement
|
|
Href string
|
|
}
|