Added fancyindex_mode directive.

pull/4/head
Adrian Perez 18 years ago
parent 059d4a8811
commit c2f086207b

23
.todo

@ -0,0 +1,23 @@
<todo version="0.1.19">
<note priority="medium" time="1187975642">
readme:iframe
</note>
<note priority="medium" time="1187975645">
readme:div
</note>
<note priority="medium" time="1187975648">
readme:pre
</note>
<note priority="medium" time="1187975662">
header:inline
</note>
<note priority="medium" time="1187975665">
header:cache
</note>
<note priority="medium" time="1187975708">
footer:inline
</note>
<note priority="medium" time="1187975712">
footer:cache
</note>
</todo>

@ -32,7 +32,7 @@ Building
4. Build and install the software:: 4. Build and install the software::
$ make $ make
And then, as ``root``:: And then, as ``root``::
# make install # make install
@ -130,6 +130,23 @@ fancyindex_readme_options
will instruct the client to perform an additional request in order to will instruct the client to perform an additional request in order to
fetch the contents of the frame. fetch the contents of the frame.
fancyindex_mode
:Syntax: *fancyindex_mode* *static* | *cached*
:Default: *fancyindex_mode static*
:Context: http, server, location
:Description:
Controls how to include the header and footer specified by
`fancyindex_header`_ and `fancyindex_footer`_, Available options are:
static
Read file contents on each request. This is the less efficient method,
but generated content will always follow on-disk changes of head and
footer templates.
cached
Header and footer contents will be read the first time they are
needed, and kept in memory for thei use in subsequent requests. If the
modification time of files changes, they will be re-read as needed.
.. _nginx: http://nginx.net .. _nginx: http://nginx.net

@ -36,13 +36,6 @@ typedef struct {
#endif #endif
#define NGX_HTTP_FANCYINDEX_README_TOP 0x00
#define NGX_HTTP_FANCYINDEX_README_PRE 0x00
#define NGX_HTTP_FANCYINDEX_README_ASIS 0x01
#define NGX_HTTP_FANCYINDEX_README_BOTTOM 0x02
#define NGX_HTTP_FANCYINDEX_README_DIV 0x04
#define NGX_HTTP_FANCYINDEX_README_IFRAME 0x08
typedef struct { typedef struct {
ngx_str_t name; ngx_str_t name;
@ -54,19 +47,39 @@ typedef struct {
} ngx_http_fancyindex_entry_t; } ngx_http_fancyindex_entry_t;
#define NGX_HTTP_FANCYINDEX_README_TOP 0x00
#define NGX_HTTP_FANCYINDEX_README_PRE 0x00
#define NGX_HTTP_FANCYINDEX_README_ASIS 0x01
#define NGX_HTTP_FANCYINDEX_README_BOTTOM 0x02
#define NGX_HTTP_FANCYINDEX_README_DIV 0x04
#define NGX_HTTP_FANCYINDEX_README_IFRAME 0x08
typedef enum {
NGX_HTTP_FANCYINDEX_INCLUDE_STATIC, /* Cache file contents on first request */
NGX_HTTP_FANCYINDEX_INCLUDE_CACHED, /* Cache file contents on first request,
and re-read if needed afterwards */
} ngx_http_fancyindex_include_mode_t;
typedef struct { typedef struct {
ngx_flag_t enable; ngx_flag_t enable;
ngx_flag_t localtime; ngx_flag_t localtime;
ngx_flag_t exact_size; ngx_flag_t exact_size;
ngx_str_t header;
ngx_str_t footer;
ngx_str_t readme;
ngx_str_t header; ngx_uint_t readme_flags;
ngx_str_t footer;
ngx_str_t readme;
ngx_uint_t readme_flags; ngx_http_fancyindex_include_mode_t include_mode;
} ngx_http_fancyindex_loc_conf_t; } ngx_http_fancyindex_loc_conf_t;
#define nfi_conf_path_set(_c, _n) ((_c)->((_n).len) > 0)
#define NGX_HTTP_FANCYINDEX_PREALLOCATE 50 #define NGX_HTTP_FANCYINDEX_PREALLOCATE 50
#define NGX_HTTP_FANCYINDEX_NAME_LEN 50 #define NGX_HTTP_FANCYINDEX_NAME_LEN 50
@ -82,7 +95,7 @@ static char *ngx_http_fancyindex_merge_loc_conf(ngx_conf_t *cf,
static ngx_conf_bitmask_t ngx_http_fancyindex_readme_flags[] = { static const ngx_conf_bitmask_t ngx_http_fancyindex_readme_flags[] = {
{ ngx_string("pre"), NGX_HTTP_FANCYINDEX_README_PRE }, { ngx_string("pre"), NGX_HTTP_FANCYINDEX_README_PRE },
{ ngx_string("asis"), NGX_HTTP_FANCYINDEX_README_ASIS }, { ngx_string("asis"), NGX_HTTP_FANCYINDEX_README_ASIS },
{ ngx_string("top"), NGX_HTTP_FANCYINDEX_README_TOP }, { ngx_string("top"), NGX_HTTP_FANCYINDEX_README_TOP },
@ -93,6 +106,14 @@ static ngx_conf_bitmask_t ngx_http_fancyindex_readme_flags[] = {
}; };
static const ngx_conf_enum_t ngx_http_fancyindex_include_modes[] = {
{ ngx_string("static"), NGX_HTTP_FANCYINDEX_INCLUDE_STATIC },
{ ngx_string("cached"), NGX_HTTP_FANCYINDEX_INCLUDE_CACHED },
{ ngx_null_string, 0 },
};
static ngx_command_t ngx_http_fancyindex_commands[] = { static ngx_command_t ngx_http_fancyindex_commands[] = {
{ ngx_string("fancyindex"), { ngx_string("fancyindex"),
@ -144,6 +165,13 @@ static ngx_command_t ngx_http_fancyindex_commands[] = {
offsetof(ngx_http_fancyindex_loc_conf_t, readme_flags), offsetof(ngx_http_fancyindex_loc_conf_t, readme_flags),
&ngx_http_fancyindex_readme_flags }, &ngx_http_fancyindex_readme_flags },
{ ngx_string("fancyindex_mode"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_enum_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fancyindex_loc_conf_t, include_mode),
&ngx_http_fancyindex_include_modes },
ngx_null_command ngx_null_command
}; };
@ -683,6 +711,7 @@ ngx_http_fancyindex_create_loc_conf(ngx_conf_t *cf)
conf->localtime = NGX_CONF_UNSET; conf->localtime = NGX_CONF_UNSET;
conf->exact_size = NGX_CONF_UNSET; conf->exact_size = NGX_CONF_UNSET;
conf->readme_flags = NGX_CONF_UNSET; conf->readme_flags = NGX_CONF_UNSET;
conf->include_mode = NGX_CONF_UNSET;
return conf; return conf;
} }
@ -697,6 +726,8 @@ ngx_http_fancyindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_value(conf->enable, prev->enable, 0); ngx_conf_merge_value(conf->enable, prev->enable, 0);
ngx_conf_merge_value(conf->localtime, prev->localtime, 0); 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->exact_size, prev->exact_size, 1);
ngx_conf_merge_uint_value(conf->include_mode, prev->include_mode,
NGX_HTTP_FANCYINDEX_INCLUDE_STATIC);
ngx_conf_merge_str_value(conf->header, prev->header, ""); ngx_conf_merge_str_value(conf->header, prev->header, "");
ngx_conf_merge_str_value(conf->footer, prev->footer, ""); ngx_conf_merge_str_value(conf->footer, prev->footer, "");

Loading…
Cancel
Save