From 32b7fa2fcb8d77cab49f0b17af75669139901859 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 10 Apr 2025 08:25:35 +0200 Subject: Shorten link label in Attachments. --- html.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'html.c') diff --git a/html.c b/html.c index a598038..e303d72 100644 --- a/html.c +++ b/html.c @@ -2439,13 +2439,19 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, name = NULL; } else { + xs *d_href = xs_dup(o_href); + if (strlen(d_href) > 64) { + d_href[64] = '\0'; + d_href = xs_str_cat(d_href, "..."); + } + xs_html_add(content_attachments, xs_html_tag("p", xs_html_tag("a", xs_html_attr("href", o_href), xs_html_text(L("Attachment")), xs_html_text(": "), - xs_html_text(o_href)))); + xs_html_text(d_href)))); /* do not generate an Alt... */ name = NULL; -- cgit v1.2.3 From cbe25ddb853281aa800befea31e8f6dac0206411 Mon Sep 17 00:00:00 2001 From: default Date: Thu, 10 Apr 2025 08:40:54 +0200 Subject: Hide the scheduled post date and time behind a 'details'. --- html.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index e303d72..b5d8946 100644 --- a/html.c +++ b/html.c @@ -457,18 +457,22 @@ xs_html *html_note(snac *user, const char *summary, if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) { xs_html_add(form, xs_html_tag("p", - xs_html_text(L("Post date and time (empty, right now; in the future, schedule for later):")), - xs_html_sctag("br", NULL), - xs_html_sctag("input", - xs_html_attr("type", "date"), - xs_html_attr("value", post_date ? post_date : ""), - xs_html_attr("name", "post_date")), - xs_html_text(" "), - xs_html_sctag("input", - xs_html_attr("type", "time"), - xs_html_attr("value", post_time ? post_time : ""), - xs_html_attr("step", "1"), - xs_html_attr("name", "post_time")))); + xs_html_tag("details", + xs_html_tag("summary", + xs_html_text(L("Scheduled post..."))), + xs_html_tag("p", + xs_html_text(L("Post date and time:")), + xs_html_sctag("br", NULL), + xs_html_sctag("input", + xs_html_attr("type", "date"), + xs_html_attr("value", post_date ? post_date : ""), + xs_html_attr("name", "post_date")), + xs_html_text(" "), + xs_html_sctag("input", + xs_html_attr("type", "time"), + xs_html_attr("value", post_time ? post_time : ""), + xs_html_attr("step", "1"), + xs_html_attr("name", "post_time")))))); } if (edit_id) -- cgit v1.2.3 From 9a238a937e31b36e7ee35109c09764019ee3af1f Mon Sep 17 00:00:00 2001 From: default Date: Sun, 13 Apr 2025 09:23:43 +0200 Subject: Added some preliminary support for time zones (for scheduled posts). --- html.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index b5d8946..afbc716 100644 --- a/html.c +++ b/html.c @@ -4359,19 +4359,23 @@ int html_post_handler(const xs_dict *req, const char *q_path, } if (xs_is_string(post_date) && *post_date) { - xs *local_pubdate = xs_fmt("%sT%s", post_date, + xs *post_pubdate = xs_fmt("%sT%s", post_date, xs_is_string(post_time) && *post_time ? post_time : "00:00:00"); - time_t t = xs_parse_iso_date(local_pubdate, 1); + time_t t = xs_parse_iso_date(post_pubdate, 0); if (t != 0) { + const char *tz = xs_dict_get_def(snac.config, "tz", "UTC"); + + t -= xs_tz_offset(tz); + xs *iso_date = xs_str_iso_date(t); msg = xs_dict_set(msg, "published", iso_date); snac_debug(&snac, 1, xs_fmt("Published date: [%s]", iso_date)); } else - snac_log(&snac, xs_fmt("Invalid post date: [%s]", local_pubdate)); + snac_log(&snac, xs_fmt("Invalid post date: [%s]", post_pubdate)); } /* is the published date from the future? */ -- cgit v1.2.3 From f1f288699805b13bcd8f296667923ae5d2ae45ed Mon Sep 17 00:00:00 2001 From: default Date: Sun, 13 Apr 2025 09:33:17 +0200 Subject: Fixed offset sign because I'm a MORON. --- html.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'html.c') diff --git a/html.c b/html.c index afbc716..b04e001 100644 --- a/html.c +++ b/html.c @@ -4367,7 +4367,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, if (t != 0) { const char *tz = xs_dict_get_def(snac.config, "tz", "UTC"); - t -= xs_tz_offset(tz); + t += xs_tz_offset(tz); xs *iso_date = xs_str_iso_date(t); msg = xs_dict_set(msg, "published", iso_date); -- cgit v1.2.3 From fb9e0fd21b7210e2ff71cc364b2285b1231fff60 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 13 Apr 2025 10:04:31 +0200 Subject: Mention the timezone in the 'post date and time' prompt. --- html.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'html.c') diff --git a/html.c b/html.c index b04e001..68a6b73 100644 --- a/html.c +++ b/html.c @@ -455,13 +455,15 @@ xs_html *html_note(snac *user, const char *summary, } if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) { + xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), xs_dict_get_def(user->config, "tz", "UTC")); + xs_html_add(form, xs_html_tag("p", xs_html_tag("details", xs_html_tag("summary", xs_html_text(L("Scheduled post..."))), xs_html_tag("p", - xs_html_text(L("Post date and time:")), + xs_html_text(pdat), xs_html_sctag("br", NULL), xs_html_sctag("input", xs_html_attr("type", "date"), -- cgit v1.2.3 From 81538904210e9092760ce7c6b043eaaa166509b6 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 13 Apr 2025 14:12:37 +0200 Subject: More timezone tweaks. --- html.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'html.c') diff --git a/html.c b/html.c index 68a6b73..a6f79de 100644 --- a/html.c +++ b/html.c @@ -4369,7 +4369,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, if (t != 0) { const char *tz = xs_dict_get_def(snac.config, "tz", "UTC"); - t += xs_tz_offset(tz); + t -= xs_tz_offset(tz); xs *iso_date = xs_str_iso_date(t); msg = xs_dict_set(msg, "published", iso_date); -- cgit v1.2.3 From 848bd3e865fb2daf75d76cbb75a4a39f9b82b516 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 13 Apr 2025 14:30:50 +0200 Subject: Cache the timezone inside the snac struct. --- html.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'html.c') diff --git a/html.c b/html.c index a6f79de..2e7f87c 100644 --- a/html.c +++ b/html.c @@ -455,7 +455,7 @@ xs_html *html_note(snac *user, const char *summary, } if (edit_id == NULL || is_draft || is_scheduled(user, edit_id)) { - xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), xs_dict_get_def(user->config, "tz", "UTC")); + xs *pdat = xs_fmt(L("Post date and time (timezone: %s):"), user->tz); xs_html_add(form, xs_html_tag("p", @@ -4367,9 +4367,7 @@ int html_post_handler(const xs_dict *req, const char *q_path, time_t t = xs_parse_iso_date(post_pubdate, 0); if (t != 0) { - const char *tz = xs_dict_get_def(snac.config, "tz", "UTC"); - - t -= xs_tz_offset(tz); + t -= xs_tz_offset(snac.tz); xs *iso_date = xs_str_iso_date(t); msg = xs_dict_set(msg, "published", iso_date); -- cgit v1.2.3 From a28638b4c18abacabd02fef4a51dde80bf4d5db4 Mon Sep 17 00:00:00 2001 From: default Date: Sun, 13 Apr 2025 14:39:46 +0200 Subject: More timezone work. --- html.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'html.c') diff --git a/html.c b/html.c index 2e7f87c..d807f4b 100644 --- a/html.c +++ b/html.c @@ -1318,6 +1318,27 @@ xs_html *html_top_controls(snac *user) xs_html_attr("value", lang))); } + /* timezone */ + xs_html *tz_select = xs_html_tag("select", + xs_html_attr("name", "tz")); + + xs *tzs = xs_tz_list(); + const char *tz; + + xs_list_foreach(tzs, tz) { + if (strcmp(tz, user->tz) == 0) + xs_html_add(tz_select, + xs_html_tag("option", + xs_html_text(tz), + xs_html_attr("value", tz), + xs_html_attr("selected", "selected"))); + else + xs_html_add(tz_select, + xs_html_tag("option", + xs_html_text(tz), + xs_html_attr("value", tz))); + } + xs *user_setup_action = xs_fmt("%s/admin/user-setup", user->actor); xs_html_add(top_controls, @@ -1513,6 +1534,11 @@ xs_html *html_top_controls(snac *user) xs_html_sctag("br", NULL), lang_select), + xs_html_tag("p", + xs_html_text(L("Time zone:")), + xs_html_sctag("br", NULL), + tz_select), + xs_html_tag("p", xs_html_text(L("New password:")), xs_html_sctag("br", NULL), @@ -4755,6 +4781,8 @@ int html_post_handler(const xs_dict *req, const char *q_path, snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE)); if ((v = xs_dict_get(p_vars, "web_ui_lang")) != NULL) snac.config = xs_dict_set(snac.config, "lang", v); + if ((v = xs_dict_get(p_vars, "tz")) != NULL) + snac.config = xs_dict_set(snac.config, "tz", v); snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", "")); snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", "")); -- cgit v1.2.3