Files
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00

46 lines
1.1 KiB
Go
Executable File

package compose
import (
"fmt"
"strings"
)
// ComposeAuthForm stamps page.auth_form for progressive-enhancement login/register.
// action is the form POST path (e.g. /login, /desk/login, /register).
func ComposeAuthForm(page any, action, submit, formID, errID, target, nextDefault, kind string) (any, error) {
action = strings.TrimSpace(action)
if action == "" {
return nil, fmt.Errorf("compose_auth_form requires non-empty action")
}
obj := asObject(page)
kind = strings.TrimSpace(strings.ToLower(kind))
if kind == "" {
if strings.Contains(strings.ToLower(action), "register") {
kind = "register"
} else {
kind = "login"
}
}
spec := map[string]any{
"action": action,
"kind": kind,
}
if s := strings.TrimSpace(submit); s != "" {
spec["submit"] = s
}
if s := strings.TrimSpace(formID); s != "" {
spec["form_id"] = s
}
if s := strings.TrimSpace(errID); s != "" {
spec["err_id"] = s
}
if s := strings.TrimSpace(target); s != "" {
spec["target"] = s
}
if s := strings.TrimSpace(nextDefault); s != "" {
spec["next"] = s
}
obj["auth_form"] = spec
return obj, nil
}