summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
authorGravatar _2025-04-18 13:09:19 +0000
committerGravatar _2025-04-18 13:09:19 +0000
commit2b17f7f89cea7c6d63fa757f23587387b6ea860a (patch)
tree5603f967edd15362352478797d398eb6dcf5b215 /html.c
parentMerge pull request 'master' (#1) from grunfink/snac2:master into master (diff)
parentUpdated RELEASE_NOTES. (diff)
downloadsnac2-2b17f7f89cea7c6d63fa757f23587387b6ea860a.tar.gz
snac2-2b17f7f89cea7c6d63fa757f23587387b6ea860a.tar.xz
snac2-2b17f7f89cea7c6d63fa757f23587387b6ea860a.zip
Merge pull request 'master' (#2) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/pmjv/snac2/pulls/2
Diffstat (limited to 'html.c')
-rw-r--r--html.c74
1 files changed, 58 insertions, 16 deletions
diff --git a/html.c b/html.c
index a598038..d807f4b 100644
--- a/html.c
+++ b/html.c
@@ -455,20 +455,26 @@ xs_html *html_note(snac *user, const char *summary,
455 } 455 }
456 456
457 if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) { 457 if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) {
458 xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), user->tz);
459
458 xs_html_add(form, 460 xs_html_add(form,
459 xs_html_tag("p", 461 xs_html_tag("p",
460 xs_html_text(L("Post date and time (empty, right now; in the future, schedule for later):")), 462 xs_html_tag("details",
461 xs_html_sctag("br", NULL), 463 xs_html_tag("summary",
462 xs_html_sctag("input", 464 xs_html_text(L("Scheduled post..."))),
463 xs_html_attr("type", "date"), 465 xs_html_tag("p",
464 xs_html_attr("value", post_date ? post_date : ""), 466 xs_html_text(pdat),
465 xs_html_attr("name", "post_date")), 467 xs_html_sctag("br", NULL),
466 xs_html_text(" "), 468 xs_html_sctag("input",
467 xs_html_sctag("input", 469 xs_html_attr("type", "date"),
468 xs_html_attr("type", "time"), 470 xs_html_attr("value", post_date ? post_date : ""),
469 xs_html_attr("value", post_time ? post_time : ""), 471 xs_html_attr("name", "post_date")),
470 xs_html_attr("step", "1"), 472 xs_html_text(" "),
471 xs_html_attr("name", "post_time")))); 473 xs_html_sctag("input",
474 xs_html_attr("type", "time"),
475 xs_html_attr("value", post_time ? post_time : ""),
476 xs_html_attr("step", "1"),
477 xs_html_attr("name", "post_time"))))));
472 } 478 }
473 479
474 if (edit_id) 480 if (edit_id)
@@ -1312,6 +1318,27 @@ xs_html *html_top_controls(snac *user)
1312 xs_html_attr("value", lang))); 1318 xs_html_attr("value", lang)));
1313 } 1319 }
1314 1320
1321 /* timezone */
1322 xs_html *tz_select = xs_html_tag("select",
1323 xs_html_attr("name", "tz"));
1324
1325 xs *tzs = xs_tz_list();
1326 const char *tz;
1327
1328 xs_list_foreach(tzs, tz) {
1329 if (strcmp(tz, user->tz) == 0)
1330 xs_html_add(tz_select,
1331 xs_html_tag("option",
1332 xs_html_text(tz),
1333 xs_html_attr("value", tz),
1334 xs_html_attr("selected", "selected")));
1335 else
1336 xs_html_add(tz_select,
1337 xs_html_tag("option",
1338 xs_html_text(tz),
1339 xs_html_attr("value", tz)));
1340 }
1341
1315 xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor); 1342 xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor);
1316 1343
1317 xs_html_add(top_controls, 1344 xs_html_add(top_controls,
@@ -1508,6 +1535,11 @@ xs_html *html_top_controls(snac *user)
1508 lang_select), 1535 lang_select),
1509 1536
1510 xs_html_tag("p", 1537 xs_html_tag("p",
1538 xs_html_text(L("Time zone:")),
1539 xs_html_sctag("br", NULL),
1540 tz_select),
1541
1542 xs_html_tag("p",
1511 xs_html_text(L("New password:")), 1543 xs_html_text(L("New password:")),
1512 xs_html_sctag("br", NULL), 1544 xs_html_sctag("br", NULL),
1513 xs_html_sctag("input", 1545 xs_html_sctag("input",
@@ -2439,13 +2471,19 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2439 name = NULL; 2471 name = NULL;
2440 } 2472 }
2441 else { 2473 else {
2474 xs *d_href = xs_dup(o_href);
2475 if (strlen(d_href) > 64) {
2476 d_href[64] = '\0';
2477 d_href = xs_str_cat(d_href, "...");
2478 }
2479
2442 xs_html_add(content_attachments, 2480 xs_html_add(content_attachments,
2443 xs_html_tag("p", 2481 xs_html_tag("p",
2444 xs_html_tag("a", 2482 xs_html_tag("a",
2445 xs_html_attr("href", o_href), 2483 xs_html_attr("href", o_href),
2446 xs_html_text(L("Attachment")), 2484 xs_html_text(L("Attachment")),
2447 xs_html_text(": "), 2485 xs_html_text(": "),
2448 xs_html_text(o_href)))); 2486 xs_html_text(d_href))));
2449 2487
2450 /* do not generate an Alt... */ 2488 /* do not generate an Alt... */
2451 name = NULL; 2489 name = NULL;
@@ -4349,19 +4387,21 @@ int html_post_handler(const xs_dict *req, const char *q_path,
4349 } 4387 }
4350 4388
4351 if (xs_is_string(post_date) && *post_date) { 4389 if (xs_is_string(post_date) && *post_date) {
4352 xs *local_pubdate = xs_fmt("%sT%s", post_date, 4390 xs *post_pubdate = xs_fmt("%sT%s", post_date,
4353 xs_is_string(post_time) && *post_time ? post_time : "00:00:00"); 4391 xs_is_string(post_time) && *post_time ? post_time : "00:00:00");
4354 4392
4355 time_t t = xs_parse_iso_date(local_pubdate, 1); 4393 time_t t = xs_parse_iso_date(post_pubdate, 0);
4356 4394
4357 if (t != 0) { 4395 if (t != 0) {
4396 t -= xs_tz_offset(snac.tz);
4397
4358 xs *iso_date = xs_str_iso_date(t); 4398 xs *iso_date = xs_str_iso_date(t);
4359 msg = xs_dict_set(msg, "published", iso_date); 4399 msg = xs_dict_set(msg, "published", iso_date);
4360 4400
4361 snac_debug(&snac, 1, xs_fmt("Published date: [%s]", iso_date)); 4401 snac_debug(&snac, 1, xs_fmt("Published date: [%s]", iso_date));
4362 } 4402 }
4363 else 4403 else
4364 snac_log(&snac, xs_fmt("Invalid post date: [%s]", local_pubdate)); 4404 snac_log(&snac, xs_fmt("Invalid post date: [%s]", post_pubdate));
4365 } 4405 }
4366 4406
4367 /* is the published date from the future? */ 4407 /* is the published date from the future? */
@@ -4741,6 +4781,8 @@ int html_post_handler(const xs_dict *req, const char *q_path,
4741 snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE)); 4781 snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE));
4742 if ((v = xs_dict_get(p_vars, "web_ui_lang")) != NULL) 4782 if ((v = xs_dict_get(p_vars, "web_ui_lang")) != NULL)
4743 snac.config = xs_dict_set(snac.config, "lang", v); 4783 snac.config = xs_dict_set(snac.config, "lang", v);
4784 if ((v = xs_dict_get(p_vars, "tz")) != NULL)
4785 snac.config = xs_dict_set(snac.config, "tz", v);
4744 4786
4745 snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", "")); 4787 snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", ""));
4746 snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", "")); 4788 snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", ""));