diff options
| -rw-r--r-- | html.c | 41 |
1 files changed, 41 insertions, 0 deletions
| @@ -582,6 +582,11 @@ xs_str *html_top_controls(snac *snac, xs_str *s) | |||
| 582 | "<label for=\"bot\">%s</label></p>\n" | 582 | "<label for=\"bot\">%s</label></p>\n" |
| 583 | 583 | ||
| 584 | "<p>%s:<br>\n" | 584 | "<p>%s:<br>\n" |
| 585 | "<textarea name=\"metadata\" cols=\"40\" rows=\"4\" " | ||
| 586 | "placeholder=\"Blog=https:/" "/example.com/my-blog\nGPG Key=1FA54\n...\">" | ||
| 587 | "%s</textarea></p>\n" | ||
| 588 | |||
| 589 | "<p>%s:<br>\n" | ||
| 585 | "<input type=\"password\" name=\"passwd1\" value=\"\"></p>\n" | 590 | "<input type=\"password\" name=\"passwd1\" value=\"\"></p>\n" |
| 586 | 591 | ||
| 587 | "<p>%s:<br>\n" | 592 | "<p>%s:<br>\n" |
| @@ -636,6 +641,19 @@ xs_str *html_top_controls(snac *snac, xs_str *s) | |||
| 636 | xs *es5 = encode_html(telegram_chat_id); | 641 | xs *es5 = encode_html(telegram_chat_id); |
| 637 | xs *es6 = encode_html(purge_days); | 642 | xs *es6 = encode_html(purge_days); |
| 638 | 643 | ||
| 644 | xs *metadata = xs_str_new(NULL); | ||
| 645 | xs_dict *md = xs_dict_get(snac->config, "metadata"); | ||
| 646 | xs_str *k; | ||
| 647 | xs_str *v; | ||
| 648 | |||
| 649 | while (xs_dict_iter(&md, &k, &v)) { | ||
| 650 | xs *kp = xs_fmt("%s=%s", k, v); | ||
| 651 | |||
| 652 | if (*metadata) | ||
| 653 | metadata = xs_str_cat(metadata, "\n"); | ||
| 654 | metadata = xs_str_cat(metadata, kp); | ||
| 655 | } | ||
| 656 | |||
| 639 | xs *s1 = xs_fmt(_tmpl, | 657 | xs *s1 = xs_fmt(_tmpl, |
| 640 | L("New Post..."), | 658 | L("New Post..."), |
| 641 | snac->actor, | 659 | snac->actor, |
| @@ -686,6 +704,10 @@ xs_str *html_top_controls(snac *snac, xs_str *s) | |||
| 686 | L("Drop direct messages from people you don't follow"), | 704 | L("Drop direct messages from people you don't follow"), |
| 687 | xs_type(bot) == XSTYPE_TRUE ? "checked" : "", | 705 | xs_type(bot) == XSTYPE_TRUE ? "checked" : "", |
| 688 | L("This account is a bot"), | 706 | L("This account is a bot"), |
| 707 | |||
| 708 | L("Profile metadata (key=value pairs in each line)"), | ||
| 709 | metadata, | ||
| 710 | |||
| 689 | L("New password"), | 711 | L("New password"), |
| 690 | L("Repeat new password"), | 712 | L("Repeat new password"), |
| 691 | L("Update user info") | 713 | L("Update user info") |
| @@ -2467,6 +2489,25 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 2467 | snac.config = xs_dict_set(snac.config, "bot", xs_stock_true); | 2489 | snac.config = xs_dict_set(snac.config, "bot", xs_stock_true); |
| 2468 | else | 2490 | else |
| 2469 | snac.config = xs_dict_set(snac.config, "bot", xs_stock_false); | 2491 | snac.config = xs_dict_set(snac.config, "bot", xs_stock_false); |
| 2492 | if ((v = xs_dict_get(p_vars, "metadata")) != NULL) { | ||
| 2493 | /* split the metadata and store it as a dict */ | ||
| 2494 | xs_dict *md = xs_dict_new(); | ||
| 2495 | xs *l = xs_split(v, "\n"); | ||
| 2496 | xs_list *p = l; | ||
| 2497 | xs_str *kp; | ||
| 2498 | |||
| 2499 | while (xs_list_iter(&p, &kp)) { | ||
| 2500 | xs *kpl = xs_split_n(kp, "=", 1); | ||
| 2501 | if (xs_list_len(kpl) == 2) { | ||
| 2502 | xs *k2 = xs_strip_i(xs_dup(xs_list_get(kpl, 0))); | ||
| 2503 | xs *v2 = xs_strip_i(xs_dup(xs_list_get(kpl, 1))); | ||
| 2504 | |||
| 2505 | md = xs_dict_set(md, k2, v2); | ||
| 2506 | } | ||
| 2507 | } | ||
| 2508 | |||
| 2509 | snac.config = xs_dict_set(snac.config, "metadata", md); | ||
| 2510 | } | ||
| 2470 | 2511 | ||
| 2471 | /* uploads */ | 2512 | /* uploads */ |
| 2472 | const char *uploads[] = { "avatar", "header", NULL }; | 2513 | const char *uploads[] = { "avatar", "header", NULL }; |