From 2e04b2c23c66a42372d0ecaea2b0f4b2c7b7c7e5 Mon Sep 17 00:00:00 2001 From: Vincent Douillet Date: Tue, 24 Dec 2024 11:52:50 +0100 Subject: delete files --- browse.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'browse.c') diff --git a/browse.c b/browse.c index be72e34..5bda651 100644 --- a/browse.c +++ b/browse.c @@ -197,7 +197,8 @@ header_template_callback(size_t index, void *arg) return 1; } -static const char *const file_template_keys[] = {"icon", "name", "url", "size"}; +static const char *const file_template_keys[] = {"icon", "name", "url", "size", +"delete_url"}; static int file_template_callback(size_t index, void *arg) @@ -253,6 +254,16 @@ file_template_callback(size_t index, void *arg) size_read[i - 1]), r); } break; + case 4: + /* delete url */ + if (build_delete_url(r, data->f) == 0) { + kutil_warnx(r, NULL, + "unable to build delete url for file %s", + data->f->path); + break; + } + K_OK(khtml_puts(html, data->f->action_url), r); + break; default: kutil_warnx(r, NULL, "Invalid key index for browse file template: %zd", @@ -352,7 +363,7 @@ browse(struct kreq * r) /* print file list */ template.key = file_template_keys; - template.keysz = 4; + template.keysz = 5; template.cb = file_template_callback; SLIST_FOREACH(file, &list, files) { -- cgit v1.2.3