From fa997aa2c153cef50941b4d4036694485259ac2a Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 23 Apr 2023 05:19:27 +0200 Subject: Implement file previews When using HTTP "Content-Disposition: attachment;", users are forced to download files in order to use them, whereas others might prefer to open them in the browser. Therefore, now that URL parameters are supported by http.h, previews can be forced by adding "preview=1" or "preview=true" (case-insensitive) as a URL parameters. Any other parameters are ignored by slcl. For users, a "Preview" link has been added next to the "Share" button for each file. --- main.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 66328a8..7fca16d 100644 --- a/main.c +++ b/main.c @@ -700,14 +700,20 @@ static int getnode(const struct http_payload *const p, goto end; } - const struct page_quota *const ppq = available ? - &(const struct page_quota) - { - .cur = cur, - .max = max - } : NULL; + const struct page_resource pr = + { + .r = r, + .args = p->args, + .n_args = p->n_args, + .dir = dir.str, + .root = root.str, + .res = d.str, + .q = available ? + &(const struct page_quota) {.cur = cur, .max = max } + : NULL + }; - ret = page_resource(r, dir.str, root.str, d.str, ppq); + ret = page_resource(&pr); end: dynstr_free(&dir); -- cgit v1.2.3