diff options
| -rw-r--r-- | data.c | 8 | ||||
| -rw-r--r-- | html.c | 24 | ||||
| -rw-r--r-- | snac.h | 4 |
3 files changed, 36 insertions, 0 deletions
| @@ -1528,6 +1528,14 @@ xs_list *timeline_list(snac *snac, const char *idx_name, int skip, int show, int | |||
| 1528 | } | 1528 | } |
| 1529 | 1529 | ||
| 1530 | 1530 | ||
| 1531 | void timeline_add_mark(snac *user) | ||
| 1532 | /* adds an "already seen" mark to the private timeline */ | ||
| 1533 | { | ||
| 1534 | xs *fn = xs_fmt("%s/private.idx", user->basedir); | ||
| 1535 | index_add_md5(fn, MD5_ALREADY_SEEN_MARK); | ||
| 1536 | } | ||
| 1537 | |||
| 1538 | |||
| 1531 | xs_str *instance_index_fn(void) | 1539 | xs_str *instance_index_fn(void) |
| 1532 | { | 1540 | { |
| 1533 | return xs_fmt("%s/public.idx", srv_basedir); | 1541 | return xs_fmt("%s/public.idx", srv_basedir); |
| @@ -2648,10 +2648,31 @@ xs_str *html_timeline(snac *user, const xs_list *list, int read_only, | |||
| 2648 | xs_html_add(body, | 2648 | xs_html_add(body, |
| 2649 | posts); | 2649 | posts); |
| 2650 | 2650 | ||
| 2651 | int mark_shown = 0; | ||
| 2652 | |||
| 2651 | while (xs_list_iter(&p, &v)) { | 2653 | while (xs_list_iter(&p, &v)) { |
| 2652 | xs *msg = NULL; | 2654 | xs *msg = NULL; |
| 2653 | int status; | 2655 | int status; |
| 2654 | 2656 | ||
| 2657 | /* "already seen" mark? */ | ||
| 2658 | if (strcmp(v, MD5_ALREADY_SEEN_MARK) == 0) { | ||
| 2659 | if (skip == 0 && !mark_shown) { | ||
| 2660 | xs *s = xs_fmt("%s/admin#top", user->actor); | ||
| 2661 | |||
| 2662 | xs_html_add(posts, | ||
| 2663 | xs_html_text(L("No more unseen posts")), | ||
| 2664 | xs_html_text(" - "), | ||
| 2665 | xs_html_tag("a", | ||
| 2666 | xs_html_attr("href", s), | ||
| 2667 | xs_html_text(L("Back to top"))), | ||
| 2668 | xs_html_sctag("hr", NULL)); | ||
| 2669 | } | ||
| 2670 | |||
| 2671 | mark_shown = 1; | ||
| 2672 | |||
| 2673 | continue; | ||
| 2674 | } | ||
| 2675 | |||
| 2655 | if (utl && user && !is_pinned_by_md5(user, v)) | 2676 | if (utl && user && !is_pinned_by_md5(user, v)) |
| 2656 | status = timeline_get_by_md5(user, v, &msg); | 2677 | status = timeline_get_by_md5(user, v, &msg); |
| 2657 | else | 2678 | else |
| @@ -3473,6 +3494,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3473 | } | 3494 | } |
| 3474 | } | 3495 | } |
| 3475 | else { | 3496 | else { |
| 3497 | /** the private timeline **/ | ||
| 3476 | double t = history_mtime(&snac, "timeline.html_"); | 3498 | double t = history_mtime(&snac, "timeline.html_"); |
| 3477 | 3499 | ||
| 3478 | /* if enabled by admin, return a cached page if its timestamp is: | 3500 | /* if enabled by admin, return a cached page if its timestamp is: |
| @@ -3492,6 +3514,8 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 3492 | 3514 | ||
| 3493 | xs *list = timeline_list(&snac, "private", skip, show, &more); | 3515 | xs *list = timeline_list(&snac, "private", skip, show, &more); |
| 3494 | 3516 | ||
| 3517 | timeline_add_mark(&snac); | ||
| 3518 | |||
| 3495 | *body = html_timeline(&snac, list, 0, skip, show, | 3519 | *body = html_timeline(&snac, list, 0, skip, show, |
| 3496 | more, NULL, "/admin", 1, error); | 3520 | more, NULL, "/admin", 1, error); |
| 3497 | 3521 | ||
| @@ -22,6 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | #define MD5_HEX_SIZE 33 | 23 | #define MD5_HEX_SIZE 33 |
| 24 | 24 | ||
| 25 | #define MD5_ALREADY_SEEN_MARK "00000000000000000000000000000000" | ||
| 26 | |||
| 25 | extern double disk_layout; | 27 | extern double disk_layout; |
| 26 | extern xs_str *srv_basedir; | 28 | extern xs_str *srv_basedir; |
| 27 | extern xs_dict *srv_config; | 29 | extern xs_dict *srv_config; |
| @@ -163,6 +165,8 @@ int timeline_add(snac *snac, const char *id, const xs_dict *o_msg); | |||
| 163 | int timeline_admire(snac *snac, const char *id, const char *admirer, int like); | 165 | int timeline_admire(snac *snac, const char *id, const char *admirer, int like); |
| 164 | 166 | ||
| 165 | xs_list *timeline_top_level(snac *snac, const xs_list *list); | 167 | xs_list *timeline_top_level(snac *snac, const xs_list *list); |
| 168 | void timeline_add_mark(snac *user); | ||
| 169 | |||
| 166 | xs_list *local_list(snac *snac, int max); | 170 | xs_list *local_list(snac *snac, int max); |
| 167 | xs_str *instance_index_fn(void); | 171 | xs_str *instance_index_fn(void); |
| 168 | xs_list *timeline_instance_list(int skip, int show); | 172 | xs_list *timeline_instance_list(int skip, int show); |