Commit Graph

80 Commits (94bb8164b23d92483b51c38f3c68a4b91660154a)

Author SHA1 Message Date
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
Benoit Sigoure bcbf8144c6 Whenever a directory contained a file that couldn't be stat()ed by nginx
(e.g. due to EACCESS), the fancyindex module would produce an error and
wouldn't generate any response to the user.

The new behavior is to log a non-critical error and keep serving the page
anyway.

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Signed-off-by: Adrian Perez <aperez@igalia.com>
2010-03-10 01:53:19 +01:00
Adrián Pérez 9e6893c0c8 Be compatible with Nginx 0.8.0 2009-06-06 22:09:04 +02:00
Adrian Perez 30337efcb3 Removed half-implemented readme_* directives (#1) 2008-09-11 19:55:52 +02:00
Adrian Perez 207be06cd4 Fixes for building on nginx 0.7.7 2008-08-01 11:27:01 +02:00
Adrian Perez d508e6f95a - Added support for sending as much response as possible in a single
ngx_chain_t instead of always calling the output filter three times.
  This should avoid possible blocking in Nginx code.
- Added warning about using external URLs in subrequest in readme file.
- Factorized out some variable declarations out to function header. Removed
  a shadowed variable.
- Removed some debugging statements.
2007-09-19 18:22:16 +02:00
Adrian Perez 75e90109e0 Fixed handling of NGX_AGAIN in big responses 2007-09-12 17:16:59 +02:00