feat(lander): show filenames on index pages
ci/woodpecker/push/build Pipeline was successful Details

Jef Roosens 2024-02-19 21:44:24 +01:00
parent f789847fc5
commit a68e32c949
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 14 additions and 3 deletions

View File

@ -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));

View File

@ -25,7 +25,7 @@ const char *index_template =
"<!doctype html>\n"
"<body>\n"
"<h1>Index /{{ title_key }}</h1>\n"
"<h2>Redirects</h2>"
"<h2>Redirects</h2>\n"
"<ul>\n"
"{{ redirect start }}\n"
"<li><a href=\"/{{ full_key }}\">{{ short_key }}</a></li>\n"
@ -37,6 +37,12 @@ const char *index_template =
"<li><a href=\"/{{ full_key }}\">{{ filename }}</a></li>\n"
"{{ file end }}\n"
"</ul>\n"
"<h2>Pastes</h2>\n"
"<ul>\n"
"{{ paste start }}\n"
"<li><a href=\"/{{ full_key }}\">{{ filename }}</a></li>\n"
"{{ paste end }}\n"
"</ul>\n"
"</body>\n";
lnm_http_loop *loop_init(lander_gctx *gctx, const char *api_key) {