summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html.c60
1 files changed, 46 insertions, 14 deletions
diff --git a/html.c b/html.c
index b87b7be..10557bc 100644
--- a/html.c
+++ b/html.c
@@ -273,7 +273,8 @@ xs_html *html_note(snac *user, char *summary,
273 char *edit_id, char *actor_id, 273 char *edit_id, char *actor_id,
274 xs_val *cw_yn, char *cw_text, 274 xs_val *cw_yn, char *cw_text,
275 xs_val *mnt_only, char *redir, 275 xs_val *mnt_only, char *redir,
276 char *in_reply_to, int poll) 276 char *in_reply_to, int poll,
277 char *att_file, char *att_alt_text)
277{ 278{
278 xs *action = xs_fmt("%s/admin/note", user->actor); 279 xs *action = xs_fmt("%s/admin/note", user->actor);
279 280
@@ -359,19 +360,36 @@ xs_html *html_note(snac *user, char *summary,
359 xs_html_attr("name", "edit_id"), 360 xs_html_attr("name", "edit_id"),
360 xs_html_attr("value", edit_id))); 361 xs_html_attr("value", edit_id)));
361 362
363 /* attachment controls */
364 xs_html *att;
365
362 xs_html_add(form, 366 xs_html_add(form,
363 xs_html_tag("p", NULL), 367 xs_html_tag("p", NULL),
364 xs_html_tag("details", 368 att = xs_html_tag("details",
365 xs_html_tag("summary", 369 xs_html_tag("summary",
366 xs_html_text(L("Attachment..."))), 370 xs_html_text(L("Attachment..."))),
367 xs_html_tag("p", NULL), 371 xs_html_tag("p", NULL)));
368 xs_html_sctag("input", 372
369 xs_html_attr("type", "file"), 373 if (att_file && *att_file)
370 xs_html_attr("name", "attach")), 374 xs_html_add(att,
371 xs_html_sctag("input", 375 xs_html_text(L("File:")),
372 xs_html_attr("type", "text"), 376 xs_html_sctag("input",
373 xs_html_attr("name", "alt_text"), 377 xs_html_attr("type", "text"),
374 xs_html_attr("placeholder", L("Attachment description"))))); 378 xs_html_attr("name", "attach_url"),
379 xs_html_attr("value", att_file)));
380 else
381 xs_html_add(att,
382 xs_html_sctag("input",
383 xs_html_attr("type", "file"),
384 xs_html_attr("name", "attach")));
385
386 xs_html_add(att,
387 xs_html_text(" "),
388 xs_html_sctag("input",
389 xs_html_attr("type", "text"),
390 xs_html_attr("name", "alt_text"),
391 xs_html_attr("value", att_alt_text),
392 xs_html_attr("placeholder", L("Attachment description"))));
375 393
376 /* add poll controls */ 394 /* add poll controls */
377 if (poll) { 395 if (poll) {
@@ -854,7 +872,7 @@ xs_html *html_top_controls(snac *snac)
854 NULL, NULL, 872 NULL, NULL,
855 xs_stock(XSTYPE_FALSE), "", 873 xs_stock(XSTYPE_FALSE), "",
856 xs_stock(XSTYPE_FALSE), NULL, 874 xs_stock(XSTYPE_FALSE), NULL,
857 NULL, 1), 875 NULL, 1, "", ""),
858 876
859 /** operations **/ 877 /** operations **/
860 xs_html_tag("details", 878 xs_html_tag("details",
@@ -1278,6 +1296,20 @@ xs_html *html_entry_controls(snac *snac, char *actor, const xs_dict *msg, const
1278 xs *form_id = xs_fmt("%s_edit_form", md5); 1296 xs *form_id = xs_fmt("%s_edit_form", md5);
1279 xs *redir = xs_fmt("%s_entry", md5); 1297 xs *redir = xs_fmt("%s_entry", md5);
1280 1298
1299 char *att_file = "";
1300 char *att_alt_text = "";
1301 xs_list *att_list = xs_dict_get(msg, "attachment");
1302
1303 /* does it have an attachment? */
1304 if (xs_type(att_list) == XSTYPE_LIST && xs_list_len(att_list)) {
1305 xs_dict *d = xs_list_get(att_list, 0);
1306
1307 if (xs_type(d) == XSTYPE_DICT) {
1308 att_file = xs_dict_get_def(d, "url", "");
1309 att_alt_text = xs_dict_get_def(d, "name", "");
1310 }
1311 }
1312
1281 xs_html_add(controls, xs_html_tag("div", 1313 xs_html_add(controls, xs_html_tag("div",
1282 xs_html_tag("p", NULL), 1314 xs_html_tag("p", NULL),
1283 html_note(snac, L("Edit..."), 1315 html_note(snac, L("Edit..."),
@@ -1286,7 +1318,7 @@ xs_html *html_entry_controls(snac *snac, char *actor, const xs_dict *msg, const
1286 id, NULL, 1318 id, NULL,
1287 xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"), 1319 xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"),
1288 xs_stock(XSTYPE_FALSE), redir, 1320 xs_stock(XSTYPE_FALSE), redir,
1289 NULL, 0)), 1321 NULL, 0, att_file, att_alt_text)),
1290 xs_html_tag("p", NULL)); 1322 xs_html_tag("p", NULL));
1291 } 1323 }
1292 1324
@@ -1305,7 +1337,7 @@ xs_html *html_entry_controls(snac *snac, char *actor, const xs_dict *msg, const
1305 NULL, NULL, 1337 NULL, NULL,
1306 xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"), 1338 xs_dict_get(msg, "sensitive"), xs_dict_get(msg, "summary"),
1307 xs_stock(XSTYPE_FALSE), redir, 1339 xs_stock(XSTYPE_FALSE), redir,
1308 id, 0)), 1340 id, 0, "", "")),
1309 xs_html_tag("p", NULL)); 1341 xs_html_tag("p", NULL));
1310 } 1342 }
1311 1343
@@ -2201,7 +2233,7 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t)
2201 NULL, actor_id, 2233 NULL, actor_id,
2202 xs_stock(XSTYPE_FALSE), "", 2234 xs_stock(XSTYPE_FALSE), "",
2203 xs_stock(XSTYPE_FALSE), NULL, 2235 xs_stock(XSTYPE_FALSE), NULL,
2204 NULL, 0), 2236 NULL, 0, "", ""),
2205 xs_html_tag("p", NULL)); 2237 xs_html_tag("p", NULL));
2206 2238
2207 xs_html_add(snac_post, snac_controls); 2239 xs_html_add(snac_post, snac_controls);