Commit Graph

86 Commits (4fc6bb10d7ac19a8cdaf6c811382f3b93712bd14)

Author SHA1 Message Date
Adrian Perez de Castro 527511fbf8 Load local header and footer files when configuring
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.
2020-10-24 18:52:58 +03:00
JoungKyun Kim 5ac161ccc3 fixed #82 fancyindex can't print list with auth-ldap module
- fixed signedness problems
- fixed gabage characters
2020-10-24 18:34:41 +03:00
Adrian Perez de Castro 140dcb7a8f Properly escape square brackets with old Nginx versions 2020-10-24 15:40:07 +03:00
z4yx b3e06fd31b remove ngx_http_fancyindex_cmp_entries_dirs_first 2020-10-24 13:17:10 +03:00
z4yx c0448985b6 ngx_int_t -> int 2020-10-24 13:17:10 +03:00
z4yx a05006e3c4 replace ngx_sort with ngx_qsort 2020-10-24 13:17:10 +03:00
Joshua Shaffer 94bb8164b2 Fixes #54. Adds configuration option 'fancyindex_show_dotfiles' to show dotfiles. 2020-05-26 16:14:09 +03:00
Anders Trier 21a084d61d Add CRLF after the 'Parent directory' line. This makes the output easier to parse. 2020-02-19 12:44:32 +02:00
kPherox 47ce20d993 refs aperezdc/ngx-fancyindex#57 Add `fancyindex_hide_parent_dir` directive 2018-10-15 11:28:09 +02:00
Adrian Perez de Castro 473c1de024 Properly encode filenames as URI components
Fixes #95
2018-08-30 00:12:47 +03:00
qjqqyy 2b2244551f Fix decreasing sort by file size
fixes #77
2018-07-03 02:39:57 +03:00
gznyirfa 60c4338b96 add html class names to table cells for better css formatting options 2018-03-21 17:13:50 +00:00
Adrian Perez de Castro c1b1be3615 Fix sorting by file size for sizes bigger than INT_MAX
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
2017-08-19 00:09:41 +03:00
cat a551b5e3ea Fix segfaults when opening directories with empty files
Apparently ngx_sprintf does not tolerate format specifiers
not matching their corresponding argument types.
2016-12-08 15:15:59 +05:00
Anders Trier 1e438a694d Add decimal to file sizes 2016-11-04 01:31:05 +02:00
Luke Zapart 2fa65b05f1
Add fancyindex_directories_first config directive.
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.
2016-08-18 00:36:24 +03:00
Thomas P cb3d21157b Add the 'show_path' configuration directive
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
2016-02-13 15:37:54 +01:00
Adrian Perez 945f87c644 Merge pull request #31 from janglapuk/master
Add title attribute for each dir or file
2016-02-10 15:54:04 +02:00
Otto van der Schaaf 1450c1b4d5 Fix hang when combining fancyindex with ngx_pagespeed
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.
2016-02-10 13:15:30 +01:00
Adrián Pérez de Castro 61f091aeb8 Update year to 2016 in copyright header 2016-01-26 18:52:54 +02:00
YeahO_O Yuan bbd0300488 Fix Windows builds
Suppress warnings for:
* non-ascii character;
* non-constant aggregate initializer;
* assignment within conditional expression;
* return value type mismatch.
2016-01-25 19:45:06 +08:00
janglapuk 07c4288e64 Added title attribute for each dir or file 2015-08-30 10:29:30 +08:00
Peter Wemm e5deb93745 Fix typo in fancyindex_hide_symlinks that causes a crash. 2015-08-16 21:18:13 -07:00
Adrian Perez de Castro 3f93d1f01d Fix propagation of fancyindex_css_href configuration directive
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.
2015-08-17 00:20:53 +03:00
Adrian Perez de Castro 5549286d39 Mark unused variables to avoid compiler warnings/errors
This avoids the compiler complaning when warnings for unused variables are
enabled.
2015-08-17 00:15:25 +03:00
Adrian Perez de Castro 13170fb6e6 Fix a couple of code style and indentation issues 2015-08-17 00:14:53 +03:00
Adrian Perez de Castro 5599bbebba Allow specifying timestamp format with fancyindex_time_format
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.
2015-08-16 23:54:32 +03:00
Adrian Perez de Castro fd0bbd7fb8 Fix indentation and spacing 2015-08-16 17:22:19 +03:00
Adrian Perez de Castro cf8197c991 Fix initializer of fancyindex_hide_symlinks flag definition 2015-08-16 17:21:31 +03:00
Adrian Perez de Castro 42d10a2a24 Add option to hide symbolic links from generated listings
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
2015-08-16 13:08:04 +03:00
Thomas P 97987a45e4 Do not display the parent dir link at the root
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.
2015-08-16 02:27:37 +03:00
Martin Herkt dc64f24bbc Make file name length limit configurable 2015-02-19 13:10:27 +01:00
Mim 7a07987ad3 Make sorting criterion configurable 2015-02-19 13:06:27 +01:00
Anthony Ryan da3f7ea17d Shift table stlying details onto the client
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.
2014-06-02 09:02:24 -04:00
Adrian Perez de Castro ea30f7fb21 Preserve URL sorting arguments on directory links
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.
2013-10-25 13:00:10 +03:00
Adrian Perez de Castro 1226d363be Support changing the sort direction of elements
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.
2013-10-24 21:45:18 +03:00
Adrian Perez de Castro d78536c9a4 Support sorting files using mtime or size
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.
2013-10-24 17:38:48 +03:00
Adrian Perez de Castro 6cf0bf8ad8 Update copyright header 2013-06-05 11:38:34 +03:00
David\ Beitey aba75b3c45 Ensure fancyindex is sending NGX_HTTP_OK (200) as the status vs HTTP_OK which is 0. Without this, connections sit waiting forever. 2013-04-19 11:10:44 +10:00
Adrian Perez 2034d0ad35 Initialize headers_out.status to NGX_OK and improve error check
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.
2012-03-14 22:30:26 +02:00
Stefan Rubner ea6323f92c Ooops. Didn't fix the actual check but just added the comment instead. Fixed. 2012-03-14 00:29:11 +01:00
Stefan Rubner 07614d5abe Fixed the wrong status code check when including header/footer in NGinx 1.1.16
where ngx_http_subrequests returns NGX_OK (0) and not NGX_HTTP_OK (200) on a
successful completion of the subrequest.
2012-03-08 23:49:32 +01:00
Adrian Perez 44805008d0 Use "ngx_inline" instead of plain "inline"
This should improve compatibility with some particular compilers
2012-01-18 00:23:02 +02:00
Adrian Perez 42d2f1b1f7 Properly escape ':' and '?' in generated hrefs
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.
2011-04-04 03:46:51 +03:00
Adrian Perez d8e0bdaef2 Update e-mail address and copyright headers 2011-04-03 00:22:59 +03:00
Adrian Perez 2f138afb70 Implement fancyindex_ignore configuration directive
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.
2010-09-09 16:42:46 +02:00
Sergey A. Osokin 3d1c14f162 Fix incompatibility with Nginx 0.7.66
Adds a couple of additional version checks to make the module compatible
with Nginx 0.7.66.

Signed-off-by: Adrian Perez <aperez@igalia.com>
2010-06-10 18:38:45 +02:00
Adrian Perez 4b19f3a73f Add fancyindex_css_href configuration option
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.
2010-06-10 16:56:31 +02:00
Sergey A. Osokin f465a2bcd6 Small improvement over previous patch
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>
2010-06-07 02:14:41 +02:00
Sergey A. Osokin d54092b842 Fix build with latest development versions of Nginx
The zero_in_uri member of the request structure does not longer exist, so
removed a reference to it.

Signed-off-by: Adrian Perez <aperez@igalia.com>
2010-06-03 22:08:59 +02:00