feat(web): table-bound intro and demo-grade web-site sample
Add compose_intro (属性/值/样式) so page heroes are not HTML strings, and polish examples/web-site for WWW Demo: literary shell, card→detail routes, richer seeds, particle atmosphere without author JS. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3eb8e732ea
commit
037592087c
23 files changed
+2279
-94
No files matched your search
@@ -60,6 +60,8 @@ extern int web_page_chrome(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_style(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_compose_components(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_compose_main(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_compose_intro(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_intro(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_render(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_db_new(char *args_json, char **out_json, char **err_msg);
|
||||
extern int web_db_init(char *args_json, char **out_json, char **err_msg);
|
||||
@@ -153,6 +155,8 @@ static int register_core(void) {
|
||||
if (host_register((char *)"web_style", (char *)"name,table,strict", web_style) != 0) return 1;
|
||||
if (host_register((char *)"web_compose_components", (char *)"page,components", web_compose_components) != 0) return 1;
|
||||
if (host_register((char *)"web_compose_main", (char *)"page,main", web_compose_main) != 0) return 1;
|
||||
if (host_register((char *)"web_compose_intro", (char *)"page,intro", web_compose_intro) != 0) return 1;
|
||||
if (host_register((char *)"web_intro", (char *)"table", web_intro) != 0) return 1;
|
||||
if (host_register((char *)"web_compose_form", (char *)"page,form,id,target", web_compose_form) != 0) return 1;
|
||||
if (host_register((char *)"web_render", (char *)"page", web_render) != 0) return 1;
|
||||
if (host_register((char *)"web_db_new", (char *)"url", web_db_new) != 0) return 1;
|
||||
@@ -509,6 +513,46 @@ func web_compose_main(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int
|
||||
return replyJSON(outJSON, errMsg, out, err)
|
||||
}
|
||||
|
||||
//export web_compose_intro
|
||||
func web_compose_intro(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
pageBag := asPageMap(args["page"])
|
||||
intro := args["intro"]
|
||||
if intro == nil {
|
||||
intro = args["引言"]
|
||||
}
|
||||
if intro == nil {
|
||||
intro = args["table"]
|
||||
}
|
||||
if intro == nil {
|
||||
return replyJSON(outJSON, errMsg, nil, fmt.Errorf("missing `intro`"))
|
||||
}
|
||||
out, err := compose.ComposeIntro(pageBag, intro, callLib)
|
||||
return replyJSON(outJSON, errMsg, out, err)
|
||||
}
|
||||
|
||||
//export web_intro
|
||||
func web_intro(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
if err != nil {
|
||||
return replyJSON(outJSON, errMsg, nil, err)
|
||||
}
|
||||
tbl := args["table"]
|
||||
if tbl == nil {
|
||||
tbl = args["intro"]
|
||||
}
|
||||
if tbl == nil {
|
||||
tbl = args["表"]
|
||||
}
|
||||
if tbl == nil {
|
||||
return replyJSON(outJSON, errMsg, nil, fmt.Errorf("missing `table`"))
|
||||
}
|
||||
return replyJSON(outJSON, errMsg, compose.MakeIntroHTML(tbl), nil)
|
||||
}
|
||||
|
||||
//export web_render
|
||||
func web_render(argsJSON *C.char, outJSON **C.char, errMsg **C.char) C.int {
|
||||
args, err := parseArgs(argsJSON)
|
||||
|
||||
Reference in new issue
Block a user