From a68e32c949989b30b28d3ee00c405aacaa307a69 Mon Sep 17 00:00:00 2001 From: Chewing_Bever Date: Mon, 19 Feb 2024 21:44:24 +0100 Subject: [PATCH] feat(lander): show filenames on index pages --- src/lander/lander_get.c | 9 +++++++-- src/main.c | 8 +++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/lander/lander_get.c b/src/lander/lander_get.c index d9b47c9..1cbc772 100644 --- a/src/lander/lander_get.c +++ b/src/lander/lander_get.c @@ -190,14 +190,19 @@ lnm_http_step_err lander_get_index(lnm_http_conn *conn) { lsm_str_len(entry_key) - prefix_len); break; case lander_entry_type_file: - ltm_instance_block_add_nested(&nested, c_ctx->instance, "file"); + case lander_entry_type_paste: + ltm_instance_block_add_nested(&nested, c_ctx->instance, + t == lander_entry_type_file ? "file" + : "paste"); ltm_instance_block_add_var( nested, "full_key", ltm_instance_block_type_buf, (void *)lsm_str_ptr(entry_key), lsm_str_len(entry_key)); + // Add the filename as the link name if known, or just the key otherwise lsm_str *filename; - if (lsm_entry_attr_get(&filename, handle, lander_attr_type_file_name)) { + if (lsm_entry_attr_get(&filename, handle, lander_attr_type_file_name) == + lsm_error_ok) { ltm_instance_block_add_var( nested, "filename", ltm_instance_block_type_buf, (void *)lsm_str_ptr(filename), lsm_str_len(filename)); diff --git a/src/main.c b/src/main.c index 351db58..c2dea68 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,7 @@ const char *index_template = "\n" "\n" "

Index /{{ title_key }}

\n" - "

Redirects

" + "

Redirects

\n" "\n" + "

Pastes

\n" + "\n" "\n"; lnm_http_loop *loop_init(lander_gctx *gctx, const char *api_key) {