commit af6d31f

default  ·  2022-12-03 06:27:26 +0000 UTC
parent 2614a8b
New function timeline_simple_list().
5 files changed,  +17, -10
M data.c
M html.c
M snac.h
+1, -1
1@@ -4,7 +4,7 @@
2 
3 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.
4 
5-Fixed HTML loose close tag (contributed by kensata).
6+Fixed HTML loose close tag (contributed by kensanata).
7 
8 Fixed bug when closing sendmail pipe (contributed by jpgarcia and themusicgod1).
9 
+1, -1
1@@ -1094,7 +1094,7 @@ int activitypub_get_handler(d_char *req, char *q_path,
2     else
3     if (strcmp(p_path, "outbox") == 0) {
4         xs *id = xs_fmt("%s/outbox", snac.actor);
5-        xs *elems = timeline_list(&snac, "public", 20);
6+        xs *elems = timeline_simple_list(&snac, "public", 20);
7         xs *list = xs_list_new();
8         msg = msg_collection(&snac, id);
9         char *p, *v;
M data.c
+12, -4
 1@@ -839,8 +839,8 @@ d_char *timeline_top_level(d_char *list)
 2 }
 3 
 4 
 5-d_char *timeline_list(snac *snac, const char *idx_name, int max)
 6-/* returns a timeline */
 7+d_char *timeline_simple_list(snac *snac, const char *idx_name, int max)
 8+/* returns a timeline (with all entries) */
 9 {
10     int c_max;
11 
12@@ -851,8 +851,16 @@ d_char *timeline_list(snac *snac, const char *idx_name, int max)
13     if (max > c_max)
14         max = c_max;
15 
16-    xs *idx  = xs_fmt("%s/%s.idx", snac->basedir, idx_name);
17-    xs *list = index_list_desc(idx, max);
18+    xs *idx = xs_fmt("%s/%s.idx", snac->basedir, idx_name);
19+
20+    return index_list_desc(idx, max);
21+}
22+
23+
24+d_char *timeline_list(snac *snac, const char *idx_name, int max)
25+/* returns a timeline (only top level entries) */
26+{
27+    xs *list = timeline_simple_list(snac, idx_name, max);
28 
29     return timeline_top_level(list);
30 }
M html.c
+2, -4
 1@@ -549,8 +549,6 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int
 2     }
 3 
 4     if (level == 0) {
 5-        char *p;
 6-
 7         s = xs_str_cat(s, "<div class=\"snac-post\">\n");
 8 
 9         if (boosts == NULL)
10@@ -558,7 +556,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int
11 
12         if (xs_list_len(boosts)) {
13             /* if somebody boosted this, show as origin */
14-            p = xs_list_get(boosts, 0);
15+            char *p = xs_list_get(boosts, -1);
16             xs *actor_r = NULL;
17 
18             if (xs_list_in(boosts, snac->md5) != -1) {
19@@ -1096,7 +1094,7 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
20     if (strcmp(p_path, ".rss") == 0) {
21         /* public timeline in RSS format */
22         d_char *rss;
23-        xs *elems = timeline_list(&snac, "public", 20);
24+        xs *elems = timeline_simple_list(&snac, "public", 20);
25         xs *bio   = not_really_markdown(xs_dict_get(snac.config, "bio"));
26         char *p, *v;
27 
M snac.h
+1, -0
1@@ -79,6 +79,7 @@ d_char *follower_list(snac *snac);
2 
3 double timeline_mtime(snac *snac);
4 int timeline_del(snac *snac, char *id);
5+d_char *timeline_simple_list(snac *snac, const char *idx_name, int max);
6 d_char *timeline_list(snac *snac, const char *idx_name, int max);
7 int timeline_add(snac *snac, char *id, char *o_msg, char *parent, char *referrer);
8 void timeline_admire(snac *snac, char *o_msg, char *id, char *admirer, int like);