diff options
| -rw-r--r-- | data.c | 31 | ||||
| -rw-r--r-- | html.c | 29 | ||||
| -rw-r--r-- | snac.h | 1 |
3 files changed, 61 insertions, 0 deletions
| @@ -914,6 +914,37 @@ int history_del(snac *snac, char *id) | |||
| 914 | } | 914 | } |
| 915 | 915 | ||
| 916 | 916 | ||
| 917 | d_char *history_list(snac *snac) | ||
| 918 | { | ||
| 919 | d_char *list; | ||
| 920 | xs *spec; | ||
| 921 | glob_t globbuf; | ||
| 922 | |||
| 923 | list = xs_list_new(); | ||
| 924 | spec = xs_fmt("%s/history/" "*.html", snac->basedir); | ||
| 925 | |||
| 926 | if (glob(spec, 0, NULL, &globbuf) == 0) { | ||
| 927 | int n; | ||
| 928 | char *fn; | ||
| 929 | |||
| 930 | for (n = 0; (fn = globbuf.gl_pathv[n]) != NULL; n++) { | ||
| 931 | char *p; | ||
| 932 | |||
| 933 | if ((p = strrchr(fn, '/')) != NULL) { | ||
| 934 | *p++ = '\0'; | ||
| 935 | |||
| 936 | if (*p != '_') | ||
| 937 | list = xs_list_append(list, p); | ||
| 938 | } | ||
| 939 | } | ||
| 940 | } | ||
| 941 | |||
| 942 | globfree(&globbuf); | ||
| 943 | |||
| 944 | return list; | ||
| 945 | } | ||
| 946 | |||
| 947 | |||
| 917 | void enqueue_input(snac *snac, char *msg, char *req, int retries) | 948 | void enqueue_input(snac *snac, char *msg, char *req, int retries) |
| 918 | /* enqueues an input message */ | 949 | /* enqueues an input message */ |
| 919 | { | 950 | { |
| @@ -483,6 +483,10 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i | |||
| 483 | xs *actor_o = NULL; | 483 | xs *actor_o = NULL; |
| 484 | char *actor; | 484 | char *actor; |
| 485 | 485 | ||
| 486 | /* do not show non-public messages in the public timeline */ | ||
| 487 | if (local && !is_msg_public(snac, msg)) | ||
| 488 | return os; | ||
| 489 | |||
| 486 | /* return if already seen */ | 490 | /* return if already seen */ |
| 487 | if (xs_set_add(seen, id) == 0) | 491 | if (xs_set_add(seen, id) == 0) |
| 488 | return os; | 492 | return os; |
| @@ -720,6 +724,31 @@ d_char *html_timeline(snac *snac, char *list, int local) | |||
| 720 | 724 | ||
| 721 | s = xs_str_cat(s, "</div>\n"); | 725 | s = xs_str_cat(s, "</div>\n"); |
| 722 | 726 | ||
| 727 | if (local) { | ||
| 728 | xs *s1 = xs_fmt( | ||
| 729 | "<div class=\"snac-history\">\n" | ||
| 730 | "<p class=\"snac-history-title\">%s</p><ul>\n", | ||
| 731 | L("History") | ||
| 732 | ); | ||
| 733 | |||
| 734 | s = xs_str_cat(s, s1); | ||
| 735 | |||
| 736 | xs *list = history_list(snac); | ||
| 737 | char *p, *v; | ||
| 738 | |||
| 739 | p = list; | ||
| 740 | while (xs_list_iter(&p, &v)) { | ||
| 741 | xs *fn = xs_replace(v, ".html", ""); | ||
| 742 | xs *s1 = xs_fmt( | ||
| 743 | "<li><a href=\"%s/h/%s\">%s</li>\n", | ||
| 744 | snac->actor, v, fn); | ||
| 745 | |||
| 746 | s = xs_str_cat(s, s1); | ||
| 747 | } | ||
| 748 | |||
| 749 | s = xs_str_cat(s, "</ul></div>\n"); | ||
| 750 | } | ||
| 751 | |||
| 723 | s = html_user_footer(snac, s); | 752 | s = html_user_footer(snac, s); |
| 724 | 753 | ||
| 725 | { | 754 | { |
| @@ -86,6 +86,7 @@ double history_mtime(snac *snac, char *id); | |||
| 86 | void history_add(snac *snac, char *id, char *content, int size); | 86 | void history_add(snac *snac, char *id, char *content, int size); |
| 87 | d_char *history_get(snac *snac, char *id); | 87 | d_char *history_get(snac *snac, char *id); |
| 88 | int history_del(snac *snac, char *id); | 88 | int history_del(snac *snac, char *id); |
| 89 | d_char *history_list(snac *snac); | ||
| 89 | 90 | ||
| 90 | void enqueue_input(snac *snac, char *msg, char *req, int retries); | 91 | void enqueue_input(snac *snac, char *msg, char *req, int retries); |
| 91 | void enqueue_output(snac *snac, char *msg, char *actor, int retries); | 92 | void enqueue_output(snac *snac, char *msg, char *actor, int retries); |