feat(lander): show filenames on index pages
parent
e91631dd42
commit
24f7bba622
|
@ -175,14 +175,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));
|
||||
|
|
|
@ -24,7 +24,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"
|
||||
|
@ -36,6 +36,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) {
|
||||
|
|
Loading…
Reference in New Issue