summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/html.c b/html.c
index 4109929..c56f4cb 100644
--- a/html.c
+++ b/html.c
@@ -2560,35 +2560,48 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2560 status = 401; 2560 status = 401;
2561 } 2561 }
2562 else { 2562 else {
2563 double t = history_mtime(&snac, "timeline.html_"); 2563 char *q = xs_dict_get(q_vars, "q");
2564 2564
2565 /* if enabled by admin, return a cached page if its timestamp is: 2565 if (q && *q) {
2566 a) newer than the timeline timestamp 2566 /* search by content */
2567 b) newer than the start time of the server 2567 int to = 0;
2568 */ 2568 xs *tl = content_search(&snac, q, 1, 0, show, &to);
2569 if (cache && t > timeline_mtime(&snac) && t > p_state->srv_start_time) {
2570 snac_debug(&snac, 1, xs_fmt("serving cached timeline"));
2571 2569
2572 status = history_get(&snac, "timeline.html_", body, b_size, 2570 *body = html_timeline(&snac, tl, 0, 0, show, 0, NULL, "/admin", 1);
2573 xs_dict_get(req, "if-none-match"), etag); 2571 *b_size = strlen(*body);
2572 status = 200;
2574 } 2573 }
2575 else { 2574 else {
2576 snac_debug(&snac, 1, xs_fmt("building timeline")); 2575 double t = history_mtime(&snac, "timeline.html_");
2577 2576
2578 xs *list = timeline_list(&snac, "private", skip, show); 2577 /* if enabled by admin, return a cached page if its timestamp is:
2579 xs *next = timeline_list(&snac, "private", skip + show, 1); 2578 a) newer than the timeline timestamp
2579 b) newer than the start time of the server
2580 */
2581 if (cache && t > timeline_mtime(&snac) && t > p_state->srv_start_time) {
2582 snac_debug(&snac, 1, xs_fmt("serving cached timeline"));
2580 2583
2581 xs *pins = pinned_list(&snac); 2584 status = history_get(&snac, "timeline.html_", body, b_size,
2582 pins = xs_list_cat(pins, list); 2585 xs_dict_get(req, "if-none-match"), etag);
2586 }
2587 else {
2588 snac_debug(&snac, 1, xs_fmt("building timeline"));
2583 2589
2584 *body = html_timeline(&snac, pins, 0, skip, show, 2590 xs *list = timeline_list(&snac, "private", skip, show);
2585 xs_list_len(next), NULL, "/admin", 1); 2591 xs *next = timeline_list(&snac, "private", skip + show, 1);
2586 2592
2587 *b_size = strlen(*body); 2593 xs *pins = pinned_list(&snac);
2588 status = 200; 2594 pins = xs_list_cat(pins, list);
2595
2596 *body = html_timeline(&snac, pins, 0, skip, show,
2597 xs_list_len(next), NULL, "/admin", 1);
2589 2598
2590 if (save) 2599 *b_size = strlen(*body);
2591 history_add(&snac, "timeline.html_", *body, *b_size, etag); 2600 status = 200;
2601
2602 if (save)
2603 history_add(&snac, "timeline.html_", *body, *b_size, etag);
2604 }
2592 } 2605 }
2593 } 2606 }
2594 } 2607 }