feat(web): W-G14 anlian-mq acceptance and auth/session listen fixes

Add a GFM-first anlian rewrite under examples/anlian-mq to exercise Go
libweb (lists, detail, gates, login, WS). Wire RBAC/login into listen,
page query/order/detail ABIs, and stop issuing Max-Age=0 CSRF cookies so
browser login sessions stick.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-09-10 21:20:11 +08:00
1 parent e20cf8b386
commit ce195998c1
22 files changed
+1454 -20

No files matched your search

+82 -5
View File
@@ -1,6 +1,9 @@
package page
import "strconv"
import (
"strconv"
"strings"
)
// New builds a page bag (ABI web_page_new), matching the Rust plugin shape.
func New(args map[string]any) map[string]any {
@@ -24,10 +27,7 @@ func New(args map[string]any) map[string]any {
// Paginate stamps page.paginate with offset/limit/path (Rust web_page_paginate).
func Paginate(page map[string]any, offset, limit int64, path string) map[string]any {
out := map[string]any{}
for k, v := range page {
out[k] = v
}
out := clone(page)
if path == "" {
path = "/"
}
@@ -39,6 +39,61 @@ func Paginate(page map[string]any, offset, limit int64, path string) map[string]
return out
}
// SetQuery stamps page.query (Rust web_page_query).
func SetQuery(page map[string]any, query any) map[string]any {
out := clone(page)
if query == nil {
query = map[string]any{}
}
out["query"] = query
return out
}
// SetOrder stamps page.order (Rust web_page_order).
func SetOrder(page map[string]any, order string) map[string]any {
out := clone(page)
out["order"] = order
return out
}
// SetLinkPrefix stamps page.link_prefix (Rust web_page_link_prefix).
func SetLinkPrefix(page map[string]any, prefix string) map[string]any {
out := clone(page)
out["link_prefix"] = prefix
return out
}
// AppendCSS appends raw CSS to page.styles_css (Rust web_page_css).
func AppendCSS(page map[string]any, css string) map[string]any {
out := clone(page)
css = strings.TrimSpace(css)
if css == "" {
return out
}
prev, _ := out["styles_css"].(string)
if prev == "" {
out["styles_css"] = css
} else {
out["styles_css"] = prev + "\n" + css
}
return out
}
// SetDetail stamps page.detail bool (Rust web_page_detail).
func SetDetail(page map[string]any, on bool) map[string]any {
out := clone(page)
out["detail"] = on
return out
}
func clone(page map[string]any) map[string]any {
out := map[string]any{}
for k, v := range page {
out[k] = v
}
return out
}
func strOpt(args map[string]any, key, def string) string {
if s, ok := strAny(args, key); ok {
return s
@@ -66,3 +121,25 @@ func strAny(args map[string]any, keys ...string) (string, bool) {
}
return "", false
}
// AsBool interprets ABI detail flags (bool / 0|1 / 真|是|true).
func AsBool(v any, def bool) bool {
if v == nil {
return def
}
switch t := v.(type) {
case bool:
return t
case float64:
return t != 0
case string:
s := strings.TrimSpace(t)
switch s {
case "1", "true", "True", "yes", "on", "真", "是":
return true
case "0", "false", "False", "no", "off", "假", "否", "":
return false
}
}
return def
}