Fixes #54. Adds configuration option 'fancyindex_show_dotfiles' to show dotfiles.

pull/83/head
Joshua Shaffer 2020-05-17 16:11:25 -04:00 committed by Adrian Perez
parent 11101de198
commit 94bb8164b2
1 changed files with 35 additions and 25 deletions

View File

@ -152,9 +152,10 @@ typedef struct {
ngx_flag_t localtime; /**< File mtime dates are sent in local time. */
ngx_flag_t exact_size; /**< Sizes are sent always in bytes. */
ngx_uint_t name_length; /**< Maximum length of file names in bytes. */
ngx_flag_t hide_symlinks;/**< Hide symbolic links in listings. */
ngx_flag_t hide_symlinks; /**< Hide symbolic links in listings. */
ngx_flag_t show_path; /**< Whether to display or not the path + '</h1>' after the header */
ngx_flag_t hide_parent; /**< Hide parent directory. */
ngx_flag_t show_dot_files; /**< Show files that start with a dot.*/
ngx_str_t header; /**< File name for header, or empty if none. */
ngx_str_t footer; /**< File name for footer, or empty if none. */
@ -362,6 +363,13 @@ static ngx_command_t ngx_http_fancyindex_commands[] = {
offsetof(ngx_http_fancyindex_loc_conf_t, show_path),
NULL },
{ ngx_string("fancyindex_show_dotfiles"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fancyindex_loc_conf_t, show_dot_files),
NULL },
{ ngx_string("fancyindex_hide_parent_dir"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
@ -654,7 +662,7 @@ make_content_buf(
len = ngx_de_namelen(&dir);
if (ngx_de_name(&dir)[0] == '.')
if (!alcf->show_dot_files && ngx_de_name(&dir)[0] == '.')
continue;
if (alcf->hide_symlinks && ngx_de_is_link (&dir))
@ -1333,6 +1341,7 @@ ngx_http_fancyindex_create_loc_conf(ngx_conf_t *cf)
conf->hide_symlinks = NGX_CONF_UNSET;
conf->show_path = NGX_CONF_UNSET;
conf->hide_parent = NGX_CONF_UNSET;
conf->show_dot_files = NGX_CONF_UNSET;
return conf;
}
@ -1352,6 +1361,7 @@ ngx_http_fancyindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->localtime, prev->localtime, 0);
ngx_conf_merge_value(conf->exact_size, prev->exact_size, 1);
ngx_conf_merge_value(conf->show_path, prev->show_path, 1);
ngx_conf_merge_value(conf->show_dot_files, prev->show_dot_files, 0);
ngx_conf_merge_uint_value(conf->name_length, prev->name_length, 50);
ngx_conf_merge_str_value(conf->header, prev->header, "");