diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 41 |
1 files changed, 31 insertions, 10 deletions
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "xs_html.h" | 13 | #include "xs_html.h" |
| 14 | #include "xs_curl.h" | 14 | #include "xs_curl.h" |
| 15 | #include "xs_unicode.h" | 15 | #include "xs_unicode.h" |
| 16 | #include "xs_url.h" | ||
| 16 | 17 | ||
| 17 | #include "snac.h" | 18 | #include "snac.h" |
| 18 | 19 | ||
| @@ -115,7 +116,8 @@ xs_str *actor_name(xs_dict *actor, const char *proxy) | |||
| 115 | 116 | ||
| 116 | xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | 117 | xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, |
| 117 | const char *udate, const char *url, int priv, | 118 | const char *udate, const char *url, int priv, |
| 118 | int in_people, const char *proxy, const char *lang) | 119 | int in_people, const char *proxy, const char *lang, |
| 120 | const char *md5) | ||
| 119 | { | 121 | { |
| 120 | xs_html *actor_icon = xs_html_tag("p", NULL); | 122 | xs_html *actor_icon = xs_html_tag("p", NULL); |
| 121 | 123 | ||
| @@ -224,12 +226,31 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 224 | if (xs_is_string(lang)) | 226 | if (xs_is_string(lang)) |
| 225 | date_title = xs_str_cat(date_title, " (", lang, ")"); | 227 | date_title = xs_str_cat(date_title, " (", lang, ")"); |
| 226 | 228 | ||
| 229 | xs_html *date_text = xs_html_text(date_label); | ||
| 230 | |||
| 231 | if (user && md5) { | ||
| 232 | xs *lpost_url = xs_fmt("%s/admin/p/%s#%s_entry", | ||
| 233 | user->actor, md5, md5); | ||
| 234 | date_text = xs_html_tag("a", | ||
| 235 | xs_html_attr("href", lpost_url), | ||
| 236 | xs_html_attr("class", "snac-pubdate"), | ||
| 237 | date_text); | ||
| 238 | } | ||
| 239 | else if (user && url) { | ||
| 240 | xs *lpost_url = xs_fmt("%s/admin?q=%s", | ||
| 241 | user->actor, xs_url_enc(url)); | ||
| 242 | date_text = xs_html_tag("a", | ||
| 243 | xs_html_attr("href", lpost_url), | ||
| 244 | xs_html_attr("class", "snac-pubdate"), | ||
| 245 | date_text); | ||
| 246 | } | ||
| 247 | |||
| 227 | xs_html_add(actor_icon, | 248 | xs_html_add(actor_icon, |
| 228 | xs_html_text(" "), | 249 | xs_html_text(" "), |
| 229 | xs_html_tag("time", | 250 | xs_html_tag("time", |
| 230 | xs_html_attr("class", "dt-published snac-pubdate"), | 251 | xs_html_attr("class", "dt-published snac-pubdate"), |
| 231 | xs_html_attr("title", date_title), | 252 | xs_html_attr("title", date_title), |
| 232 | xs_html_text(date_label))); | 253 | date_text)); |
| 233 | } | 254 | } |
| 234 | 255 | ||
| 235 | { | 256 | { |
| @@ -261,7 +282,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | |||
| 261 | } | 282 | } |
| 262 | 283 | ||
| 263 | 284 | ||
| 264 | xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, const char *proxy) | 285 | xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, const char *proxy, const char *md5) |
| 265 | { | 286 | { |
| 266 | xs *actor = NULL; | 287 | xs *actor = NULL; |
| 267 | xs_html *actor_icon = NULL; | 288 | xs_html *actor_icon = NULL; |
| @@ -292,7 +313,7 @@ xs_html *html_msg_icon(snac *user, const char *actor_id, const xs_dict *msg, con | |||
| 292 | else | 313 | else |
| 293 | lang = NULL; | 314 | lang = NULL; |
| 294 | 315 | ||
| 295 | actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang); | 316 | actor_icon = html_actor_icon(user, actor, date, udate, url, priv, 0, proxy, lang, md5); |
| 296 | } | 317 | } |
| 297 | 318 | ||
| 298 | return actor_icon; | 319 | return actor_icon; |
| @@ -1706,7 +1727,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1706 | xs_html_tag("div", | 1727 | xs_html_tag("div", |
| 1707 | xs_html_attr("class", "snac-origin"), | 1728 | xs_html_attr("class", "snac-origin"), |
| 1708 | xs_html_text(L("follows you"))), | 1729 | xs_html_text(L("follows you"))), |
| 1709 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy))); | 1730 | html_msg_icon(read_only ? NULL : user, xs_dict_get(msg, "actor"), msg, proxy, NULL))); |
| 1710 | } | 1731 | } |
| 1711 | else | 1732 | else |
| 1712 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { | 1733 | if (!xs_match(type, POSTLIKE_OBJECT_TYPE)) { |
| @@ -1887,7 +1908,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 1887 | } | 1908 | } |
| 1888 | 1909 | ||
| 1889 | xs_html_add(post_header, | 1910 | xs_html_add(post_header, |
| 1890 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy)); | 1911 | html_msg_icon(read_only ? NULL : user, actor, msg, proxy, md5)); |
| 1891 | 1912 | ||
| 1892 | /** post content **/ | 1913 | /** post content **/ |
| 1893 | 1914 | ||
| @@ -2820,7 +2841,7 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t, cons | |||
| 2820 | xs_html_tag("div", | 2841 | xs_html_tag("div", |
| 2821 | xs_html_attr("class", "snac-post-header"), | 2842 | xs_html_attr("class", "snac-post-header"), |
| 2822 | html_actor_icon(snac, actor, xs_dict_get(actor, "published"), | 2843 | html_actor_icon(snac, actor, xs_dict_get(actor, "published"), |
| 2823 | NULL, NULL, 0, 1, proxy, NULL))); | 2844 | NULL, NULL, 0, 1, proxy, NULL, NULL))); |
| 2824 | 2845 | ||
| 2825 | /* content (user bio) */ | 2846 | /* content (user bio) */ |
| 2826 | const char *c = xs_dict_get(actor, "summary"); | 2847 | const char *c = xs_dict_get(actor, "summary"); |
| @@ -3118,7 +3139,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3118 | xs_html_add(entry, | 3139 | xs_html_add(entry, |
| 3119 | xs_html_tag("div", | 3140 | xs_html_tag("div", |
| 3120 | xs_html_attr("class", "snac-post"), | 3141 | xs_html_attr("class", "snac-post"), |
| 3121 | html_actor_icon(user, actor, NULL, NULL, NULL, 0, 0, proxy, NULL))); | 3142 | html_actor_icon(user, actor, NULL, NULL, NULL, 0, 0, proxy, NULL, NULL))); |
| 3122 | } | 3143 | } |
| 3123 | else | 3144 | else |
| 3124 | if (strcmp(type, "Move") == 0) { | 3145 | if (strcmp(type, "Move") == 0) { |
| @@ -3132,7 +3153,7 @@ xs_str *html_notifications(snac *user, int skip, int show) | |||
| 3132 | xs_html_add(entry, | 3153 | xs_html_add(entry, |
| 3133 | xs_html_tag("div", | 3154 | xs_html_tag("div", |
| 3134 | xs_html_attr("class", "snac-post"), | 3155 | xs_html_attr("class", "snac-post"), |
| 3135 | html_actor_icon(user, old_actor, NULL, NULL, NULL, 0, 0, proxy, NULL))); | 3156 | html_actor_icon(user, old_actor, NULL, NULL, NULL, 0, 0, proxy, NULL, NULL))); |
| 3136 | } | 3157 | } |
| 3137 | } | 3158 | } |
| 3138 | } | 3159 | } |
| @@ -3306,7 +3327,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3306 | cache = 0; | 3327 | cache = 0; |
| 3307 | 3328 | ||
| 3308 | int skip = 0; | 3329 | int skip = 0; |
| 3309 | int def_show = xs_number_get(xs_dict_get(srv_config, "max_timeline_entries")); | 3330 | int def_show = xs_number_get(xs_dict_get_def(srv_config, "def_timeline_entries", "50")); |
| 3310 | int show = def_show; | 3331 | int show = def_show; |
| 3311 | 3332 | ||
| 3312 | if ((v = xs_dict_get(q_vars, "skip")) != NULL) | 3333 | if ((v = xs_dict_get(q_vars, "skip")) != NULL) |