diff options
| author | 2023-08-23 09:44:46 +0200 | |
|---|---|---|
| committer | 2023-08-23 09:44:46 +0200 | |
| commit | 505084bab74ec5a2a2c7c662cf7efe739fba3afa (patch) | |
| tree | 6bf716d08939f454049bcbb8c808427467c81c36 /html.c | |
| parent | Also propagate the 'conversation' field, if there is one. (diff) | |
| download | snac2-505084bab74ec5a2a2c7c662cf7efe739fba3afa.tar.gz snac2-505084bab74ec5a2a2c7c662cf7efe739fba3afa.tar.xz snac2-505084bab74ec5a2a2c7c662cf7efe739fba3afa.zip | |
Added some support for 'Article' object types.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 13 |
1 files changed, 8 insertions, 5 deletions
| @@ -203,7 +203,8 @@ xs_str *html_msg_icon(xs_str *os, const xs_dict *msg) | |||
| 203 | int priv = 0; | 203 | int priv = 0; |
| 204 | const char *type = xs_dict_get(msg, "type"); | 204 | const char *type = xs_dict_get(msg, "type"); |
| 205 | 205 | ||
| 206 | if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 || strcmp(type, "Page") == 0) | 206 | if (strcmp(type, "Note") == 0 || strcmp(type, "Question") == 0 || |
| 207 | strcmp(type, "Page") == 0 || strcmp(type, "Article") == 0) | ||
| 207 | url = xs_dict_get(msg, "id"); | 208 | url = xs_dict_get(msg, "id"); |
| 208 | 209 | ||
| 209 | priv = !is_msg_public(msg); | 210 | priv = !is_msg_public(msg); |
| @@ -972,7 +973,8 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 972 | return xs_str_cat(os, s); | 973 | return xs_str_cat(os, s); |
| 973 | } | 974 | } |
| 974 | else | 975 | else |
| 975 | if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0 && strcmp(type, "Page") != 0) { | 976 | if (strcmp(type, "Note") != 0 && strcmp(type, "Question") != 0 && |
| 977 | strcmp(type, "Page") != 0 && strcmp(type, "Article") != 0) { | ||
| 976 | /* skip oddities */ | 978 | /* skip oddities */ |
| 977 | return os; | 979 | return os; |
| 978 | } | 980 | } |
| @@ -1316,8 +1318,9 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 1316 | if (xs_is_null(url)) | 1318 | if (xs_is_null(url)) |
| 1317 | continue; | 1319 | continue; |
| 1318 | 1320 | ||
| 1319 | /* if it's a plain Link, check if it can be "rewritten" */ | 1321 | /* infer MIME type from non-specific attachments */ |
| 1320 | if (xs_list_len(attach) < 2 && strcmp(t, "Link") == 0) { | 1322 | if (xs_list_len(attach) < 2 && |
| 1323 | (strcmp(t, "Link") == 0 || strcmp(t, "Document") == 0)) { | ||
| 1321 | const char *mt = xs_mime_by_ext(url); | 1324 | const char *mt = xs_mime_by_ext(url); |
| 1322 | 1325 | ||
| 1323 | if (xs_startswith(mt, "image/") || | 1326 | if (xs_startswith(mt, "image/") || |
| @@ -1371,7 +1374,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 1371 | 1374 | ||
| 1372 | /* has this message an audience (i.e., comes from a channel or community)? */ | 1375 | /* has this message an audience (i.e., comes from a channel or community)? */ |
| 1373 | const char *audience = xs_dict_get(msg, "audience"); | 1376 | const char *audience = xs_dict_get(msg, "audience"); |
| 1374 | if (strcmp(type, "Page") == 0 && !xs_is_null(audience)) { | 1377 | if (!xs_is_null(audience)) { |
| 1375 | xs *es1 = encode_html(audience); | 1378 | xs *es1 = encode_html(audience); |
| 1376 | xs *s1 = xs_fmt("<p>(<a href=\"%s\" title=\"%s\">%s</a>)</p>\n", | 1379 | xs *s1 = xs_fmt("<p>(<a href=\"%s\" title=\"%s\">%s</a>)</p>\n", |
| 1377 | audience, L("Source channel or community"), es1); | 1380 | audience, L("Source channel or community"), es1); |