From af6d31ff83bfe1eb6f4d37c5623e35f149e9aee5 Mon Sep 17 00:00:00 2001 From: default Date: Sat, 3 Dec 2022 07:27:26 +0100 Subject: [PATCH] New function timeline_simple_list(). --- RELEASE_NOTES.md | 2 +- activitypub.c | 2 +- data.c | 16 ++++++++++++---- html.c | 6 ++---- snac.h | 1 + 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 27674e5..d8a7e3f 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -4,7 +4,7 @@ A big disk layout rework, to make it more efficient when timelines get very big. Please take note that you must run `snac upgrade` when you install this version over an already existing one. -Fixed HTML loose close tag (contributed by kensata). +Fixed HTML loose close tag (contributed by kensanata). Fixed bug when closing sendmail pipe (contributed by jpgarcia and themusicgod1). diff --git a/activitypub.c b/activitypub.c index f19774c..9ac6bed 100644 --- a/activitypub.c +++ b/activitypub.c @@ -1094,7 +1094,7 @@ int activitypub_get_handler(d_char *req, char *q_path, else if (strcmp(p_path, "outbox") == 0) { xs *id = xs_fmt("%s/outbox", snac.actor); - xs *elems = timeline_list(&snac, "public", 20); + xs *elems = timeline_simple_list(&snac, "public", 20); xs *list = xs_list_new(); msg = msg_collection(&snac, id); char *p, *v; diff --git a/data.c b/data.c index a2242e8..12ba447 100644 --- a/data.c +++ b/data.c @@ -839,8 +839,8 @@ d_char *timeline_top_level(d_char *list) } -d_char *timeline_list(snac *snac, const char *idx_name, int max) -/* returns a timeline */ +d_char *timeline_simple_list(snac *snac, const char *idx_name, int max) +/* returns a timeline (with all entries) */ { int c_max; @@ -851,8 +851,16 @@ d_char *timeline_list(snac *snac, const char *idx_name, int max) if (max > c_max) max = c_max; - xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name); - xs *list = index_list_desc(idx, max); + xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name); + + return index_list_desc(idx, max); +} + + +d_char *timeline_list(snac *snac, const char *idx_name, int max) +/* returns a timeline (only top level entries) */ +{ + xs *list = timeline_simple_list(snac, idx_name, max); return timeline_top_level(list); } diff --git a/html.c b/html.c index 65ea5e1..3c5d0bc 100644 --- a/html.c +++ b/html.c @@ -549,8 +549,6 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int } if (level == 0) { - char *p; - s = xs_str_cat(s, "
\n"); if (boosts == NULL) @@ -558,7 +556,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int if (xs_list_len(boosts)) { /* if somebody boosted this, show as origin */ - p = xs_list_get(boosts, 0); + char *p = xs_list_get(boosts, -1); xs *actor_r = NULL; if (xs_list_in(boosts, snac->md5) != -1) { @@ -1096,7 +1094,7 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char * if (strcmp(p_path, ".rss") == 0) { /* public timeline in RSS format */ d_char *rss; - xs *elems = timeline_list(&snac, "public", 20); + xs *elems = timeline_simple_list(&snac, "public", 20); xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio")); char *p, *v; diff --git a/snac.h b/snac.h index 0d7ede1..1254584 100644 --- a/snac.h +++ b/snac.h @@ -79,6 +79,7 @@ d_char *follower_list(snac *snac); double timeline_mtime(snac *snac); int timeline_del(snac *snac, char *id); +d_char *timeline_simple_list(snac *snac, const char *idx_name, int max); d_char *timeline_list(snac *snac, const char *idx_name, int max); int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer); void timeline_admire(snac *snac, char *o_msg, char *id, char *admirer, int like);