mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
The history is shown at the bottom of the local timeline.
This commit is contained in:
parent
20fd70c011
commit
f82124a705
3 changed files with 61 additions and 0 deletions
31
data.c
31
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)
|
void enqueue_input(snac *snac, char *msg, char *req, int retries)
|
||||||
/* enqueues an input message */
|
/* enqueues an input message */
|
||||||
{
|
{
|
||||||
|
|
29
html.c
29
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;
|
xs *actor_o = NULL;
|
||||||
char *actor;
|
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 */
|
/* return if already seen */
|
||||||
if (xs_set_add(seen, id) == 0)
|
if (xs_set_add(seen, id) == 0)
|
||||||
return os;
|
return os;
|
||||||
|
@ -720,6 +724,31 @@ d_char *html_timeline(snac *snac, char *list, int local)
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n");
|
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);
|
s = html_user_footer(snac, s);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
1
snac.h
1
snac.h
|
@ -86,6 +86,7 @@ double history_mtime(snac *snac, char *id);
|
||||||
void history_add(snac *snac, char *id, char *content, int size);
|
void history_add(snac *snac, char *id, char *content, int size);
|
||||||
d_char *history_get(snac *snac, char *id);
|
d_char *history_get(snac *snac, char *id);
|
||||||
int history_del(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_input(snac *snac, char *msg, char *req, int retries);
|
||||||
void enqueue_output(snac *snac, char *msg, char *actor, int retries);
|
void enqueue_output(snac *snac, char *msg, char *actor, int retries);
|
||||||
|
|
Loading…
Reference in a new issue