Make the configuration process load the local files specified with
'fancyindex_{header,footer} "foo" local', instead of loading them
on every request.
Additionally, change the syntax of the configuration directive to accept
an optional parameter indicating whether the header (or footer) is to be
loaded as a subrequest (default, for backwards compatibility) or a local
file (must be specified explicitly). This avoids the footgun of having
a local file which accidentally happens to match the subrequest that one
had the intention to do when configuring.
Instead of directly return the difference of the sizes from the
comparison functions, use the relational operators, as suggested by
Chris Young (thanks!).
Fixes#74
The fancyindex_directories_first directive allows one to enable or
disable grouping directories first before all files when sorting.
This is accomplished by changing the sort function from ngx_qsort (which
is the plain stdlib qsort under the hood) to ngx_sort which is a stable
insertion sort (per ngx_string.c).
We call ngx_sort with the standard sort_cmp_func (albeit modified to remove
grouping dirs), and then, if fancyindex_directories_first is set, call
ngx_sort again with ngx_http_fancyindex_cmp_entries_dirs_first which sorts
entries according to the directories first criterion.
Because a stable sorting function is used, the relative primary order is
preserved when we call ngx_sort again.
Change int (*sort_cmp_func) (const void*, const void*) to ngx_int_t
(*sort_cmp_func) (const void*, const void*) to satisfy ngx_sort.
This directive enables someone using a custom header to disable the output of the indexed directory by the module
Useful when you want to create links to previous directories via PHP for example
This attempts to address hanging requests when fancyindex is
combined with ngx_pagespeed. The change makes fancyindex check
the return value of ngx_http_send_header in a way that is just
the same as nginx's autoindex module - which makes the modules
work for me when I test with ngx_pagespeed.
The value for fancyindex_css_href was not being propagated properly, so
overriding its value did not work as expected. For example the following
configuration:
http {
# ...
fancyindex_css_href "/css/global.css";
location /subdir/ {
fancyindex_css_href "/css/local.css";
}
}
would always use "global.css", even when accessing file listings under
"/subdir".
This patch fixes the issue.
This patch adds a new configuration directive fancyindex_time_format, which
accepts a strftime()-style format string used to format the timestamps in the
generated listings. The accepted format specifiers are an useful subset of
those supported by strftime(), but the libc function is not used to make the
output of the module stable and locale-independent.
This fixes issue #23.
This adds a new "fancyindex_hide_symlinks" configuration flag, which will
filter out symbolic links from the generated file listings when enabled.
Feature suggested by Peter Wemm (https://github.com/DarkHelmet433)
Fixes issue #27
If fancy indexing is used at the root of a webserver, it will still display
a "Parent Directory" link even when listing the webserver's root. This should
not happen as it outputs a useless link.
There is almost universal support for the CSS3
:nth-child() pseudo-selector. We're shifting the
responsibility for labeling even and odd rows to
the browser.
If a sorting criteria different than the default is used, carry the URL
arguments to the links pointing to other directories, so the sorting is
"remembered" when navigating across different directories.
When choosing different sorting criteria for the elements (with the "?C=x"
URL argument), allow also specifying a second "O=x" argument for the
direction: "?C=x&O=A" selects ascending direction, while "?C=x&O=D" chooses
descending direction.
This introduces Apache-style URL arguments to specify how to sort the
entries in the generated listings:
- Appending "?C=M" sorts by modification time (mtime).
- Appending "?C=S" sorts by file size.
- Any other (or no arguments) use the default sorting, by name.
When issuing subrequests (currently for non-builtin headers and footers),
initialize the headers_out.status field to NGX_OK.
Also, change the check of the result from ngx_http_send_header() to only
check for NGX_OK, as it is redundant to check it and also NGX_ERROR.
Unfortunately ngx_escape_uri() does not properly escape all characters
that may be problematic in URIs, so apart from doing a first pass with
ngx_escape_uri(), it is needed to do a second pass for escaping the rest
of characters.
Thanks to Steve Willing <eiji-gravion@hotmail.com> for reporting the issue.
Adds a new "fancyindex_ignore string1 [string2 [... stringN]]" directive
which sets a lists of files which are not to be shown in generated listings.
If Nginx is built with PCRE support, strings are interpreted as regular
expressions, and files which match one of the regular expressions in this
list will not be sent in listings.
This allows for inserting a <link> tag in the generated listings pointing to
an additional CSS stylesheet, which will be applied by the browser after the
built-in rules. This allows for super-easy customization of the output look.
Sergey A. Osokin provided this small improvement for the his previous patch
regarding the "zero_in_uri" being absent in newer development versions of
Nginx.
Signed-off-by: Adrian Perez <aperez@igalia.com>