diff options
Diffstat (limited to 'browse.c')
-rw-r--r-- | browse.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -41,6 +41,7 @@ #include "browse.h" #include "cgi.h" #include "config.h" +#include "create.h" #include "download.h" #include "file.h" #include "http.h" @@ -164,7 +165,7 @@ struct template_data { struct file *f; }; -static const char *const header_template_keys[] = {"upload_url"}; +static const char *const header_template_keys[] = {"upload_url", "create_url"}; static int header_template_callback(size_t index, void *arg) @@ -185,7 +186,21 @@ header_template_callback(size_t index, void *arg) switch (index) { case 0: /* upload_url */ - K_OK(khtml_puts(html, data->f->action_url), r); + if (build_upload_url(r, data->f) > 0) { + K_OK(khtml_puts(html, data->f->action_url), r); + } else + kutil_warnx(r, NULL, + "failed to build upload URL for path %s", + data->f->path); + break; + case 1: + /* create_url */ + if (build_create_url(r, data->f) > 0) { + K_OK(khtml_puts(html, data->f->action_url), r); + } else + kutil_warnx(r, NULL, + "failed to build create URL for path %s", + data->f->path); break; default: kutil_warnx(r, NULL, @@ -302,10 +317,6 @@ browse(struct kreq * r) http_exit(r, KHTTP_404, "browse: Invalid data file"); goto end; } - if (build_upload_url(r, file) == 0) { - http_exit(r, KHTTP_500, "browse: Can't build upload url"); - goto end; - } if (build_file_list(r, file) < 0) { http_exit(r, KHTTP_500, "browse: Unable to build file list"); goto end; @@ -325,7 +336,7 @@ browse(struct kreq * r) /* print browse header with action buttons for current dir */ template.key = header_template_keys; - template.keysz = 1; + template.keysz = 2; template.cb = header_template_callback; template.arg = &data; data.r = r; |