mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Implemented local timeline cache.
This commit is contained in:
parent
d29c00bd8f
commit
20fd70c011
2 changed files with 20 additions and 6 deletions
4
TODO.md
4
TODO.md
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
## Open
|
## Open
|
||||||
|
|
||||||
Implement the user-setup web interface.
|
|
||||||
|
|
||||||
Implement the citations as @user@host in the reply textareas.
|
Implement the citations as @user@host in the reply textareas.
|
||||||
|
|
||||||
Implement the purge.
|
Implement the purge.
|
||||||
|
@ -143,3 +141,5 @@ Implement an input queue (2022-10-01T20:27:52+0200).
|
||||||
Refactor HTML rendering because it's a mess and write build_timeline(), that generates a big structure with everything to show in a timeline, to be passed to the HTML renderer (2022-10-01T20:27:52+0200).
|
Refactor HTML rendering because it's a mess and write build_timeline(), that generates a big structure with everything to show in a timeline, to be passed to the HTML renderer (2022-10-01T20:27:52+0200).
|
||||||
|
|
||||||
Implement the helper thread (2022-10-01T20:56:46+0200).
|
Implement the helper thread (2022-10-01T20:56:46+0200).
|
||||||
|
|
||||||
|
Implement the user-setup web interface (2022-10-02T17:45:03+0200).
|
||||||
|
|
14
html.c
14
html.c
|
@ -8,6 +8,7 @@
|
||||||
#include "xs_regex.h"
|
#include "xs_regex.h"
|
||||||
#include "xs_set.h"
|
#include "xs_set.h"
|
||||||
#include "xs_openssl.h"
|
#include "xs_openssl.h"
|
||||||
|
#include "xs_time.h"
|
||||||
|
|
||||||
#include "snac.h"
|
#include "snac.h"
|
||||||
|
|
||||||
|
@ -753,11 +754,24 @@ int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char *
|
||||||
|
|
||||||
if (p_path == NULL) {
|
if (p_path == NULL) {
|
||||||
/* public timeline */
|
/* public timeline */
|
||||||
|
xs *h = xs_str_localtime(0, "%Y-%m.html");
|
||||||
|
|
||||||
|
if (history_mtime(&snac, h) > timeline_mtime(&snac)) {
|
||||||
|
snac_debug(&snac, 1, xs_fmt("serving cached local timeline"));
|
||||||
|
|
||||||
|
*body = history_get(&snac, h);
|
||||||
|
*b_size = strlen(*body);
|
||||||
|
status = 200;
|
||||||
|
}
|
||||||
|
else {
|
||||||
xs *list = local_list(&snac, 0xfffffff);
|
xs *list = local_list(&snac, 0xfffffff);
|
||||||
|
|
||||||
*body = html_timeline(&snac, list, 1);
|
*body = html_timeline(&snac, list, 1);
|
||||||
*b_size = strlen(*body);
|
*b_size = strlen(*body);
|
||||||
status = 200;
|
status = 200;
|
||||||
|
|
||||||
|
history_add(&snac, h, *body, *b_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(p_path, "admin") == 0) {
|
if (strcmp(p_path, "admin") == 0) {
|
||||||
|
|
Loading…
Reference in a new issue