commit f82124a705d9c5350b92fba6a03c556c1fd5b2b0
parent 20fd70c01145e6be40edf231781497a2b5ec404f
Author: default <nobody@localhost>
Date: Sun, 2 Oct 2022 18:16:58 +0200
The history is shown at the bottom of the local timeline.
Diffstat:
M | data.c | | | 31 | +++++++++++++++++++++++++++++++ |
M | html.c | | | 29 | +++++++++++++++++++++++++++++ |
M | snac.h | | | 1 | + |
3 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/data.c b/data.c
@@ -914,6 +914,37 @@ int history_del(snac *snac, char *id)
}
+d_char *history_list(snac *snac)
+{
+ d_char *list;
+ xs *spec;
+ glob_t globbuf;
+
+ list = xs_list_new();
+ spec = xs_fmt("%s/history/" "*.html", snac->basedir);
+
+ if (glob(spec, 0, NULL, &globbuf) == 0) {
+ int n;
+ char *fn;
+
+ for (n = 0; (fn = globbuf.gl_pathv[n]) != NULL; n++) {
+ char *p;
+
+ if ((p = strrchr(fn, '/')) != NULL) {
+ *p++ = '\0';
+
+ if (*p != '_')
+ list = xs_list_append(list, p);
+ }
+ }
+ }
+
+ globfree(&globbuf);
+
+ return list;
+}
+
+
void enqueue_input(snac *snac, char *msg, char *req, int retries)
/* enqueues an input message */
{
diff --git a/html.c b/html.c
@@ -483,6 +483,10 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i
xs *actor_o = NULL;
char *actor;
+ /* do not show non-public messages in the public timeline */
+ if (local && !is_msg_public(snac, msg))
+ return os;
+
/* return if already seen */
if (xs_set_add(seen, id) == 0)
return os;
@@ -720,6 +724,31 @@ d_char *html_timeline(snac *snac, char *list, int local)
s = xs_str_cat(s, "</div>\n");
+ if (local) {
+ xs *s1 = xs_fmt(
+ "<div class=\"snac-history\">\n"
+ "<p class=\"snac-history-title\">%s</p><ul>\n",
+ L("History")
+ );
+
+ s = xs_str_cat(s, s1);
+
+ xs *list = history_list(snac);
+ char *p, *v;
+
+ p = list;
+ while (xs_list_iter(&p, &v)) {
+ xs *fn = xs_replace(v, ".html", "");
+ xs *s1 = xs_fmt(
+ "<li><a href=\"%s/h/%s\">%s</li>\n",
+ snac->actor, v, fn);
+
+ s = xs_str_cat(s, s1);
+ }
+
+ s = xs_str_cat(s, "</ul></div>\n");
+ }
+
s = html_user_footer(snac, s);
{
diff --git a/snac.h b/snac.h
@@ -86,6 +86,7 @@ double history_mtime(snac *snac, char *id);
void history_add(snac *snac, char *id, char *content, int size);
d_char *history_get(snac *snac, char *id);
int history_del(snac *snac, char *id);
+d_char *history_list(snac *snac);
void enqueue_input(snac *snac, char *msg, char *req, int retries);
void enqueue_output(snac *snac, char *msg, char *actor, int retries);