diff options
| -rw-r--r-- | html.c | 37 |
1 files changed, 37 insertions, 0 deletions
| @@ -2224,6 +2224,43 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2224 | au_tag); | 2224 | au_tag); |
| 2225 | } | 2225 | } |
| 2226 | 2226 | ||
| 2227 | /* does it have a location? */ | ||
| 2228 | const xs_dict *location = xs_dict_get(msg, "location"); | ||
| 2229 | if (xs_type(location) == XSTYPE_DICT) { | ||
| 2230 | const xs_number *latitude = xs_dict_get(location, "latitude"); | ||
| 2231 | const xs_number *longitude = xs_dict_get(location, "longitude"); | ||
| 2232 | const char *name = xs_dict_get(location, "name"); | ||
| 2233 | const char *address = xs_dict_get(location, "address"); | ||
| 2234 | xs *label_list = xs_list_new(); | ||
| 2235 | |||
| 2236 | if (xs_type(name) == XSTYPE_STRING) | ||
| 2237 | label_list = xs_list_append(label_list, name); | ||
| 2238 | if (xs_type(address) == XSTYPE_STRING) | ||
| 2239 | label_list = xs_list_append(label_list, address); | ||
| 2240 | |||
| 2241 | if (xs_list_len(label_list)) { | ||
| 2242 | xs *label = xs_join(label_list, ", "); | ||
| 2243 | |||
| 2244 | if (!xs_is_null(latitude) && !xs_is_null(longitude)) { | ||
| 2245 | xs *url = xs_fmt("https://openstreetmap.org/search/?query=%s,%s", | ||
| 2246 | xs_number_str(latitude), xs_number_str(longitude)); | ||
| 2247 | |||
| 2248 | xs_html_add(snac_content_wrap, | ||
| 2249 | xs_html_tag("p", | ||
| 2250 | xs_html_text(L("Location: ")), | ||
| 2251 | xs_html_tag("a", | ||
| 2252 | xs_html_attr("href", url), | ||
| 2253 | xs_html_attr("target", "_blank"), | ||
| 2254 | xs_html_text(label)))); | ||
| 2255 | } | ||
| 2256 | else | ||
| 2257 | xs_html_add(snac_content_wrap, | ||
| 2258 | xs_html_tag("p", | ||
| 2259 | xs_html_text(L("Location: ")), | ||
| 2260 | xs_html_text(label))); | ||
| 2261 | } | ||
| 2262 | } | ||
| 2263 | |||
| 2227 | /* show all hashtags that has not been shown previously in the content */ | 2264 | /* show all hashtags that has not been shown previously in the content */ |
| 2228 | const xs_list *tags = xs_dict_get(msg, "tag"); | 2265 | const xs_list *tags = xs_dict_get(msg, "tag"); |
| 2229 | if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags)) { | 2266 | if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags)) { |