commit ed72987
default
·
2025-01-10 07:00:18 +0000 UTC
parent aab3274
New user settings latitude and longitude.
M
data.c
+2,
-1
1@@ -319,7 +319,8 @@ int user_persist(snac *snac, int publish)
2
3 if (old != NULL) {
4 int nw = 0;
5- const char *fields[] = { "header", "avatar", "name", "bio", "metadata", NULL };
6+ const char *fields[] = { "header", "avatar", "name", "bio",
7+ "metadata", "latitude", "longitude", NULL };
8
9 for (int n = 0; fields[n]; n++) {
10 const char *of = xs_dict_get(old, fields[n]);
M
html.c
+19,
-0
1@@ -1101,6 +1101,8 @@ xs_html *html_top_controls(snac *snac)
2 const xs_val *coll_thrds = xs_dict_get(snac->config, "collapse_threads");
3 const xs_val *pending = xs_dict_get(snac->config, "approve_followers");
4 const xs_val *show_foll = xs_dict_get(snac->config, "show_contact_metrics");
5+ const char *latitude = xs_dict_get_def(snac->config, "latitude", "");
6+ const char *longitude = xs_dict_get_def(snac->config, "longitude", "");
7
8 xs *metadata = NULL;
9 const xs_dict *md = xs_dict_get(snac->config, "metadata");
10@@ -1290,6 +1292,20 @@ xs_html *html_top_controls(snac *snac)
11 xs_html_tag("label",
12 xs_html_attr("for", "show_contact_metrics"),
13 xs_html_text(L("Publish follower and following metrics")))),
14+ xs_html_tag("p",
15+ xs_html_text(L("Home location:")),
16+ xs_html_sctag("br", NULL),
17+ xs_html_sctag("input",
18+ xs_html_attr("type", "text"),
19+ xs_html_attr("name", "latitude"),
20+ xs_html_attr("value", latitude),
21+ xs_html_attr("placeholder", "latitude")),
22+ xs_html_text(" "),
23+ xs_html_sctag("input",
24+ xs_html_attr("type", "text"),
25+ xs_html_attr("name", "longitude"),
26+ xs_html_attr("value", longitude),
27+ xs_html_attr("placeholder", "longitude"))),
28 xs_html_tag("p",
29 xs_html_text(L("Profile metadata (key=value pairs in each line):")),
30 xs_html_sctag("br", NULL),
31@@ -4053,6 +4069,9 @@ int html_post_handler(const xs_dict *req, const char *q_path,
32 else
33 snac.config = xs_dict_set(snac.config, "show_contact_metrics", xs_stock(XSTYPE_FALSE));
34
35+ snac.config = xs_dict_set(snac.config, "latitude", xs_dict_get_def(p_vars, "latitude", ""));
36+ snac.config = xs_dict_set(snac.config, "longitude", xs_dict_get_def(p_vars, "longitude", ""));
37+
38 if ((v = xs_dict_get(p_vars, "metadata")) != NULL)
39 snac.config = xs_dict_set(snac.config, "metadata", v);
40