summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c46
1 files changed, 35 insertions, 11 deletions
diff --git a/html.c b/html.c
index b9f2419..aec7d0a 100644
--- a/html.c
+++ b/html.c
@@ -216,7 +216,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
216 xs_html_attr("loading", "lazy"), 216 xs_html_attr("loading", "lazy"),
217 xs_html_attr("class", "snac-avatar"), 217 xs_html_attr("class", "snac-avatar"),
218 xs_html_attr("src", avatar), 218 xs_html_attr("src", avatar),
219 xs_html_attr("alt", "")), 219 xs_html_attr("alt", "[?]")),
220 xs_html_tag("a", 220 xs_html_tag("a",
221 xs_html_attr("href", href), 221 xs_html_attr("href", href),
222 xs_html_attr("class", "p-author h-card snac-author"), 222 xs_html_attr("class", "p-author h-card snac-author"),
@@ -482,7 +482,7 @@ xs_html *html_note(snac *user, const char *summary,
482 } 482 }
483 483
484 if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) { 484 if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) {
485 xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), xs_dict_get_def(user->config, "tz", "UTC")); 485 xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), user->tz);
486 486
487 xs_html_add(form, 487 xs_html_add(form,
488 xs_html_tag("p", 488 xs_html_tag("p",
@@ -1342,6 +1342,27 @@ xs_html *html_top_controls(snac *user)
1342 xs_html_attr("value", lang))); 1342 xs_html_attr("value", lang)));
1343 } 1343 }
1344 1344
1345 /* timezone */
1346 xs_html *tz_select = xs_html_tag("select",
1347 xs_html_attr("name", "tz"));
1348
1349 xs *tzs = xs_tz_list();
1350 const char *tz;
1351
1352 xs_list_foreach(tzs, tz) {
1353 if (strcmp(tz, user->tz) == 0)
1354 xs_html_add(tz_select,
1355 xs_html_tag("option",
1356 xs_html_text(tz),
1357 xs_html_attr("value", tz),
1358 xs_html_attr("selected", "selected")));
1359 else
1360 xs_html_add(tz_select,
1361 xs_html_tag("option",
1362 xs_html_text(tz),
1363 xs_html_attr("value", tz)));
1364 }
1365
1345 xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor); 1366 xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor);
1346 1367
1347 xs_html_add(top_controls, 1368 xs_html_add(top_controls,
@@ -1538,6 +1559,11 @@ xs_html *html_top_controls(snac *user)
1538 lang_select), 1559 lang_select),
1539 1560
1540 xs_html_tag("p", 1561 xs_html_tag("p",
1562 xs_html_text(L("Time zone:")),
1563 xs_html_sctag("br", NULL),
1564 tz_select),
1565
1566 xs_html_tag("p",
1541 xs_html_text(L("New password:")), 1567 xs_html_text(L("New password:")),
1542 xs_html_sctag("br", NULL), 1568 xs_html_sctag("br", NULL),
1543 xs_html_sctag("input", 1569 xs_html_sctag("input",
@@ -2386,14 +2412,10 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2386 const char *o_href = xs_dict_get(a, "href"); 2412 const char *o_href = xs_dict_get(a, "href");
2387 const char *name = xs_dict_get(a, "name"); 2413 const char *name = xs_dict_get(a, "name");
2388 2414
2389 /* if this image is already in the post content, skip */ 2415 /* if this URL is already in the post content, skip */
2390 if (content && xs_str_in(content, o_href) != -1) 2416 if (content && xs_str_in(content, o_href) != -1)
2391 continue; 2417 continue;
2392 2418
2393 /* drop silently any attachment that may include JavaScript */
2394 if (strcmp(type, "text/html") == 0)
2395 continue;
2396
2397 if (strcmp(type, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg"))) 2419 if (strcmp(type, "image/svg+xml") == 0 && !xs_is_true(xs_dict_get(srv_config, "enable_svg")))
2398 continue; 2420 continue;
2399 2421
@@ -4394,9 +4416,7 @@ int html_post_handler(const xs_dict *req, const char *q_path,
4394 time_t t = xs_parse_iso_date(post_pubdate, 0); 4416 time_t t = xs_parse_iso_date(post_pubdate, 0);
4395 4417
4396 if (t != 0) { 4418 if (t != 0) {
4397 const char *tz = xs_dict_get_def(snac.config, "tz", "UTC"); 4419 t -= xs_tz_offset(snac.tz);
4398
4399 t += xs_tz_offset(tz);
4400 4420
4401 xs *iso_date = xs_str_iso_date(t); 4421 xs *iso_date = xs_str_iso_date(t);
4402 msg = xs_dict_set(msg, "published", iso_date); 4422 msg = xs_dict_set(msg, "published", iso_date);
@@ -4495,8 +4515,10 @@ int html_post_handler(const xs_dict *req, const char *q_path,
4495 snac_log(&snac, xs_fmt("cannot get object '%s' for editing", edit_id)); 4515 snac_log(&snac, xs_fmt("cannot get object '%s' for editing", edit_id));
4496 } 4516 }
4497 4517
4498 if (c_msg != NULL) 4518 if (c_msg != NULL) {
4499 enqueue_message(&snac, c_msg); 4519 enqueue_message(&snac, c_msg);
4520 enqueue_webmention(msg);
4521 }
4500 4522
4501 history_del(&snac, "timeline.html_"); 4523 history_del(&snac, "timeline.html_");
4502 } 4524 }
@@ -4784,6 +4806,8 @@ int html_post_handler(const xs_dict *req, const char *q_path,
4784 snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE)); 4806 snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE));
4785 if ((v = xs_dict_get(p_vars, "web_ui_lang")) != NULL) 4807 if ((v = xs_dict_get(p_vars, "web_ui_lang")) != NULL)
4786 snac.config = xs_dict_set(snac.config, "lang", v); 4808 snac.config = xs_dict_set(snac.config, "lang", v);
4809 if ((v = xs_dict_get(p_vars, "tz")) != NULL)
4810 snac.config = xs_dict_set(snac.config, "tz", v);
4787 4811
4788 snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", "")); 4812 snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", ""));
4789 snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", "")); 4813 snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", ""));