diff options
| author | 2023-11-27 21:54:57 +0100 | |
|---|---|---|
| committer | 2023-11-27 21:54:57 +0100 | |
| commit | 04b253200b04048abc5bdc5490d619532334ee51 (patch) | |
| tree | ece95d65f2b4f8f0a11e4a2420fcf6713325e5db /html.c | |
| parent | More html_entry() refactoring. (diff) | |
| download | snac2-04b253200b04048abc5bdc5490d619532334ee51.tar.gz snac2-04b253200b04048abc5bdc5490d619532334ee51.tar.xz snac2-04b253200b04048abc5bdc5490d619532334ee51.zip | |
More html_entry() refactoring.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 81 |
1 files changed, 37 insertions, 44 deletions
| @@ -1298,10 +1298,13 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 1298 | else | 1298 | else |
| 1299 | s = xs_str_cat(s, "<div class=\"snac-child\">\n"); /** **/ | 1299 | s = xs_str_cat(s, "<div class=\"snac-child\">\n"); /** **/ |
| 1300 | 1300 | ||
| 1301 | s = xs_str_cat(s, "<div class=\"snac-post-header\">\n"); /** **/ | 1301 | /** post header **/ |
| 1302 | 1302 | ||
| 1303 | xs_html *score = xs_html_tag("div", | 1303 | xs_html *score; |
| 1304 | xs_html_attr("class", "snac-score")); | 1304 | xs_html *post_header = xs_html_tag("div", |
| 1305 | xs_html_attr("class", "snac-post-header"), | ||
| 1306 | score = xs_html_tag("div", | ||
| 1307 | xs_html_attr("class", "snac-score"))); | ||
| 1305 | 1308 | ||
| 1306 | if (user && is_pinned(user, id)) { | 1309 | if (user && is_pinned(user, id)) { |
| 1307 | /* add a pin emoji */ | 1310 | /* add a pin emoji */ |
| @@ -1339,11 +1342,6 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 1339 | xs_html_raw(s1)); | 1342 | xs_html_raw(s1)); |
| 1340 | } | 1343 | } |
| 1341 | 1344 | ||
| 1342 | { | ||
| 1343 | xs *s1 = xs_html_render(score); | ||
| 1344 | s = xs_str_cat(s, s1); | ||
| 1345 | } | ||
| 1346 | |||
| 1347 | if (boosts == NULL) | 1345 | if (boosts == NULL) |
| 1348 | boosts = object_announces(id); | 1346 | boosts = object_announces(id); |
| 1349 | 1347 | ||
| @@ -1354,33 +1352,28 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 1354 | 1352 | ||
| 1355 | if (user && xs_list_in(boosts, user->md5) != -1) { | 1353 | if (user && xs_list_in(boosts, user->md5) != -1) { |
| 1356 | /* we boosted this */ | 1354 | /* we boosted this */ |
| 1357 | xs_html *h = xs_html_tag("div", | 1355 | xs_html_add(post_header, |
| 1358 | xs_html_attr("class", "snac-origin"), | 1356 | xs_html_tag("div", |
| 1359 | xs_html_tag("a", | 1357 | xs_html_attr("class", "snac-origin"), |
| 1360 | xs_html_attr("href", user->actor), | 1358 | xs_html_tag("a", |
| 1361 | xs_html_text(xs_dict_get(user->config, "name"))), | 1359 | xs_html_attr("href", user->actor), |
| 1362 | xs_html_text(" "), | 1360 | xs_html_text(xs_dict_get(user->config, "name"))), |
| 1363 | xs_html_text(L("boosted"))); | 1361 | xs_html_text(" "), |
| 1364 | 1362 | xs_html_text(L("boosted")))); | |
| 1365 | xs *s1 = xs_html_render(h); | ||
| 1366 | s = xs_str_cat(s, s1); | ||
| 1367 | } | 1363 | } |
| 1368 | else | 1364 | else |
| 1369 | if (valid_status(object_get_by_md5(p, &actor_r))) { | 1365 | if (valid_status(object_get_by_md5(p, &actor_r))) { |
| 1370 | xs *name = actor_name(actor_r); | 1366 | xs *name = actor_name(actor_r); |
| 1371 | 1367 | ||
| 1372 | if (!xs_is_null(name)) { | 1368 | if (!xs_is_null(name)) { |
| 1373 | xs_html *h = xs_html_tag("div", | 1369 | xs_html_add(post_header, |
| 1374 | xs_html_attr("class", "snac-origin"), | 1370 | xs_html_tag("div", |
| 1375 | xs_html_tag("a", | 1371 | xs_html_attr("class", "snac-origin"), |
| 1376 | xs_html_attr("href", xs_dict_get(actor_r, "id")), | 1372 | xs_html_tag("a", |
| 1377 | xs_html_text(name)), | 1373 | xs_html_attr("href", xs_dict_get(actor_r, "id")), |
| 1378 | xs_html_text(" "), | 1374 | xs_html_text(name)), |
| 1379 | xs_html_text(L("boosted"))); | 1375 | xs_html_text(" "), |
| 1380 | 1376 | xs_html_text(L("boosted")))); | |
| 1381 | xs *s1 = xs_html_render(h); | ||
| 1382 | |||
| 1383 | s = xs_str_cat(s, s1); | ||
| 1384 | } | 1377 | } |
| 1385 | } | 1378 | } |
| 1386 | } | 1379 | } |
| @@ -1391,29 +1384,29 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local, | |||
| 1391 | char *parent = xs_dict_get(msg, "inReplyTo"); | 1384 | char *parent = xs_dict_get(msg, "inReplyTo"); |
| 1392 | 1385 | ||
| 1393 | if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { | 1386 | if (user && !xs_is_null(parent) && *parent && !timeline_here(user, parent)) { |
| 1394 | xs_html *h = xs_html_tag("div", | 1387 | xs_html_add(post_header, |
| 1395 | xs_html_attr("class", "snac-origin"), | 1388 | xs_html_tag("div", |
| 1396 | xs_html_text(L("in reply to")), | 1389 | xs_html_attr("class", "snac-origin"), |
| 1397 | xs_html_text(" "), | 1390 | xs_html_text(L("in reply to")), |
| 1398 | xs_html_tag("a", | 1391 | xs_html_text(" "), |
| 1399 | xs_html_attr("href", parent), | 1392 | xs_html_tag("a", |
| 1400 | xs_html_text("»"))); | 1393 | xs_html_attr("href", parent), |
| 1401 | 1394 | xs_html_text("»")))); | |
| 1402 | xs *s1 = xs_html_render(h); | ||
| 1403 | |||
| 1404 | s = xs_str_cat(s, s1); | ||
| 1405 | } | 1395 | } |
| 1406 | } | 1396 | } |
| 1407 | } | 1397 | } |
| 1408 | 1398 | ||
| 1399 | xs_html_add(post_header, | ||
| 1400 | html_msg_icon(msg)); | ||
| 1401 | |||
| 1409 | { | 1402 | { |
| 1410 | xs_html *h = html_msg_icon(msg); | 1403 | xs *s1 = xs_html_render(post_header); |
| 1411 | xs *s1 = xs_html_render(h); | ||
| 1412 | s = xs_str_cat(s, s1); | 1404 | s = xs_str_cat(s, s1); |
| 1413 | } | 1405 | } |
| 1414 | 1406 | ||
| 1415 | /* add the content */ | 1407 | /** post content **/ |
| 1416 | s = xs_str_cat(s, "</div>\n<div class=\"e-content snac-content\">\n"); /** **/ | 1408 | |
| 1409 | s = xs_str_cat(s, "\n<div class=\"e-content snac-content\">\n"); /** **/ | ||
| 1417 | 1410 | ||
| 1418 | if (!xs_is_null(v = xs_dict_get(msg, "name"))) { | 1411 | if (!xs_is_null(v = xs_dict_get(msg, "name"))) { |
| 1419 | xs *es1 = encode_html(v); | 1412 | xs *es1 = encode_html(v); |