diff options
author | default <nobody@localhost> | 2024-05-09 10:04:45 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2024-05-09 10:04:45 +0200 |
commit | a5766a6c83662efeb9544ab4a14ea4bfa33c5344 (patch) | |
tree | f955c4d7876860df266fd1630be039085848e4fb /html.c | |
parent | 7b0e9285af8ec0f4f4de48e43bf46e8bb1741ae9 (diff) |
The /admin page now accepts ?q=regex for a content search.
Diffstat (limited to 'html.c')
-rw-r--r-- | html.c | 53 |
1 files changed, 33 insertions, 20 deletions
@@ -2560,35 +2560,48 @@ int html_get_handler(const xs_dict *req, const char *q_path, status = 401; } else { - double t = history_mtime(&snac, "timeline.html_"); + char *q = xs_dict_get(q_vars, "q"); - /* if enabled by admin, return a cached page if its timestamp is: - a) newer than the timeline timestamp - b) newer than the start time of the server - */ - if (cache && t > timeline_mtime(&snac) && t > p_state->srv_start_time) { - snac_debug(&snac, 1, xs_fmt("serving cached timeline")); + if (q && *q) { + /* search by content */ + int to = 0; + xs *tl = content_search(&snac, q, 1, 0, show, &to); - status = history_get(&snac, "timeline.html_", body, b_size, - xs_dict_get(req, "if-none-match"), etag); + *body = html_timeline(&snac, tl, 0, 0, show, 0, NULL, "/admin", 1); + *b_size = strlen(*body); + status = 200; } else { - snac_debug(&snac, 1, xs_fmt("building timeline")); + double t = history_mtime(&snac, "timeline.html_"); - xs *list = timeline_list(&snac, "private", skip, show); - xs *next = timeline_list(&snac, "private", skip + show, 1); + /* if enabled by admin, return a cached page if its timestamp is: + a) newer than the timeline timestamp + b) newer than the start time of the server + */ + if (cache && t > timeline_mtime(&snac) && t > p_state->srv_start_time) { + snac_debug(&snac, 1, xs_fmt("serving cached timeline")); - xs *pins = pinned_list(&snac); - pins = xs_list_cat(pins, list); + status = history_get(&snac, "timeline.html_", body, b_size, + xs_dict_get(req, "if-none-match"), etag); + } + else { + snac_debug(&snac, 1, xs_fmt("building timeline")); - *body = html_timeline(&snac, pins, 0, skip, show, - xs_list_len(next), NULL, "/admin", 1); + xs *list = timeline_list(&snac, "private", skip, show); + xs *next = timeline_list(&snac, "private", skip + show, 1); - *b_size = strlen(*body); - status = 200; + xs *pins = pinned_list(&snac); + pins = xs_list_cat(pins, list); + + *body = html_timeline(&snac, pins, 0, skip, show, + xs_list_len(next), NULL, "/admin", 1); - if (save) - history_add(&snac, "timeline.html_", *body, *b_size, etag); + *b_size = strlen(*body); + status = 200; + + if (save) + history_add(&snac, "timeline.html_", *body, *b_size, etag); + } } } } |