diff options
| -rw-r--r-- | html.c | 60 |
1 files changed, 15 insertions, 45 deletions
| @@ -1065,54 +1065,24 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch | |||
| 1065 | 1065 | ||
| 1066 | s = xs_str_cat(s, "</form>\n"); | 1066 | s = xs_str_cat(s, "</form>\n"); |
| 1067 | 1067 | ||
| 1068 | const char *prev_src1 = xs_dict_get(msg, "sourceContent"); | 1068 | char *prev_src = xs_dict_get(msg, "sourceContent"); |
| 1069 | |||
| 1070 | if (!xs_is_null(prev_src1) && strcmp(actor, snac->actor) == 0) { /** edit **/ | ||
| 1071 | xs *prev_src = encode_html(prev_src1); | ||
| 1072 | const xs_val *sensitive = xs_dict_get(msg, "sensitive"); | ||
| 1073 | const char *summary = xs_dict_get(msg, "summary"); | ||
| 1074 | 1069 | ||
| 1070 | if (!xs_is_null(prev_src) && strcmp(actor, snac->actor) == 0) { /** edit **/ | ||
| 1075 | /* post can be edited */ | 1071 | /* post can be edited */ |
| 1076 | xs *s1 = xs_fmt( | 1072 | xs *div_id = xs_fmt("%s_edit", md5); |
| 1077 | "<p><details><summary>%s</summary>\n" | 1073 | xs *form_id = xs_fmt("%s_edit_form", md5); |
| 1078 | "<p><div class=\"snac-note\" id=\"%s_edit\">\n" | 1074 | xs *redir = xs_fmt("%s_entry", md5); |
| 1079 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/note\" " | ||
| 1080 | "enctype=\"multipart/form-data\" id=\"%s_edit_form\">\n" | ||
| 1081 | "<textarea class=\"snac-textarea\" name=\"content\" " | ||
| 1082 | "rows=\"4\" wrap=\"virtual\" required=\"required\">%s</textarea>\n" | ||
| 1083 | "<input type=\"hidden\" name=\"edit_id\" value=\"%s\">\n" | ||
| 1084 | |||
| 1085 | "<p>%s: <input type=\"checkbox\" name=\"sensitive\" %s> " | ||
| 1086 | "<input type=\"text\" name=\"summary\" placeholder=\"%s\" value=\"%s\">\n" | ||
| 1087 | "<p>%s: <input type=\"checkbox\" name=\"mentioned_only\">\n" | ||
| 1088 | |||
| 1089 | "<details><summary>%s</summary>\n" | ||
| 1090 | "<p>%s: <input type=\"file\" name=\"attach\">\n" | ||
| 1091 | "<p>%s: <input type=\"text\" name=\"alt_text\">\n" | ||
| 1092 | "</details>\n" | ||
| 1093 | 1075 | ||
| 1094 | "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n" | 1076 | xs_html *h = xs_html_tag("p", |
| 1095 | "<p><input type=\"submit\" class=\"button\" value=\"%s\">\n" | 1077 | html_note(snac, L("Edit..."), |
| 1096 | "</form><p></div>\n" | 1078 | div_id, form_id, |
| 1097 | "</details><p>" | 1079 | "", prev_src, |
| 1098 | "\n", | 1080 | (char *)id, NULL, |
| 1081 | xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"), | ||
| 1082 | xs_stock_false, redir, | ||
| 1083 | NULL, 0)); | ||
| 1099 | 1084 | ||
| 1100 | L("Edit..."), | 1085 | xs *s1 = xs_html_render(h); |
| 1101 | md5, | ||
| 1102 | snac->actor, md5, | ||
| 1103 | prev_src, | ||
| 1104 | id, | ||
| 1105 | L("Sensitive content"), | ||
| 1106 | xs_type(sensitive) == XSTYPE_TRUE ? "checked" : "", | ||
| 1107 | L("Sensitive content description"), | ||
| 1108 | xs_is_null(summary) ? "" : summary, | ||
| 1109 | L("Only for mentioned people"), | ||
| 1110 | L("Attach..."), | ||
| 1111 | L("File"), | ||
| 1112 | L("File description"), | ||
| 1113 | md5, | ||
| 1114 | L("Post") | ||
| 1115 | ); | ||
| 1116 | 1086 | ||
| 1117 | s = xs_str_cat(s, s1); | 1087 | s = xs_str_cat(s, s1); |
| 1118 | } | 1088 | } |
| @@ -1125,7 +1095,7 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch | |||
| 1125 | xs *redir = xs_fmt("%s_entry", md5); | 1095 | xs *redir = xs_fmt("%s_entry", md5); |
| 1126 | 1096 | ||
| 1127 | xs_html *h = xs_html_tag("p", | 1097 | xs_html *h = xs_html_tag("p", |
| 1128 | html_note(snac, L("Reply..."), | 1098 | html_note(snac, L("Reply..."), |
| 1129 | div_id, form_id, | 1099 | div_id, form_id, |
| 1130 | "", ct, | 1100 | "", ct, |
| 1131 | NULL, NULL, | 1101 | NULL, NULL, |