diff options
| author | 2023-07-23 23:11:02 +0700 | |
|---|---|---|
| committer | 2023-07-24 19:42:20 +0700 | |
| commit | 75e061a9f78939e3235125ec180186080bd57b58 (patch) | |
| tree | 5a72f426b0f632cca6682fb4b08deb0baddde022 /html.c | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | snac2-75e061a9f78939e3235125ec180186080bd57b58.tar.gz snac2-75e061a9f78939e3235125ec180186080bd57b58.tar.xz snac2-75e061a9f78939e3235125ec180186080bd57b58.zip | |
html.c & httpd.c: Fix hardlink.
Some people may still want to post in the web client with such different
way, Such as posting from Yggdrasil / SSH port forwarder, and so on.
This commit gives the workaround for that purpose, However things will
go messed up when current path were ends with / (Like: user/, admin/).
But overall, If user just uses it like normal, Then things will just
worked well as expected.
Signed-off-by: Yonle <yonle@lecturify.net>
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 68 |
1 files changed, 31 insertions, 37 deletions
| @@ -325,8 +325,8 @@ d_char *html_user_header(snac *snac, d_char *s, int local) | |||
| 325 | s1 = xs_fmt( | 325 | s1 = xs_fmt( |
| 326 | "<a href=\"%s.rss\">%s</a> - " | 326 | "<a href=\"%s.rss\">%s</a> - " |
| 327 | "<a href=\"%s/admin\" rel=\"nofollow\">%s</a></nav>\n", | 327 | "<a href=\"%s/admin\" rel=\"nofollow\">%s</a></nav>\n", |
| 328 | snac->actor, L("RSS"), | 328 | snac->uid, L("RSS"), |
| 329 | snac->actor, L("private")); | 329 | snac->uid, L("private")); |
| 330 | else { | 330 | else { |
| 331 | xs *n_list = notify_list(snac, 1); | 331 | xs *n_list = notify_list(snac, 1); |
| 332 | int n_len = xs_list_len(n_list); | 332 | int n_len = xs_list_len(n_list); |
| @@ -340,18 +340,17 @@ d_char *html_user_header(snac *snac, d_char *s, int local) | |||
| 340 | n_str = xs_str_new(""); | 340 | n_str = xs_str_new(""); |
| 341 | 341 | ||
| 342 | s1 = xs_fmt( | 342 | s1 = xs_fmt( |
| 343 | "<a href=\"%s\">%s</a> - " | 343 | "<a href=\"../%s\">%s</a> - " |
| 344 | "<a href=\"%s/admin\">%s</a> - " | 344 | "<a href=\"admin\">%s</a> - " |
| 345 | "<a href=\"%s/notifications\">%s</a>%s - " | 345 | "<a href=\"notifications\">%s</a>%s - " |
| 346 | "<a href=\"%s/people\">%s</a> - " | 346 | "<a href=\"people\">%s</a></nav>\n" |
| 347 | "<a href=\"%s/settings\">%s</a>" | 347 | "<a href=\"settings\">%s</a>" |
| 348 | "</nav>\n", | 348 | "</nav>" |
| 349 | snac->actor, L("public"), | 349 | snac->uid, L("public"), |
| 350 | snac->actor, L("private"), | 350 | L("private"), |
| 351 | snac->actor, L("notifications"), n_str, | 351 | L("notifications"), n_str, |
| 352 | snac->actor, L("people"), | 352 | L("people"), |
| 353 | snac->actor, L("settings") | 353 | L("settings")); |
| 354 | ); | ||
| 355 | } | 354 | } |
| 356 | 355 | ||
| 357 | s = xs_str_cat(s, s1); | 356 | s = xs_str_cat(s, s1); |
| @@ -398,7 +397,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) | |||
| 398 | "<div class=\"snac-note\" %s>\n" | 397 | "<div class=\"snac-note\" %s>\n" |
| 399 | "<details><summary>%s</summary>\n" | 398 | "<details><summary>%s</summary>\n" |
| 400 | "<form autocomplete=\"off\" method=\"post\" " | 399 | "<form autocomplete=\"off\" method=\"post\" " |
| 401 | "action=\"%s/admin/note\" enctype=\"multipart/form-data\">\n" | 400 | "action=\"admin/note\" enctype=\"multipart/form-data\">\n" |
| 402 | "<textarea class=\"snac-textarea\" name=\"content\" " | 401 | "<textarea class=\"snac-textarea\" name=\"content\" " |
| 403 | "rows=\"8\" wrap=\"virtual\" required=\"required\" placeholder=\"What's on your mind?\"></textarea>\n" | 402 | "rows=\"8\" wrap=\"virtual\" required=\"required\" placeholder=\"What's on your mind?\"></textarea>\n" |
| 404 | "<input type=\"hidden\" name=\"in_reply_to\" value=\"\">\n" | 403 | "<input type=\"hidden\" name=\"in_reply_to\" value=\"\">\n" |
| @@ -435,12 +434,12 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) | |||
| 435 | "<div class=\"snac-top-controls-more\" %s>\n" | 434 | "<div class=\"snac-top-controls-more\" %s>\n" |
| 436 | "<p><details><summary>%s</summary>\n" | 435 | "<p><details><summary>%s</summary>\n" |
| 437 | 436 | ||
| 438 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** follow **/ | 437 | "<form autocomplete=\"off\" method=\"post\" action=\"admin/action\">\n" /** follow **/ |
| 439 | "<input type=\"text\" name=\"actor\" required=\"required\" placeholder=\"bob@example.com\">\n" | 438 | "<input type=\"text\" name=\"actor\" required=\"required\" placeholder=\"bob@example.com\">\n" |
| 440 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" | 439 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" |
| 441 | "</form><p>\n" | 440 | "</form><p>\n" |
| 442 | 441 | ||
| 443 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** boost **/ | 442 | "<form autocomplete=\"off\" method=\"post\" action=\"admin/action\">\n" /** boost **/ |
| 444 | "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/....\">\n" | 443 | "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/....\">\n" |
| 445 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" | 444 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" |
| 446 | "</form><p>\n" | 445 | "</form><p>\n" |
| @@ -453,7 +452,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) | |||
| 453 | 452 | ||
| 454 | "<div class=\"snac-user-setup\">\n" /** user setup **/ | 453 | "<div class=\"snac-user-setup\">\n" /** user setup **/ |
| 455 | "<form autocomplete=\"off\" method=\"post\" " | 454 | "<form autocomplete=\"off\" method=\"post\" " |
| 456 | "action=\"%s/admin/user-setup\" enctype=\"multipart/form-data\">\n" | 455 | "action=\"admin/user-setup\" enctype=\"multipart/form-data\">\n" |
| 457 | "<p>%s:<br>\n" | 456 | "<p>%s:<br>\n" |
| 458 | "<input type=\"text\" name=\"name\" value=\"%s\" placeholder=\"Your name.\"></p>\n" | 457 | "<input type=\"text\" name=\"name\" value=\"%s\" placeholder=\"Your name.\"></p>\n" |
| 459 | 458 | ||
| @@ -538,7 +537,6 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) | |||
| 538 | xs *s1 = xs_fmt(_tmpl, | 537 | xs *s1 = xs_fmt(_tmpl, |
| 539 | settings ? "style=\"display: none\"" : "", | 538 | settings ? "style=\"display: none\"" : "", |
| 540 | L("New Post..."), | 539 | L("New Post..."), |
| 541 | snac->actor, | ||
| 542 | L("Sensitive content"), | 540 | L("Sensitive content"), |
| 543 | L("Sensitive content description"), | 541 | L("Sensitive content description"), |
| 544 | L("Only for mentioned people"), | 542 | L("Only for mentioned people"), |
| @@ -560,16 +558,12 @@ xs_str *html_top_controls(snac *snac, xs_str *s, int settings) | |||
| 560 | settings ? "style=\"display: none\"" : "", | 558 | settings ? "style=\"display: none\"" : "", |
| 561 | L("Operations..."), | 559 | L("Operations..."), |
| 562 | 560 | ||
| 563 | snac->actor, | ||
| 564 | L("Follow"), L("(by URL or user@host)"), | 561 | L("Follow"), L("(by URL or user@host)"), |
| 565 | |||
| 566 | snac->actor, | ||
| 567 | L("Boost"), L("(by URL)"), | 562 | L("Boost"), L("(by URL)"), |
| 568 | 563 | ||
| 569 | !settings ? "style=\"display: none\"" : "", | 564 | !settings ? "style=\"display: none\"" : "", |
| 570 | 565 | ||
| 571 | L("User Settings"), | 566 | L("User Settings"), |
| 572 | snac->actor, | ||
| 573 | L("Display name"), | 567 | L("Display name"), |
| 574 | es1, | 568 | es1, |
| 575 | L("Avatar"), | 569 | L("Avatar"), |
| @@ -673,13 +667,13 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch | |||
| 673 | 667 | ||
| 674 | { | 668 | { |
| 675 | xs *s1 = xs_fmt( | 669 | xs *s1 = xs_fmt( |
| 676 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" | 670 | "<form autocomplete=\"off\" method=\"post\" action=\"admin/action\">\n" |
| 677 | "<input type=\"hidden\" name=\"id\" value=\"%s\">\n" | 671 | "<input type=\"hidden\" name=\"id\" value=\"%s\">\n" |
| 678 | "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n" | 672 | "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n" |
| 679 | "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n" | 673 | "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n" |
| 680 | "\n", | 674 | "\n", |
| 681 | 675 | ||
| 682 | snac->actor, id, actor, md5 | 676 | id, actor, md5 |
| 683 | ); | 677 | ); |
| 684 | 678 | ||
| 685 | s = xs_str_cat(s, s1); | 679 | s = xs_str_cat(s, s1); |
| @@ -733,7 +727,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch | |||
| 733 | xs *s1 = xs_fmt( | 727 | xs *s1 = xs_fmt( |
| 734 | "<p><details><summary>%s</summary>\n" | 728 | "<p><details><summary>%s</summary>\n" |
| 735 | "<p><div class=\"snac-note\" id=\"%s_edit\">\n" | 729 | "<p><div class=\"snac-note\" id=\"%s_edit\">\n" |
| 736 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/note\" " | 730 | "<form autocomplete=\"off\" method=\"post\" action=\"admin/note\" " |
| 737 | "enctype=\"multipart/form-data\" id=\"%s_edit_form\">\n" | 731 | "enctype=\"multipart/form-data\" id=\"%s_edit_form\">\n" |
| 738 | "<textarea class=\"snac-textarea\" name=\"content\" " | 732 | "<textarea class=\"snac-textarea\" name=\"content\" " |
| 739 | "rows=\"4\" wrap=\"virtual\" required=\"required\">%s</textarea>\n" | 733 | "rows=\"4\" wrap=\"virtual\" required=\"required\">%s</textarea>\n" |
| @@ -784,7 +778,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch | |||
| 784 | xs *s1 = xs_fmt( | 778 | xs *s1 = xs_fmt( |
| 785 | "<p><details><summary>%s</summary>\n" | 779 | "<p><details><summary>%s</summary>\n" |
| 786 | "<p><div class=\"snac-note\" id=\"%s_reply\">\n" | 780 | "<p><div class=\"snac-note\" id=\"%s_reply\">\n" |
| 787 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/note\" " | 781 | "<form autocomplete=\"off\" method=\"post\" action=\"admin/note\" " |
| 788 | "enctype=\"multipart/form-data\" id=\"%s_reply_form\">\n" | 782 | "enctype=\"multipart/form-data\" id=\"%s_reply_form\">\n" |
| 789 | "<textarea class=\"snac-textarea\" name=\"content\" " | 783 | "<textarea class=\"snac-textarea\" name=\"content\" " |
| 790 | "rows=\"4\" wrap=\"virtual\" required=\"required\">%s</textarea>\n" | 784 | "rows=\"4\" wrap=\"virtual\" required=\"required\">%s</textarea>\n" |
| @@ -807,7 +801,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch | |||
| 807 | 801 | ||
| 808 | L("Reply..."), | 802 | L("Reply..."), |
| 809 | md5, | 803 | md5, |
| 810 | snac->actor, md5, | 804 | md5, |
| 811 | ct, | 805 | ct, |
| 812 | id, | 806 | id, |
| 813 | L("Sensitive content"), | 807 | L("Sensitive content"), |
| @@ -1102,10 +1096,10 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local, | |||
| 1102 | /* poll still active */ | 1096 | /* poll still active */ |
| 1103 | xs *s1 = xs_fmt("<div class=\"snac-poll-form\">\n" | 1097 | xs *s1 = xs_fmt("<div class=\"snac-poll-form\">\n" |
| 1104 | "<form autocomplete=\"off\" " | 1098 | "<form autocomplete=\"off\" " |
| 1105 | "method=\"post\" action=\"%s/admin/vote\">\n" | 1099 | "method=\"post\" action=\"admin/vote\">\n" |
| 1106 | "<input type=\"hidden\" name=\"actor\" value= \"%s\">\n" | 1100 | "<input type=\"hidden\" name=\"actor\" value= \"%s\">\n" |
| 1107 | "<input type=\"hidden\" name=\"irt\" value=\"%s\">\n", | 1101 | "<input type=\"hidden\" name=\"irt\" value=\"%s\">\n", |
| 1108 | snac->actor, actor, id); | 1102 | actor, id); |
| 1109 | 1103 | ||
| 1110 | while (xs_list_iter(&p, &v)) { | 1104 | while (xs_list_iter(&p, &v)) { |
| 1111 | const char *name = xs_dict_get(v, "name"); | 1105 | const char *name = xs_dict_get(v, "name"); |
| @@ -1495,11 +1489,11 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade | |||
| 1495 | s = xs_str_cat(s, "<div class=\"snac-controls\">\n"); | 1489 | s = xs_str_cat(s, "<div class=\"snac-controls\">\n"); |
| 1496 | 1490 | ||
| 1497 | xs *s1 = xs_fmt( | 1491 | xs *s1 = xs_fmt( |
| 1498 | "<p><form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" | 1492 | "<p><form autocomplete=\"off\" method=\"post\" action=\"admin/action\">\n" |
| 1499 | "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n" | 1493 | "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n" |
| 1500 | "<input type=\"hidden\" name=\"actor-form\" value=\"yes\">\n", | 1494 | "<input type=\"hidden\" name=\"actor-form\" value=\"yes\">\n", |
| 1501 | 1495 | ||
| 1502 | snac->actor, actor_id | 1496 | actor_id |
| 1503 | ); | 1497 | ); |
| 1504 | s = xs_str_cat(s, s1); | 1498 | s = xs_str_cat(s, s1); |
| 1505 | 1499 | ||
| @@ -1523,7 +1517,7 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade | |||
| 1523 | xs *s2 = xs_fmt( | 1517 | xs *s2 = xs_fmt( |
| 1524 | "<p><details><summary>%s</summary>\n" | 1518 | "<p><details><summary>%s</summary>\n" |
| 1525 | "<p><div class=\"snac-note\" id=\"%s_%s_dm\">\n" | 1519 | "<p><div class=\"snac-note\" id=\"%s_%s_dm\">\n" |
| 1526 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/note\" " | 1520 | "<form autocomplete=\"off\" method=\"post\" action=\"admin/note\" " |
| 1527 | "enctype=\"multipart/form-data\" id=\"%s_reply_form\">\n" | 1521 | "enctype=\"multipart/form-data\" id=\"%s_reply_form\">\n" |
| 1528 | "<textarea class=\"snac-textarea\" name=\"content\" " | 1522 | "<textarea class=\"snac-textarea\" name=\"content\" " |
| 1529 | "rows=\"4\" wrap=\"virtual\" required=\"required\"></textarea>\n" | 1523 | "rows=\"4\" wrap=\"virtual\" required=\"required\"></textarea>\n" |
| @@ -1535,7 +1529,7 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade | |||
| 1535 | 1529 | ||
| 1536 | L("Direct Message..."), | 1530 | L("Direct Message..."), |
| 1537 | md5, t, | 1531 | md5, t, |
| 1538 | snac->actor, md5, | 1532 | md5, |
| 1539 | actor_id, | 1533 | actor_id, |
| 1540 | L("Post") | 1534 | L("Post") |
| 1541 | ); | 1535 | ); |
| @@ -1586,9 +1580,9 @@ xs_str *html_notifications(snac *snac) | |||
| 1586 | 1580 | ||
| 1587 | xs *s1 = xs_fmt( | 1581 | xs *s1 = xs_fmt( |
| 1588 | "<form autocomplete=\"off\" " | 1582 | "<form autocomplete=\"off\" " |
| 1589 | "method=\"post\" action=\"%s/admin/clear-notifications\" id=\"clear\">\n" | 1583 | "method=\"post\" action=\"admin/clear-notifications\" id=\"clear\">\n" |
| 1590 | "<input type=\"submit\" class=\"snac-btn-like\" value=\"%s\">\n" | 1584 | "<input type=\"submit\" class=\"snac-btn-like\" value=\"%s\">\n" |
| 1591 | "</form><p>\n", snac->actor, L("Clear all")); | 1585 | "</form><p>\n", L("Clear all")); |
| 1592 | s = xs_str_cat(s, s1); | 1586 | s = xs_str_cat(s, s1); |
| 1593 | 1587 | ||
| 1594 | while (xs_list_iter(&p, &v)) { | 1588 | while (xs_list_iter(&p, &v)) { |
| @@ -2402,7 +2396,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, | |||
| 2402 | if (xs_is_null(redir)) | 2396 | if (xs_is_null(redir)) |
| 2403 | redir = "snac-posts"; | 2397 | redir = "snac-posts"; |
| 2404 | 2398 | ||
| 2405 | *body = xs_fmt("%s/admin#%s", snac.actor, redir); | 2399 | *body = xs_fmt("../admin#%s", redir); |
| 2406 | *b_size = strlen(*body); | 2400 | *b_size = strlen(*body); |
| 2407 | } | 2401 | } |
| 2408 | 2402 | ||