Hello community, here is the log from the commit of package nginx for openSUSE:Factory checked in at 2016-10-14 09:06:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/nginx (Old) and /work/SRC/openSUSE:Factory/.nginx.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "nginx" Changes: -------- --- /work/SRC/openSUSE:Factory/nginx/nginx.changes 2016-08-09 22:14:45.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.nginx.new/nginx.changes 2016-10-14 09:06:04.000000000 +0200 @@ -1,0 +2,103 @@ +Thu Sep 29 10:45:57 UTC 2016 - [email protected] + +- update to 11.4 + - Feature: the $upstream_bytes_received variable. + - Feature: the $bytes_received, $session_time, $protocol, + $status, $upstream_addr, $upstream_bytes_sent, + $upstream_bytes_received, $upstream_connect_time, + $upstream_first_byte_time, and $upstream_session_time variables + in the stream module. + - Feature: the ngx_stream_log_module. + - Feature: the "proxy_protocol" parameter of the "listen" + directive, the $proxy_protocol_addr and $proxy_protocol_port + variables in the stream module. + - Feature: the ngx_stream_realip_module. + - Bugfix: nginx could not be built with the stream module and the + ngx_http_ssl_module, but without ngx_stream_ssl_module; the bug + had appeared in 1.11.3. + - Feature: the IP_BIND_ADDRESS_NO_PORT socket option was not + used; the bug had appeared in 1.11.2. + - Bugfix: in the "ranges" parameter of the "geo" directive. + - Bugfix: an incorrect response might be returned when using the + "aio threads" and "sendfile" directives; the bug had appeared + in 1.9.13. +- drop nginx-1.11.3_ssl_stream.patch again +- refreshed the following patches to apply cleanly again + check_1.9.2+.patch + nginx-1.11.2-html.patch + nginx-1.11.2-no_Werror.patch + nginx-aio.patch + +------------------------------------------------------------------- +Wed Aug 24 11:34:50 UTC 2016 - [email protected] + +- update to 1.11.3 + - Change: now the "accept_mutex" directive is turned off by + default. + - Feature: now nginx uses EPOLLEXCLUSIVE on Linux. + - Feature: the ngx_stream_geo_module. + - Feature: the ngx_stream_geoip_module. + - Feature: the ngx_stream_split_clients_module. + - Feature: variables support in the "proxy_pass" and + "proxy_ssl_name" directives in the stream module. + - Bugfix: socket leak when using HTTP/2. + - Bugfix: in configure tests. Thanks to Piotr Sikora. +- backport nginx-1.11.3_ssl_stream.patch from hg +- refresh patches to apply cleanly again: + - check_1.9.2+.patch + - nginx-1.11.2-html.patch + - nginx-1.11.2-no_Werror.patch + - nginx-aio.patch +- enable a few new upstream modules and move some from 1.11.x to + dynamic: + - stream_geoip_module + - mail_ssl_module + - stream_ssl_module +- build fancyindex unconditionally and update it to 0.4.1 + - New `fancyindex_directories_first` configuration directive + (enabled by default), which allows setting whether directories + are sorted before other files. + (Patch by Luke Zapart <<[email protected]>>.) + - Fix index files not working when the fancyindex module is in + use (#46). + - The module can now be built as a [dynamic + module](https://www.nginx.com/resources/wiki/extending/converting/). + (Patch by Róbert Nagy <<[email protected]>>.) + - New configuration directive `fancyindex_show_path`, which + allows hiding the `<h1>` header which contains the current + path. (Patch by Thomas P. <<[email protected]>>.) + - Directory and file links in listings now have a title="..." + attribute. (Patch by `@janglapuk` <<[email protected]>>.) + - Fix for hung requests when the module is used along with + `ngx_pagespeed`. + (Patch by Otto van der Schaaf <<[email protected]>>.) + - New feature: Allow filtering out symbolic links using the + `fancyindex_hide_symlinks` configuration directive. (Idea and + prototype patch by Thomas Wemm.) + - New feature: Allow specifying the format of timestamps using + the `fancyindex_time_format` configuration directive. (Idea + suggested by Xiao Meng <<[email protected]>>). + - Listings in top-level directories will not generate a "Parent + Directory" link as first element of the listing. + (Patch by Thomas P.) + - Fix propagation and overriding of the `fancyindex_css_href` + setting inside nested locations. + - Minor changes in the code to allow building cleanly under + Windows with Visual Studio 2013. + (Patch by Y. Yuan <<[email protected]>>). +- added nginx-rtmp-module +- make all modules dynamic that support it: + - ngx-fancyindex + - headers_more_nginx-module + - nginx-rtmp-module +- manually install the docs instead of using %doc +- unify how we install documentation for the modules +- restructure contrib file handling + - moved vim files into the normal vim paths so we can use them + directly + - new BR/R: vim + - split out vim files into a subpackage vim-plugin-nginx so we + dont have the vim requires on the main package + - perl scripts are moved to /usr/share/nginx/ + +------------------------------------------------------------------- Old: ---- nginx-1.11.2.tar.gz ngx-fancyindex-0.3.5.tar.gz New: ---- nginx-1.11.4.tar.gz nginx-rtmp-module-1.1.9.tar.gz ngx-fancyindex-0.4.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ nginx.spec ++++++ --- /var/tmp/diff_new_pack.CwYoVO/_old 2016-10-14 09:06:06.000000000 +0200 +++ /var/tmp/diff_new_pack.CwYoVO/_new 2016-10-14 09:06:06.000000000 +0200 @@ -18,7 +18,6 @@ %bcond_with cpp_test %bcond_with google_perftools -%bcond_without fancyindex %if 0%{?suse_version} != 1315 || 0%{?is_opensuse} %bcond_without libatomic @@ -36,6 +35,8 @@ %bcond_with systemd %endif +%{!?vim_data_dir:%global vim_data_dir /usr/share/vim/%(readlink /usr/share/vim/current)} + %define pkg_name nginx %define ngx_prefix %{_prefix} %define ngx_sbin_path %{_sbindir}/nginx @@ -60,13 +61,23 @@ %define ngx_pid_path %{_localstatedir}/run/nginx.pid %define ngx_lock_path %{_localstatedir}/run/nginx.lock %endif +%define ngx_doc_dir %{_datadir}/doc/packages/%{name} # Name: nginx -Version: 1.11.2 +Version: 1.11.4 Release: 0 -%define fancyindex_version 0.3.5 +%define ngx_fancyindex_version 0.4.1 +%define ngx_fancyindex_module_path ngx-fancyindex-%{ngx_fancyindex_version} + %define headers_more_nginx_version 0.30 +%define headers_more_nginx_module_path headers-more-nginx-module-%{headers_more_nginx_version} + %define nginx_upstream_check_version 0.3.0 +%define nginx_upstream_check_module_path nginx_upstream_check_module-%{nginx_upstream_check_version} + +%define nginx_rtmp_version 1.1.9 +%define nginx_rtmp_module_path nginx-rtmp-module-%{nginx_rtmp_version} + Summary: A HTTP server and IMAP/POP3 proxy server License: BSD-2-Clause Group: Productivity/Networking/Web/Proxy @@ -75,9 +86,10 @@ Source1: nginx.init Source2: nginx.logrotate Source3: nginx.service -Source4: https://github.com/aperezdc/ngx-fancyindex/archive/v%{fancyindex_version}/ngx-fancyindex-%{fancyindex_version}.tar.gz -Source5: https://github.com/openresty/headers-more-nginx-module/archive/v%{headers_more_nginx_version}/headers-more-nginx-module-%{headers_more_nginx_version}.tar.gz -Source6: https://github.com/yaoweibin/nginx_upstream_check_module/archive/v%{nginx_upstream_check_version}/nginx_upstream_check_module-%{nginx_upstream_check_version}.tar.gz +Source4: https://github.com/aperezdc/ngx-fancyindex/archive/v%{ngx_fancyindex_version}/%{ngx_fancyindex_module_path}.tar.gz +Source5: https://github.com/openresty/headers-more-nginx-module/archive/v%{headers_more_nginx_version}/%{headers_more_nginx_module_path}.tar.gz +Source6: https://github.com/yaoweibin/nginx_upstream_check_module/archive/v%{nginx_upstream_check_version}/%{nginx_upstream_check_module_path}.tar.gz +Source7: https://github.com/arut/nginx-rtmp-module/archive/v%{nginx_rtmp_version}/%{nginx_rtmp_module_path}.tar.gz Source100: nginx.rpmlintrc # PATCH-FIX-UPSTREAM nginx-1.11.2-no_Werror.patch Patch0: nginx-1.11.2-no_Werror.patch @@ -97,12 +109,14 @@ BuildRequires: openssl-devel BuildRequires: pcre-devel BuildRequires: pkgconfig +BuildRequires: vim BuildRequires: zlib-devel %requires_eq perl Requires(pre): %fillup_prereq Requires(pre): %insserv_prereq Requires(pre): pwdutils Recommends: logrotate +Recommends: vim-plugin-nginx Conflicts: otherproviders(nginx) Provides: http_daemon Provides: httpd @@ -119,7 +133,7 @@ %endif # %if %{with systemd} -BuildRequires: systemd +BuildRequires: pkgconfig(systemd) %{?systemd_requires} %endif @@ -127,14 +141,21 @@ nginx [engine x] is a HTTP server and IMAP/POP3 proxy server written by Igor Sysoev. It has been running on many heavily loaded Russian sites for more than two years. -%prep -%if %{with fancyindex} -%setup -q -n %{pkg_name}-%{version} -b4 -%else -%setup -q -n %{pkg_name}-%{version} +%package -n vim-plugin-nginx +Summary: VIM support for nginx config files +Group: Productivity/Editors/Vi +%if 0%{?suse_version} > 1110 +BuildArch: noarch %endif -%setup -D -T -a 5 -n %{pkg_name}-%{version} -%setup -D -T -a 6 -n %{pkg_name}-%{version} +%requires_eq vim +%description -n vim-plugin-nginx +nginx [engine x] is a HTTP server and IMAP/POP3 proxy server written by Igor Sysoev. +It has been running on many heavily loaded Russian sites for more than two years. + +This package holds the VIM support for nginx config files. + +%prep +%setup -q -n %{pkg_name}-%{version} -a 4 -a 5 -a 6 -a 7 %patch0 -p1 %patch1 -p1 %patch2 @@ -146,13 +167,6 @@ # we just use lib here because nginx loads them relative to _prefix perl -pi -e 's|#LIBDIR#|%{_lib}|g' conf/nginx.conf -%if %{with fancyindex} -mkdir -p ngx-fancyindex-%{fancyindex_version} -pushd ../ngx-fancyindex-%{fancyindex_version} -cp -r template* LICENSE *.rst $RPM_BUILD_DIR/%{pkg_name}-%{version}/ngx-fancyindex-%{fancyindex_version}/ -popd -%endif - %if %{with systemd} sed -i "s/\/var\/run/\/run/" %{_sourcedir}/nginx.init %endif @@ -202,8 +216,11 @@ --with-http_perl_module=dynamic \ --with-perl=%{_bindir}/perl \ --with-mail=dynamic \ - --with-stream=dynamic \ --with-mail_ssl_module \ + --with-stream=dynamic \ + --with-stream_ssl_module \ + --with-stream_realip_module \ + --with-stream_geoip_module=dynamic \ --with-pcre \ %if %{with pcre_jit} --with-pcre-jit \ @@ -217,13 +234,10 @@ %if %{with cpp_test} --with-cpp_test_module \ %endif - %if %{with fancyindex} - --add-module=../ngx-fancyindex-%{fancyindex_version} \ - %endif - --add-module=headers-more-nginx-module-%{headers_more_nginx_version} \ - --add-module=nginx_upstream_check_module-%{nginx_upstream_check_version} \ - --with-md5=%{_prefix} \ - --with-sha1=%{_prefix} \ + --add-module=%{nginx_upstream_check_module_path} \ + --add-dynamic-module=%{ngx_fancyindex_module_path} \ + --add-dynamic-module=%{headers_more_nginx_module_path} \ + --add-dynamic-module=%{nginx_rtmp_module_path} \ %if 0%{?suse_version} > 1220 --with-cc-opt="%{optflags} -fPIC -D_GNU_SOURCE -std=gnu99 -fstack-protector" \ --with-ld-opt="-Wl,-z,relro,-z,now -pie" @@ -250,6 +264,40 @@ rm %{buildroot}/srv/www/htdocs/index.html +mkdir -p %{buildroot}%{ngx_doc_dir} +cp -av CHANGES* LICENSE \ + %{buildroot}%{ngx_doc_dir} + +mkdir -p %{buildroot}%{vim_data_dir}/ +cp -av contrib/vim/* \ + %{buildroot}%{vim_data_dir}/ + +mkdir -p %{buildroot}%{_datadir}/nginx/ +chmod a+rx contrib/geo2nginx.pl +cp -av contrib/geo2nginx.pl contrib/unicode2nginx/ \ + %{buildroot}%{_datadir}/nginx/ + +copydocs() { + subdir=$1; + shift; + mkdir -p %{buildroot}%{ngx_doc_dir}/$subdir/ + pushd $subdir + cp -av $* %{buildroot}%{ngx_doc_dir}/$subdir/ + popd +} + +copydocs %{ngx_fancyindex_module_path} \ + template* LICENSE *.rst + +copydocs %{headers_more_nginx_module_path} \ + README.markdown + +copydocs %{nginx_upstream_check_module_path} \ + doc/* + +copydocs %{nginx_rtmp_module_path} \ + AUTHORS LICENSE README.md stat.xsl + %post %if %{with systemd} %service_add_post nginx.service @@ -309,6 +357,11 @@ %{ngx_module_dir}/ngx_http_xslt_filter_module.so %{ngx_module_dir}/ngx_mail_module.so %{ngx_module_dir}/ngx_stream_module.so +%{ngx_module_dir}/ngx_stream_geoip_module.so +# external modules +%{ngx_module_dir}/ngx_http_fancyindex_module.so +%{ngx_module_dir}/ngx_http_headers_more_filter_module.so +%{ngx_module_dir}/ngx_rtmp_module.so %{_mandir}/man3/nginx.3pm* /srv/www/htdocs/50x.html %if 0%{?suse_version} && 0%{?suse_version} < 1140 @@ -323,15 +376,19 @@ %dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_fcgi} %dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_scgi} %dir %attr(750,%{ngx_user_group},%{ngx_user_group}) %{ngx_tmp_uwsgi} -%doc CHANGES* -%doc conf/ contrib/ -%if %{with fancyindex} -%doc ngx-fancyindex-%{fancyindex_version}/ -%endif +%doc %{ngx_doc_dir} %if %{with systemd} %{_unitdir}/nginx.service %else %{_sysconfdir}/init.d/%{pkg_name} %endif +%{_datadir}/nginx/ + +%files -n vim-plugin-nginx +%defattr(-,root,root) +%dir %{vim_data_dir}/ftdetect/ +%{vim_data_dir}/ftdetect/nginx.vim +%{vim_data_dir}/indent/nginx.vim +%{vim_data_dir}/syntax/nginx.vim %changelog ++++++ check_1.9.2+.patch ++++++ --- /var/tmp/diff_new_pack.CwYoVO/_old 2016-10-14 09:06:06.000000000 +0200 +++ /var/tmp/diff_new_pack.CwYoVO/_new 2016-10-14 09:06:06.000000000 +0200 @@ -1,6 +1,6 @@ -diff --git src/http/modules/ngx_http_upstream_hash_module.c src/http/modules/ngx_http_upstream_hash_module.c -index 1e2e05c..44a72e2 100644 ---- src/http/modules/ngx_http_upstream_hash_module.c +Index: src/http/modules/ngx_http_upstream_hash_module.c +=================================================================== +--- src/http/modules/ngx_http_upstream_hash_module.c.orig +++ src/http/modules/ngx_http_upstream_hash_module.c @@ -9,6 +9,9 @@ #include <ngx_core.h> @@ -12,7 +12,7 @@ typedef struct { uint32_t hash; -@@ -235,6 +238,15 @@ ngx_http_upstream_get_hash_peer(ngx_peer_connection_t *pc, void *data) +@@ -235,6 +238,15 @@ ngx_http_upstream_get_hash_peer(ngx_peer goto next; } @@ -28,7 +28,7 @@ if (peer->max_fails && peer->fails >= peer->max_fails && now - peer->checked <= peer->fail_timeout) -@@ -535,6 +547,15 @@ ngx_http_upstream_get_chash_peer(ngx_peer_connection_t *pc, void *data) +@@ -535,6 +547,15 @@ ngx_http_upstream_get_chash_peer(ngx_pee continue; } @@ -44,9 +44,9 @@ if (peer->server.len != server->len || ngx_strncmp(peer->server.data, server->data, server->len) != 0) -diff --git src/http/modules/ngx_http_upstream_ip_hash_module.c src/http/modules/ngx_http_upstream_ip_hash_module.c -index 401b58e..ba656bd 100644 ---- src/http/modules/ngx_http_upstream_ip_hash_module.c +Index: src/http/modules/ngx_http_upstream_ip_hash_module.c +=================================================================== +--- src/http/modules/ngx_http_upstream_ip_hash_module.c.orig +++ src/http/modules/ngx_http_upstream_ip_hash_module.c @@ -9,6 +9,9 @@ #include <ngx_core.h> @@ -58,7 +58,7 @@ typedef struct { /* the round robin data must be first */ -@@ -205,6 +208,15 @@ ngx_http_upstream_get_ip_hash_peer(ngx_peer_connection_t *pc, void *data) +@@ -205,6 +208,15 @@ ngx_http_upstream_get_ip_hash_peer(ngx_p goto next; } @@ -74,9 +74,9 @@ if (peer->max_fails && peer->fails >= peer->max_fails && now - peer->checked <= peer->fail_timeout) -diff --git src/http/modules/ngx_http_upstream_least_conn_module.c src/http/modules/ngx_http_upstream_least_conn_module.c -index 92951bd..48aca2c 100644 ---- src/http/modules/ngx_http_upstream_least_conn_module.c +Index: src/http/modules/ngx_http_upstream_least_conn_module.c +=================================================================== +--- src/http/modules/ngx_http_upstream_least_conn_module.c.orig +++ src/http/modules/ngx_http_upstream_least_conn_module.c @@ -9,6 +9,9 @@ #include <ngx_core.h> @@ -88,7 +88,7 @@ static ngx_int_t ngx_http_upstream_init_least_conn_peer(ngx_http_request_t *r, ngx_http_upstream_srv_conf_t *us); -@@ -148,6 +151,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data) +@@ -148,6 +151,16 @@ ngx_http_upstream_get_least_conn_peer(ng continue; } @@ -105,7 +105,7 @@ if (peer->max_fails && peer->fails >= peer->max_fails && now - peer->checked <= peer->fail_timeout) -@@ -199,6 +212,16 @@ ngx_http_upstream_get_least_conn_peer(ngx_peer_connection_t *pc, void *data) +@@ -199,6 +212,16 @@ ngx_http_upstream_get_least_conn_peer(ng continue; } @@ -122,9 +122,9 @@ if (peer->conns * best->weight != best->conns * peer->weight) { continue; } -diff --git src/http/ngx_http_upstream_round_robin.c src/http/ngx_http_upstream_round_robin.c -index d6ae33b..416572a 100644 ---- src/http/ngx_http_upstream_round_robin.c +Index: src/http/ngx_http_upstream_round_robin.c +=================================================================== +--- src/http/ngx_http_upstream_round_robin.c.orig +++ src/http/ngx_http_upstream_round_robin.c @@ -9,6 +9,9 @@ #include <ngx_core.h> @@ -136,7 +136,7 @@ #define ngx_http_upstream_tries(p) ((p)->number \ + ((p)->next ? (p)->next->number : 0)) -@@ -96,7 +99,14 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf, +@@ -96,7 +99,14 @@ ngx_http_upstream_init_round_robin(ngx_c peer[n].fail_timeout = server[i].fail_timeout; peer[n].down = server[i].down; peer[n].server = server[i].name; @@ -152,7 +152,7 @@ *peerp = &peer[n]; peerp = &peer[n].next; n++; -@@ -159,7 +169,15 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf, +@@ -159,7 +169,15 @@ ngx_http_upstream_init_round_robin(ngx_c peer[n].fail_timeout = server[i].fail_timeout; peer[n].down = server[i].down; peer[n].server = server[i].name; @@ -169,7 +169,7 @@ *peerp = &peer[n]; peerp = &peer[n].next; n++; -@@ -225,6 +243,9 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf, +@@ -225,6 +243,9 @@ ngx_http_upstream_init_round_robin(ngx_c peer[i].current_weight = 0; peer[i].max_fails = 1; peer[i].fail_timeout = 10; @@ -179,7 +179,7 @@ *peerp = &peer[i]; peerp = &peer[i].next; } -@@ -339,6 +360,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r, +@@ -339,6 +360,9 @@ ngx_http_upstream_create_round_robin_pee peer[0].current_weight = 0; peer[0].max_fails = 1; peer[0].fail_timeout = 10; @@ -189,7 +189,7 @@ peers->peer = peer; } else { -@@ -381,6 +405,9 @@ ngx_http_upstream_create_round_robin_peer(ngx_http_request_t *r, +@@ -372,6 +396,9 @@ ngx_http_upstream_create_round_robin_pee peer[i].current_weight = 0; peer[i].max_fails = 1; peer[i].fail_timeout = 10; @@ -199,7 +199,7 @@ *peerp = &peer[i]; peerp = &peer[i].next; } -@@ -441,6 +468,12 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data) +@@ -432,6 +459,12 @@ ngx_http_upstream_get_round_robin_peer(n goto failed; } @@ -212,7 +212,7 @@ rrp->current = peer; } else { -@@ -542,6 +575,12 @@ ngx_http_upstream_get_peer(ngx_http_upstream_rr_peer_data_t *rrp) +@@ -533,6 +566,12 @@ ngx_http_upstream_get_peer(ngx_http_upst continue; } @@ -225,9 +225,9 @@ if (peer->max_fails && peer->fails >= peer->max_fails && now - peer->checked <= peer->fail_timeout) -diff --git src/http/ngx_http_upstream_round_robin.h src/http/ngx_http_upstream_round_robin.h -index f2c573f..75e0ed6 100644 ---- src/http/ngx_http_upstream_round_robin.h +Index: src/http/ngx_http_upstream_round_robin.h +=================================================================== +--- src/http/ngx_http_upstream_round_robin.h.orig +++ src/http/ngx_http_upstream_round_robin.h @@ -35,6 +35,10 @@ struct ngx_http_upstream_rr_peer_s { ngx_uint_t max_fails; ++++++ nginx-1.11.2-html.patch ++++++ --- /var/tmp/diff_new_pack.CwYoVO/_old 2016-10-14 09:06:06.000000000 +0200 +++ /var/tmp/diff_new_pack.CwYoVO/_new 2016-10-14 09:06:06.000000000 +0200 @@ -1,7 +1,8 @@ -diff -ur nginx-1.11.2.orig/auto/install nginx-1.11.2/auto/install ---- nginx-1.11.2.orig/auto/install 2016-05-06 09:12:12.617492168 +0200 -+++ nginx-1.11.2/auto/install 2016-05-06 09:30:12.164261301 +0200 -@@ -154,8 +154,7 @@ +Index: nginx-1.11.2/auto/install +=================================================================== +--- nginx-1.11.2.orig/auto/install ++++ nginx-1.11.2/auto/install +@@ -154,8 +154,7 @@ install: build $NGX_INSTALL_PERL_MODULES test -d '\$(DESTDIR)`dirname "$NGX_HTTP_LOG_PATH"`' \\ || mkdir -p '\$(DESTDIR)`dirname "$NGX_HTTP_LOG_PATH"`' ++++++ nginx-1.11.2-no_Werror.patch ++++++ --- /var/tmp/diff_new_pack.CwYoVO/_old 2016-10-14 09:06:06.000000000 +0200 +++ /var/tmp/diff_new_pack.CwYoVO/_new 2016-10-14 09:06:06.000000000 +0200 @@ -1,7 +1,8 @@ -diff -urp nginx-1.11.2/auto/cc/gcc nginx-1.11.2-patched/auto/cc/gcc ---- nginx-1.11.2/auto/cc/gcc 2014-03-04 03:39:24.000000000 -0800 -+++ nginx-1.11.2-patched/auto/cc/gcc 2014-03-13 20:54:13.301355329 -0700 -@@ -168,7 +168,7 @@ esac +Index: nginx-1.11.2/auto/cc/gcc +=================================================================== +--- nginx-1.11.2.orig/auto/cc/gcc ++++ nginx-1.11.2/auto/cc/gcc +@@ -166,7 +166,7 @@ esac # stop on warning @@ -10,10 +11,11 @@ # debug CFLAGS="$CFLAGS -g" -diff -urp nginx-1.11.2/auto/cc/icc nginx-1.11.2-patched/auto/cc/icc ---- nginx-1.11.2/auto/cc/icc 2014-03-04 03:39:24.000000000 -0800 -+++ nginx-1.11.2-patched/auto/cc/icc 2014-03-13 20:54:13.301355329 -0700 -@@ -115,7 +115,7 @@ case "$NGX_ICC_VER" in +Index: nginx-1.11.2/auto/cc/icc +=================================================================== +--- nginx-1.11.2.orig/auto/cc/icc ++++ nginx-1.11.2/auto/cc/icc +@@ -111,7 +111,7 @@ case "$NGX_ICC_VER" in esac # stop on warning ++++++ nginx-1.11.2.tar.gz -> nginx-1.11.4.tar.gz ++++++ ++++ 9023 lines of diff (skipped) ++++++ nginx-aio.patch ++++++ --- /var/tmp/diff_new_pack.CwYoVO/_old 2016-10-14 09:06:06.000000000 +0200 +++ /var/tmp/diff_new_pack.CwYoVO/_new 2016-10-14 09:06:06.000000000 +0200 @@ -1,25 +1,26 @@ -Index: nginx-1.9.1/auto/unix +Index: nginx-1.11.3/auto/unix =================================================================== ---- nginx-1.9.1.orig/auto/unix -+++ nginx-1.9.1/auto/unix -@@ -438,7 +438,11 @@ if [ $NGX_FILE_AIO = YES ]; then +--- nginx-1.11.3.orig/auto/unix ++++ nginx-1.11.3/auto/unix +@@ -531,7 +531,12 @@ if [ $NGX_FILE_AIO = YES ]; then ngx_feature="Linux AIO support (SYS_eventfd)" ngx_feature_incs="#include <linux/aio_abi.h> #include <sys/syscall.h>" -- ngx_feature_test="int n = SYS_eventfd; +- ngx_feature_test="struct iocb iocb; + ngx_feature_test="#ifdef SYS_eventfd + int n = SYS_eventfd; + #else + int n = SYS_eventfd2; + #endif - struct iocb iocb; ++ struct iocb iocb; iocb.aio_lio_opcode = IOCB_CMD_PREAD; iocb.aio_flags = IOCB_FLAG_RESFD; -Index: nginx-1.9.1/src/event/modules/ngx_epoll_module.c + iocb.aio_resfd = -1; +Index: nginx-1.11.3/src/event/modules/ngx_epoll_module.c =================================================================== ---- nginx-1.9.1.orig/src/event/modules/ngx_epoll_module.c -+++ nginx-1.9.1/src/event/modules/ngx_epoll_module.c -@@ -76,9 +76,7 @@ int epoll_wait(int epfd, struct epoll_ev +--- nginx-1.11.3.orig/src/event/modules/ngx_epoll_module.c ++++ nginx-1.11.3/src/event/modules/ngx_epoll_module.c +@@ -77,9 +77,7 @@ int epoll_wait(int epfd, struct epoll_ev #if (NGX_HAVE_FILE_AIO) @@ -30,7 +31,7 @@ typedef u_int aio_context_t; -@@ -246,7 +244,11 @@ ngx_epoll_aio_init(ngx_cycle_t *cycle, n +@@ -254,7 +252,11 @@ ngx_epoll_aio_init(ngx_cycle_t *cycle, n #if (NGX_HAVE_SYS_EVENTFD_H) ngx_eventfd = eventfd(0, 0); #else ++++++ ngx-fancyindex-0.3.5.tar.gz -> ngx-fancyindex-0.4.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/.gitignore new/ngx-fancyindex-0.4.1/.gitignore --- old/ngx-fancyindex-0.3.5/.gitignore 2015-02-19 13:16:36.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/.gitignore 2016-08-18 19:49:47.000000000 +0200 @@ -1 +1,4 @@ *.sw[op] +/t/*.sh +/t/*.out +/t/*.err diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/.travis.yml new/ngx-fancyindex-0.4.1/.travis.yml --- old/ngx-fancyindex-0.3.5/.travis.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/.travis.yml 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,34 @@ +language: c + +compiler: + - clang + - gcc + +env: + # Mainline + - NGINX=1.11.3 + - NGINX=1.11.3 DYNAMIC=1 + # Stable + - NGINX=1.10.1 + - NGINX=1.10.1 DYNAMIC=1 + # Other configurations + - NGINX=1.9.15 + - NGINX=1.9.15 DYNAMIC=1 + - NGINX=1.8.1 + # Also, the oldest supported version + # TODO: Fails building because it won't find IOV_MAX from header. + #- NGINX=0.7.69 + +sudo: false + +addons: + apt: + packages: + - libpcre3-dev + - libssl-dev + +cache: ccache + +script: + - echo "NGINX=${NGINX} ${DYNAMIC:+DYNAMIC=${DYNAMIC}}" + - t/build-and-run ${NGINX} ${DYNAMIC} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/CHANGELOG.md new/ngx-fancyindex-0.4.1/CHANGELOG.md --- old/ngx-fancyindex-0.3.5/CHANGELOG.md 2015-02-19 13:16:36.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/CHANGELOG.md 2016-08-18 19:49:47.000000000 +0200 @@ -1,37 +1,111 @@ # Change Log All notable changes to this project will be documented in this file. -## Unreleased +## [Unreleased] + +## [0.4.1] - 2016-08-18 +### Added +- New `fancyindex_directories_first` configuration directive (enabled by + default), which allows setting whether directories are sorted before other + files. (Patch by Luke Zapart <<[email protected]>>.) + +### Fixed +- Fix index files not working when the fancyindex module is in use (#46). + + +## [0.4.0] - 2016-06-08 +### Added +- The module can now be built as a [dynamic + module](https://www.nginx.com/resources/wiki/extending/converting/). + (Patch by Róbert Nagy <<[email protected]>>.) +- New configuration directive `fancyindex_show_path`, which allows hiding the + `<h1>` header which contains the current path. + (Patch by Thomas P. <<[email protected]>>.) + +### Changed +- Directory and file links in listings now have a title="..." attribute. + (Patch by `@janglapuk` <<[email protected]>>.) + +### Fixed +- Fix for hung requests when the module is used along with `ngx_pagespeed`. + (Patch by Otto van der Schaaf <<[email protected]>>.) + + +## [0.3.6] - 2016-01-26 +### Added +- New feature: Allow filtering out symbolic links using the + `fancyindex_hide_symlinks` configuration directive. (Idea and prototype + patch by Thomas Wemm.) +- New feature: Allow specifying the format of timestamps using the + `fancyindex_time_format` configuration directive. (Idea suggested by Xiao + Meng <<[email protected]>>). + +### Changed +- Listings in top-level directories will not generate a "Parent Directory" + link as first element of the listing. (Patch by Thomas P.) + +### Fixed +- Fix propagation and overriding of the `fancyindex_css_href` setting inside + nested locations. +- Minor changes in the code to allow building cleanly under Windows with + Visual Studio 2013. (Patch by Y. Yuan <<[email protected]>>). + + +## [0.3.5] - 2015-02-19 ### Added - New feature: Allow setting the default sort criterion using the `fancyindex_default_sort` configuration directive. (Patch by Алексей Урбанский). -- New feature: Allos changing the maximum length of file names, using +- New feature: Allow changing the maximum length of file names, using the `fancyindex_name_length` configuration directive. (Patch by Martin Herkt). + ### Changed - Renames `NEWS.rst` to `CHANGELOG.md`, which follows the recommendations from [Keep a Change Log](http://keepachangelog.com/). +- Configuring Nginx without the `http_addition_module` will generate a + warning during configuration, as it is needed for the `fancyindex_footer` + and `fancyindex_header` directives. + + +## [0.3.4] - 2014-09-03 -## 0.3.4 - 2014-09-03 ### Added - Viewport is now defined in the generated HTML, which works better for mobile devices. + ### Changed - Even-odd row styling moved to the CSS using :nth-child(). This makes the HTML served to clients smaller. -## 0.3.3 - 2013-10-25 + +## [0.3.3] - 2013-10-25 + ### Added - New feature: table headers in the default template are now clickable to set the sorting criteria and direction of the index entries. (https://github.com/aperezdc/ngx-fancyindex/issues/7) -## 0.3.2 - 2013-06-05 + +## [0.3.2] - 2013-06-05 + ### Fixed - Solved a bug that would leave certain clients stalled forever. - Improved handling of subrequests for non-builtin headers/footers. -## 0.3.1 - 2011-04-04 + +## [0.3.1] - 2011-04-04 + ### Added - `NEWS.rst` file, to act as change log. + + +[Unreleased]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.1...HEAD +[0.4.1]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.0...v0.4.1 +[0.4.0]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.3.6...v0.4.0 +[0.3.6]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.3.5...v0.3.6 +[0.3.5]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.3.4...v0.3.5 +[0.3.4]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.3.3...v0.3.4 +[0.3.3]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.3.2...v0.3.3 +[0.3.2]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.3.1...v0.3.2 +[0.3.1]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.3...v0.3.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/README.rst new/ngx-fancyindex-0.4.1/README.rst --- old/ngx-fancyindex-0.3.5/README.rst 2015-02-19 13:16:36.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/README.rst 2016-08-18 19:49:47.000000000 +0200 @@ -2,8 +2,8 @@ Nginx Fancy Index module ======================== -.. image:: https://drone.io/github.com/aperezdc/ngx-fancyindex/status.png - :target: https://drone.io/github.com/aperezdc/ngx-fancyindex/latest +.. image:: https://travis-ci.org/aperezdc/ngx-fancyindex.svg?branch=master + :target: https://travis-ci.org/aperezdc/ngx-fancyindex :alt: Build Status .. contents:: @@ -31,6 +31,10 @@ versions in the 0.6 series by applying ``nginx-0.6-support.patch``, but this is unsupported (YMMV). +In order to use the fancyindex_header_ and fancyindex_footer_ directives +you will also need the `ngx_http_addition_module <http://nginx.org/en/docs/http/ngx_http_addition_module.html>`_ +built into Nginx. + Building ======== @@ -49,7 +53,12 @@ of the fancy indexing module:: $ cd nginx-?.?.? - $ ./configure --add-module=../nginx-fancyindex-?.?.? [extra desired options] + $ ./configure --add-module=../nginx-fancyindex-?.?.? \ + [--with-http_addition_module] [extra desired options] + + Since version 0.4.0, the module can also be built as a + `dynamic module <https://www.nginx.com/resources/wiki/extending/converting/>`_, + using ``--add-dynamic-module=…`` instead. 4. Build and install the software:: @@ -74,13 +83,19 @@ } -Advanced Theming -~~~~~~~~~~~~~~~~ +Themes +~~~~~~ + +The following themes demonstrate the level of customization which can be +achieved using the module: -For a more elaborate example using `fancyindex_header`_ and -`fancyindex_footer`_ you can check `nice theme -<https://github.com/TheInsomniac/Nginx-Fancyindex-Theme>`__ -designed by `@TheInsomniac <https://github.com/TheInsomniac>`__. +* `Theme <https://github.com/TheInsomniac/Nginx-Fancyindex-Theme>`__ by + `@TheInsomniac <https://github.com/TheInsomniac>`__. Uses custom header and + footer. +* `Theme <https://github.com/nwrd/Nginx-Fancyindex-Theme>`__ by + nwrd <https://github.com/nwrd>`__. Uses custom header and footer, the + header includes search field to filter by filename using JavaScript + (`demo <http://nwrd.sly.io/>`__). Directives @@ -102,6 +117,15 @@ :Description: Defines sorting criterion by default. +fancyindex_directories_first +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +:Syntax: *fancyindex_directories_first* [*on* | *off*] +:Default: fancyindex_directories_first on +:Context: http, server, location +:Description: + If enabled (default setting), groups directories together and sorts them + before all regular files. If disabled, directories are sorted together with files. + fancyindex_css_href ~~~~~~~~~~~~~~~~~~~ :Syntax: *fancyindex_css_href uri* @@ -141,6 +165,9 @@ If set to an empty string, the default footer supplied by the module will be sent. +.. note:: Using this directive needs the ngx_http_addition_module_ built + into Nginx. + .. warning:: When inserting custom header/footer a subrequest will be issued so potentially any URL can be used as source for them. Although it will work with external URLs, only using internal ones is supported. @@ -159,6 +186,22 @@ If set to an empty string, the default header supplied by the module will be sent. +.. note:: Using this directive needs the ngx_http_addition_module_ built + into Nginx. + +fancyindex_show_path +~~~~~~~~~~~~~~~~~ +:Syntax: *fancyindex_show_path* [*on* | *off*] +:Default: fancyindex_show_path on +:Context: http, server, location +:Description: + Whether to output or not the path and the closing </h1> tag after the header. + This is useful when you want to handle the path displaying with a PHP script + for example. + +.. warning:: This directive can be turned off only if a custom header is provided + using fancyindex_header. + fancyindex_ignore ~~~~~~~~~~~~~~~~~ :Syntax: *fancyindex_ignore string1 [string2 [... stringN]]* @@ -169,6 +212,14 @@ listings. If Nginx was built with PCRE support strings are interpreted as regular expressions. +fancyindex_hide_symlinks +~~~~~~~~~~~~~~~~~~~~~~~~ +:Syntax: *fancyindex_hide_symlinks* [*on* | *off*] +:Default: fancyindex_hide_symlinks off +:Context: http, server, location +:Description: + When enabled, generated listings will not contain symbolic links. + fancyindex_localtime ~~~~~~~~~~~~~~~~~~~~ :Syntax: *fancyindex_localtime* [*on* | *off*] @@ -177,6 +228,46 @@ :Description: Enables showing file times as local time. Default is “off” (GMT time). +fancyindex_time_format +~~~~~~~~~~~~~~~~~~~~~~ +:Syntax: *fancyindex_time_format* string +:Default: fancyindex_time_format "%Y-%b-%d %H:%M" +:Context: http, server, location +:Description: + Format string used for timestamps. The format specifiers are a subset of + those supported by the `strftime <http://linux.die.net/man/3/strftime>`_ + function, and the behavior is locale-independent (for example, day and month + names are always in English). The supported formats are: + + * ``%a``: Abbreviated name of the day of the week. + * ``%A``: Full name of the day of the week. + * ``%b``: Abbreviated month name. + * ``%B``: Full month name. + * ``%d``: Day of the month as a decimal number (range 01 to 31). + * ``%e``: Like ``%d``, the day of the month as a decimal number, but a + leading zero is replaced by a space. + * ``%F``: Equivalent to ``%Y-%m-%d`` (the ISO 8601 date format). + * ``%H``: Hour as a decimal number using a 24-hour clock (range 00 + to 23). + * ``%I``: Hour as a decimal number using a 12-hour clock (range 01 to 12). + * ``%k``: Hour (24-hour clock) as a decimal number (range 0 to 23); + single digits are preceded by a blank. + * ``%l``: Hour (12-hour clock) as a decimal number (range 1 to 12); single + digits are preceded by a blank. + * ``%m``: Month as a decimal number (range 01 to 12). + * ``%M``: Minute as a decimal number (range 00 to 59). + * ``%p``: Either "AM" or "PM" according to the given time value. + * ``%P``: Like ``%p`` but in lowercase: "am" or "pm". + * ``%r``: Time in a.m. or p.m. notation. Equivalent to ``%I:%M:%S %p``. + * ``%R``: Time in 24-hour notation (``%H:%M``). + * ``%S``: Second as a decimal number (range 00 to 60). + * ``%T``: Time in 24-hour notation (``%H:%M:%S``). + * ``%u``: Day of the week as a decimal, range 1 to 7, Monday being 1. + * ``%w``: Day of the week as a decimal, range 0 to 6, Monday being 0. + * ``%y``: Year as a decimal number without a century (range 00 to 99). + * ``%Y``: Year as a decimal number including the century. + + .. _nginx: http://nginx.net .. vim:ft=rst:spell:spelllang=en: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/config new/ngx-fancyindex-0.4.1/config --- old/ngx-fancyindex-0.3.5/config 2015-02-19 13:16:36.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/config 2016-08-18 19:49:47.000000000 +0200 @@ -1,8 +1,20 @@ # vim:ft=sh: ngx_addon_name=ngx_http_fancyindex_module -# XXX: Insert fancyindex module *after* index module! -# -HTTP_MODULES=`echo "${HTTP_MODULES}" | sed -e \ +if [ "$ngx_module_link" = DYNAMIC ] ; then + ngx_module_type=HTTP + ngx_module_name=ngx_http_fancyindex_module + ngx_module_srcs="$ngx_addon_dir/ngx_http_fancyindex_module.c" + ngx_module_deps="$ngx_addon_dir/template.h" + ngx_module_order="$ngx_module_name ngx_http_autoindex_module" + . auto/module +else + # XXX: Insert fancyindex module *after* index module! + # + HTTP_MODULES=`echo "${HTTP_MODULES}" | sed -e \ 's/ngx_http_index_module/ngx_http_fancyindex_module ngx_http_index_module/'` -NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fancyindex_module.c" + NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_fancyindex_module.c" + if [ $HTTP_ADDITION != YES ] ; then + echo " - The 'addition' filter is needed for fancyindex_{header,footer}, but it was disabled" + fi +fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/ngx_http_fancyindex_module.c new/ngx-fancyindex-0.4.1/ngx_http_fancyindex_module.c --- old/ngx-fancyindex-0.3.5/ngx_http_fancyindex_module.c 2015-02-19 13:16:36.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/ngx_http_fancyindex_module.c 2016-08-18 19:49:47.000000000 +0200 @@ -1,6 +1,6 @@ /* * ngx_http_fancyindex_module.c - * Copyright © 2007-2013 Adrian Perez <[email protected]> + * Copyright © 2007-2016 Adrian Perez <[email protected]> * * Module used for fancy indexing of directories. Features and differences * with the stock nginx autoindex module: @@ -33,6 +33,113 @@ #endif /* __GNUC__ */ +static const char *short_weekday[] = { + "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun", +}; +static const char *long_weekday[] = { + "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Sunday", +}; +static const char *short_month[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", +}; +static const char *long_month[] = { + "January", "February", "March", "April", "May", "June", "July", + "August", "September", "October", "November", "December", +}; + + +#define DATETIME_FORMATS(F_, t) \ + F_ ('a', 3, "%3s", short_weekday[((t)->ngx_tm_wday + 6) % 7]) \ + F_ ('A', 9, "%s", long_weekday [((t)->ngx_tm_wday + 6) % 7]) \ + F_ ('b', 3, "%3s", short_month[(t)->ngx_tm_mon - 1] ) \ + F_ ('B', 9, "%s", long_month [(t)->ngx_tm_mon - 1] ) \ + F_ ('d', 2, "%02d", (t)->ngx_tm_mday ) \ + F_ ('e', 2, "%2d", (t)->ngx_tm_mday ) \ + F_ ('F', 10, "%d-%02d-%02d", \ + (t)->ngx_tm_year, \ + (t)->ngx_tm_mon, \ + (t)->ngx_tm_mday ) \ + F_ ('H', 2, "%02d", (t)->ngx_tm_hour ) \ + F_ ('I', 2, "%02d", ((t)->ngx_tm_hour % 12) + 1 ) \ + F_ ('k', 2, "%2d", (t)->ngx_tm_hour ) \ + F_ ('l', 2, "%2d", ((t)->ngx_tm_hour % 12) + 1 ) \ + F_ ('m', 2, "%02d", (t)->ngx_tm_mon ) \ + F_ ('M', 2, "%02d", (t)->ngx_tm_min ) \ + F_ ('p', 2, "%2s", (((t)->ngx_tm_hour < 12) ? "AM" : "PM") ) \ + F_ ('P', 2, "%2s", (((t)->ngx_tm_hour < 12) ? "am" : "pm") ) \ + F_ ('r', 11, "%02d:%02d:%02d %2s", \ + ((t)->ngx_tm_hour % 12) + 1, \ + (t)->ngx_tm_min, \ + (t)->ngx_tm_sec, \ + (((t)->ngx_tm_hour < 12) ? "AM" : "PM") ) \ + F_ ('R', 5, "%02d:%02d", (t)->ngx_tm_hour, (t)->ngx_tm_min ) \ + F_ ('S', 2, "%02d", (t)->ngx_tm_sec ) \ + F_ ('T', 8, "%02d:%02d:%02d", \ + (t)->ngx_tm_hour, \ + (t)->ngx_tm_min, \ + (t)->ngx_tm_sec ) \ + F_ ('u', 1, "%1d", (((t)->ngx_tm_wday + 6) % 7) + 1 ) \ + F_ ('w', 1, "%1d", ((t)->ngx_tm_wday + 6) % 7 ) \ + F_ ('y', 2, "%02d", (t)->ngx_tm_year % 100 ) \ + F_ ('Y', 4, "%04d", (t)->ngx_tm_year ) + + +static size_t +ngx_fancyindex_timefmt_calc_size (const ngx_str_t *fmt) +{ +#define DATETIME_CASE(letter, fmtlen, fmt, ...) \ + case letter: result += (fmtlen); break; + + size_t i, result = 0; + for (i = 0; i < fmt->len; i++) { + if (fmt->data[i] == '%') { + if (++i >= fmt->len) { + result++; + break; + } + switch (fmt->data[i]) { + DATETIME_FORMATS(DATETIME_CASE,) + default: + result++; + } + } else { + result++; + } + } + return result; + +#undef DATETIME_CASE +} + + +static u_char* +ngx_fancyindex_timefmt (u_char *buffer, const ngx_str_t *fmt, const ngx_tm_t *tm) +{ +#define DATETIME_CASE(letter, fmtlen, fmt, ...) \ + case letter: buffer = ngx_snprintf(buffer, fmtlen, fmt, ##__VA_ARGS__); break; + + size_t i; + for (i = 0; i < fmt->len; i++) { + if (fmt->data[i] == '%') { + if (++i >= fmt->len) { + *buffer++ = '%'; + break; + } + switch (fmt->data[i]) { + DATETIME_FORMATS(DATETIME_CASE, tm) + default: + *buffer++ = fmt->data[i]; + } + } else { + *buffer++ = fmt->data[i]; + } + } + return buffer; + +#undef DATETIME_CASE +} + /** * Configuration structure for the fancyindex module. The configuration @@ -41,13 +148,17 @@ typedef struct { ngx_flag_t enable; /**< Module is enabled. */ ngx_uint_t default_sort; /**< Default sort criterion. */ + ngx_flag_t dirs_first; /**< Group directories together first when sorting */ 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 show_path; /**< Whether to display or not the path + '</h1>' after the header */ ngx_str_t header; /**< File name for header, or empty if none. */ ngx_str_t footer; /**< File name for footer, or empty if none. */ ngx_str_t css_href; /**< Link to a CSS stylesheet, or empty if none. */ + ngx_str_t time_format; /**< Format used for file timestamps. */ ngx_array_t *ignore; /**< List of files to ignore in listings. */ } ngx_http_fancyindex_loc_conf_t; @@ -113,17 +224,19 @@ -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl + ngx_http_fancyindex_cmp_entries_dirs_first(const void *one, const void *two); +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_name_desc(const void *one, const void *two); -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_size_desc(const void *one, const void *two); -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_mtime_desc(const void *one, const void *two); -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_name_asc(const void *one, const void *two); -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_size_asc(const void *one, const void *two); -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_mtime_asc(const void *one, const void *two); static ngx_int_t ngx_http_fancyindex_error(ngx_http_request_t *r, @@ -174,6 +287,13 @@ offsetof(ngx_http_fancyindex_loc_conf_t, default_sort), &ngx_http_fancyindex_sort_criteria }, + { ngx_string("fancyindex_directories_first"), + 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, dirs_first), + NULL }, + { ngx_string("fancyindex_localtime"), NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, ngx_conf_set_flag_slot, @@ -223,6 +343,27 @@ 0, NULL }, + { ngx_string("fancyindex_hide_symlinks"), + 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, hide_symlinks), + NULL }, + + { ngx_string("fancyindex_show_path"), + 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_path), + NULL }, + + { ngx_string("fancyindex_time_format"), + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, + ngx_conf_set_str_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_http_fancyindex_loc_conf_t, time_format), + NULL }, + ngx_null_command }; @@ -406,7 +547,7 @@ { ngx_http_fancyindex_entry_t *entry; - int (*sort_cmp_func) (const void*, const void*); + ngx_int_t (*sort_cmp_func) (const void*, const void*); const char *sort_url_args = ""; off_t length; @@ -421,11 +562,6 @@ ngx_dir_t dir; ngx_buf_t *b; - static char *months[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", - }; - /* * NGX_DIR_MASK_LEN is lesser than NGX_HTTP_FANCYINDEX_PREALLOCATE */ @@ -497,9 +633,14 @@ if (ngx_de_name(&dir)[0] == '.') continue; + if (alcf->hide_symlinks && ngx_de_is_link (&dir)) + continue; + #if NGX_PCRE { - ngx_str_t str = { len, ngx_de_name(&dir) }; + ngx_str_t str; + str.len = len; + str.data = ngx_de_name(&dir); if (alcf->ignore && ngx_regex_exec_array(alcf->ignore, &str, r->connection->log) @@ -588,12 +729,29 @@ /* * Calculate needed buffer length. */ - len = r->uri.len - + ngx_sizeof_ssz(t05_body2) - + ngx_sizeof_ssz(t06_list1) - + ngx_sizeof_ssz(t_parentdir_entry) - + ngx_sizeof_ssz(t07_list2) - ; + if (alcf->show_path) + len = r->uri.len + + ngx_sizeof_ssz(t05_body2) + + ngx_sizeof_ssz(t06_list1) + + ngx_sizeof_ssz(t_parentdir_entry) + + ngx_sizeof_ssz(t07_list2) + + ngx_fancyindex_timefmt_calc_size (&alcf->time_format) * entries.nelts + ; + else + len = r->uri.len + + ngx_sizeof_ssz(t06_list1) + + ngx_sizeof_ssz(t_parentdir_entry) + + ngx_sizeof_ssz(t07_list2) + + ngx_fancyindex_timefmt_calc_size (&alcf->time_format) * entries.nelts + ; + + /* + * If we are a the root of the webserver (URI = "/" --> length of 1), + * do not display the "Parent Directory" link. + */ + if (r->uri.len == 1) { + len -= ngx_sizeof_ssz(t_parentdir_entry); + } entry = entries.elts; for (i = 0; i < entries.nelts; i++) { @@ -609,14 +767,15 @@ len += ngx_sizeof_ssz("<tr><td><a href=\"") + entry[i].name.len + entry[i].escape /* Escaped URL */ + ngx_sizeof_ssz("?C=x&O=y") /* URL sorting arguments */ + + ngx_sizeof_ssz("\" title=\"") + + entry[i].name.len + entry[i].utf_len + ngx_sizeof_ssz("\">") + entry[i].name.len + entry[i].utf_len + alcf->name_length + ngx_sizeof_ssz(">") + ngx_sizeof_ssz("</a></td><td>") + 20 /* File size */ - + ngx_sizeof_ssz("</td><td>") - + ngx_sizeof_ssz(" 28-Sep-1970 12:00 ") - + ngx_sizeof_ssz("</td></tr>\n") + + ngx_sizeof_ssz("</td><td>") /* Date prefix */ + + ngx_sizeof_ssz("</td></tr>\n") /* Date suffix */ + 2 /* CR LF */ ; } @@ -707,31 +866,48 @@ /* Sort entries, if needed */ if (entries.nelts > 1) { - ngx_qsort(entry, (size_t) entries.nelts, + /* Use ngx_sort for stability */ + ngx_sort(entry, (size_t) entries.nelts, sizeof(ngx_http_fancyindex_entry_t), sort_cmp_func); + + if (alcf->dirs_first) + { + /* Sort directories first */ + ngx_sort(entry, (size_t) entries.nelts, + sizeof(ngx_http_fancyindex_entry_t), + ngx_http_fancyindex_cmp_entries_dirs_first); + } + } - b->last = ngx_cpymem_str(b->last, r->uri); - b->last = ngx_cpymem_ssz(b->last, t05_body2); + /* Display the path, if needed */ + if (alcf->show_path){ + b->last = ngx_cpymem_str(b->last, r->uri); + b->last = ngx_cpymem_ssz(b->last, t05_body2); + } + + /* Open the <table> tag */ b->last = ngx_cpymem_ssz(b->last, t06_list1); tp = ngx_timeofday(); - /* "Parent dir" entry, always first */ - b->last = ngx_cpymem_ssz(b->last, - "<tr>" - "<td><a href=\"../"); - if (*sort_url_args) { - b->last = ngx_cpymem(b->last, - sort_url_args, - ngx_sizeof_ssz("?C=N&O=A")); - } - b->last = ngx_cpymem_ssz(b->last, - "\">Parent directory/</a></td>" - "<td>-</td>" - "<td>-</td>" - "</tr>"); + /* "Parent dir" entry, always first if displayed */ + if (r->uri.len > 1) { + b->last = ngx_cpymem_ssz(b->last, + "<tr>" + "<td><a href=\"../"); + if (*sort_url_args) { + b->last = ngx_cpymem(b->last, + sort_url_args, + ngx_sizeof_ssz("?C=N&O=A")); + } + b->last = ngx_cpymem_ssz(b->last, + "\">Parent directory/</a></td>" + "<td>-</td>" + "<td>-</td>" + "</tr>"); + } /* Entries for directories and files */ for (i = 0; i < entries.nelts; i++) { @@ -758,6 +934,9 @@ } *b->last++ = '"'; + b->last = ngx_cpymem_ssz(b->last, " title=\""); + b->last = ngx_cpymem_str(b->last, entry[i].name); + *b->last++ = '"'; *b->last++ = '>'; len = entry[i].utf_len; @@ -842,14 +1021,9 @@ } ngx_gmtime(entry[i].mtime + tp->gmtoff * 60 * alcf->localtime, &tm); - - b->last = ngx_sprintf(b->last, "</td><td>%02d-%s-%d %02d:%02d</td></tr>", - tm.ngx_tm_mday, - months[tm.ngx_tm_mon - 1], - tm.ngx_tm_year, - tm.ngx_tm_hour, - tm.ngx_tm_min); - + b->last = ngx_cpymem_ssz(b->last, "</td><td>"); + b->last = ngx_fancyindex_timefmt(b->last, &alcf->time_format, &tm); + b->last = ngx_cpymem_ssz(b->last, "</td></tr>"); *b->last++ = CR; *b->last++ = LF; @@ -899,7 +1073,7 @@ return NGX_DECLINED; } - if ((rc = make_content_buf(r, &out[0].buf, alcf) != NGX_OK)) + if ((rc = make_content_buf(r, &out[0].buf, alcf)) != NGX_OK) return rc; out[0].buf->last_in_chain = 1; @@ -910,8 +1084,7 @@ r->headers_out.content_type.data = (u_char *) "text/html"; rc = ngx_http_send_header(r); - - if (rc != NGX_OK || r->header_only) + if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) return rc; if (alcf->header.len > 0) { @@ -943,7 +1116,7 @@ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http fancyindex: header subrequest status = %i", sr->headers_out.status); - /* ngx_http_subrequest returns NGX_OK(0), not NGX_HTTP_OK(200) */ + /* ngx_http_subrequest returns NGX_OK(0), not NGX_HTTP_OK(200) */ if (sr->headers_out.status != NGX_OK) { /* * XXX: Should we write a message to the error log just in case @@ -1038,9 +1211,8 @@ return (r != r->main) ? rc : ngx_http_send_special(r, NGX_HTTP_LAST); } - -static int ngx_libc_cdecl -ngx_http_fancyindex_cmp_entries_name_desc(const void *one, const void *two) +static ngx_int_t ngx_libc_cdecl +ngx_http_fancyindex_cmp_entries_dirs_first(const void *one, const void *two) { ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one; ngx_http_fancyindex_entry_t *second = (ngx_http_fancyindex_entry_t *) two; @@ -1053,97 +1225,67 @@ return 1; } + return 0; +} + + +static ngx_int_t ngx_libc_cdecl +ngx_http_fancyindex_cmp_entries_name_desc(const void *one, const void *two) +{ + ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one; + ngx_http_fancyindex_entry_t *second = (ngx_http_fancyindex_entry_t *) two; + return (int) ngx_strcmp(second->name.data, first->name.data); } -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_size_desc(const void *one, const void *two) { ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one; ngx_http_fancyindex_entry_t *second = (ngx_http_fancyindex_entry_t *) two; - /* move the directories to the start */ - if (first->dir && !second->dir) { - return -1; - } - if (!first->dir && second->dir) { - return 1; - } - - return second->size - first->size; + return (int) (second->size - first->size); } -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_mtime_desc(const void *one, const void *two) { ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one; ngx_http_fancyindex_entry_t *second = (ngx_http_fancyindex_entry_t *) two; - /* move the directories to the start */ - if (first->dir && !second->dir) { - return -1; - } - if (!first->dir && second->dir) { - return 1; - } - - return second->mtime - first->mtime; + return (int) (second->mtime - first->mtime); } -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_name_asc(const void *one, const void *two) { ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one; ngx_http_fancyindex_entry_t *second = (ngx_http_fancyindex_entry_t *) two; - /* move the directories to the start */ - if (first->dir && !second->dir) { - return -1; - } - if (!first->dir && second->dir) { - return 1; - } - return (int) ngx_strcmp(first->name.data, second->name.data); } -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_size_asc(const void *one, const void *two) { ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one; ngx_http_fancyindex_entry_t *second = (ngx_http_fancyindex_entry_t *) two; - /* move the directories to the start */ - if (first->dir && !second->dir) { - return -1; - } - if (!first->dir && second->dir) { - return 1; - } - - return first->size - second->size; + return (int) (first->size - second->size); } -static int ngx_libc_cdecl +static ngx_int_t ngx_libc_cdecl ngx_http_fancyindex_cmp_entries_mtime_asc(const void *one, const void *two) { ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one; ngx_http_fancyindex_entry_t *second = (ngx_http_fancyindex_entry_t *) two; - /* move the directories to the start */ - if (first->dir && !second->dir) { - return -1; - } - if (!first->dir && second->dir) { - return 1; - } - - return first->mtime - second->mtime; + return (int) (first->mtime - second->mtime); } @@ -1171,17 +1313,24 @@ /* * Set by ngx_pcalloc: - * conf->header.len = 0 - * conf->header.data = NULL - * conf->footer.len = 0 - * conf->footer.data = NULL + * conf->header.len = 0 + * conf->header.data = NULL + * conf->footer.len = 0 + * conf->footer.data = NULL + * conf->css_href.len = 0 + * conf->css_href.data = NULL + * conf->time_format.len = 0 + * conf->time_format.data = NULL */ - conf->enable = NGX_CONF_UNSET; - conf->default_sort = NGX_CONF_UNSET_UINT; - conf->localtime = NGX_CONF_UNSET; - conf->name_length = NGX_CONF_UNSET_UINT; - conf->exact_size = NGX_CONF_UNSET; - conf->ignore = NGX_CONF_UNSET_PTR; + conf->enable = NGX_CONF_UNSET; + conf->default_sort = NGX_CONF_UNSET_UINT; + conf->dirs_first = NGX_CONF_UNSET; + conf->localtime = NGX_CONF_UNSET; + conf->name_length = NGX_CONF_UNSET_UINT; + conf->exact_size = NGX_CONF_UNSET; + conf->ignore = NGX_CONF_UNSET_PTR; + conf->hide_symlinks = NGX_CONF_UNSET; + conf->show_path = NGX_CONF_UNSET; return conf; } @@ -1193,16 +1342,30 @@ ngx_http_fancyindex_loc_conf_t *prev = parent; ngx_http_fancyindex_loc_conf_t *conf = child; + (void) cf; /* unused */ + ngx_conf_merge_value(conf->enable, prev->enable, 0); ngx_conf_merge_uint_value(conf->default_sort, prev->default_sort, NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME); + ngx_conf_merge_value(conf->dirs_first, prev->dirs_first, 1); 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_uint_value(conf->name_length, prev->name_length, 50); ngx_conf_merge_str_value(conf->header, prev->header, ""); ngx_conf_merge_str_value(conf->footer, prev->footer, ""); + ngx_conf_merge_str_value(conf->css_href, prev->css_href, ""); + ngx_conf_merge_str_value(conf->time_format, prev->time_format, "%Y-%b-%d %H:%M"); ngx_conf_merge_ptr_value(conf->ignore, prev->ignore, NULL); + ngx_conf_merge_value(conf->hide_symlinks, prev->hide_symlinks, 0); + + /* Just make sure we haven't disabled the show_path directive without providing a custom header */ + if (conf->show_path == 0 && conf->header.len == 0) + { + ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "FancyIndex : cannot set show_path to off without providing a custom header !"); + return NGX_CONF_ERROR; + } return NGX_CONF_OK; } @@ -1214,6 +1377,8 @@ ngx_http_fancyindex_loc_conf_t *alcf = conf; ngx_str_t *value; + (void) cmd; /* unused */ + #if (NGX_PCRE) ngx_uint_t i; ngx_regex_elt_t *re; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/00-build-artifacts.test new/ngx-fancyindex-0.4.1/t/00-build-artifacts.test --- old/ngx-fancyindex-0.3.5/t/00-build-artifacts.test 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/00-build-artifacts.test 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,22 @@ +#! /bin/bash +cat <<--- +This test checks that the built Nginx either has the dynamic fancyindex +module available, or that it's not there (for static builds). +-- + +readonly nginx_path="${PREFIX}/sbin/nginx" +readonly so_path="${PREFIX}/modules/ngx_http_fancyindex_module.so" + +if [[ ! -x ${nginx_path} ]] ; then + fail "executable binary not found at '%s'\n" "${nginx_path}" +fi + +if ${DYNAMIC} ; then + if [[ ! -r ${so_path} ]] ; then + fail "module not found at '%s'\n" "${so_path}" + fi +else + if [[ -r ${so_path} ]] ; then + fail "module should not exist at '%s'\n" "${so_path}" + fi +fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/01-smoke-hasindex.test new/ngx-fancyindex-0.4.1/t/01-smoke-hasindex.test --- old/ngx-fancyindex-0.3.5/t/01-smoke-hasindex.test 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/01-smoke-hasindex.test 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,7 @@ +#! /bin/bash +cat <<--- +This test fetches the root directory served by Nginx, which has no index file, +and checks that the output contains something that resembles a directory index. +-- +nginx_start +grep 'Index of' <( fetch ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/02-smoke-indexisfancy.test new/ngx-fancyindex-0.4.1/t/02-smoke-indexisfancy.test --- old/ngx-fancyindex-0.3.5/t/02-smoke-indexisfancy.test 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/02-smoke-indexisfancy.test 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,11 @@ +#! /bin/bash +cat <<--- +This test fetches the root directory served by Nginx, which has no index file, +and checks that the output contains something that resembles the output from +the fancyindex module. +-- +nginx_start +content=$(fetch --with-headers) +grep 'Index of /' <<< "${content}" # It is an index +grep '\<table\>' <<< "${content}" # It contains a table +grep '^ Content-Type:[[:space:]]*text/html' <<< "${content}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/build-and-run new/ngx-fancyindex-0.4.1/t/build-and-run --- old/ngx-fancyindex-0.3.5/t/build-and-run 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/build-and-run 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,25 @@ +#! /bin/bash +set -e + +if [[ $# -lt 1 || $# -gt 2 ]] ; then + echo "Usage: $0 <nginx-version> [1]" 1>&2 + exit 1 +fi + +readonly NGINX=$1 + +if [[ $2 -eq 1 ]] ; then + readonly DYNAMIC=$2 +fi + +cd "$(dirname "$0")/.." +wget -O - http://nginx.org/download/nginx-${NGINX}.tar.gz | tar -xzf - +rm -rf prefix/ +cd nginx-${NGINX} +./configure \ + --add-${DYNAMIC:+dynamic-}module=.. \ + --with-http_addition_module \ + --prefix="$(pwd)/../prefix" +make install +cd .. +exec ./t/run prefix ${DYNAMIC} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/has-index/index.html new/ngx-fancyindex-0.4.1/t/has-index/index.html --- old/ngx-fancyindex-0.3.5/t/has-index/index.html 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/has-index/index.html 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8" /> + <title>Index file test</title> + </head> + <body> + This is <code>index.html</code>. + </body> +</html> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/has-index.test new/ngx-fancyindex-0.4.1/t/has-index.test --- old/ngx-fancyindex-0.3.5/t/has-index.test 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/has-index.test 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,7 @@ +#! /bin/bash +cat <<--- +This test ensures that the "index.html" is returned instead of a directory +listing when fetching a directory which contains an index file. +-- +nginx_start +diff -u "${TESTDIR}/has-index/index.html" <( fetch /has-index/ ) 1>&2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/nginx.conf new/ngx-fancyindex-0.4.1/t/nginx.conf --- old/ngx-fancyindex-0.3.5/t/nginx.conf 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/nginx.conf 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,25 @@ +worker_processes 1; + + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + server { + listen 80; + server_name localhost; + location / { + root html; + index index.html index.htm; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/preamble new/ngx-fancyindex-0.4.1/t/preamble --- old/ngx-fancyindex-0.3.5/t/preamble 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/preamble 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,84 @@ +#! /bin/bash +# +# preamble +# Copyright (C) 2016 Adrian Perez <[email protected]> +# +# Distributed under terms of the MIT license. +# + +function nginx_conf_generate () { + if ${DYNAMIC} ; then + echo 'load_module modules/ngx_http_fancyindex_module.so;' + fi + cat <<-EOF + worker_processes 1; + events { worker_connections 1024; } + http { + include mime.types; + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + server { + server_name localhost; + listen 127.0.0.1:8888; + root ${TESTDIR}; + error_page 500 502 503 504 /50x.html; + location = /50x.html { root html; } + location / { + index index.html; + fancyindex on; + $* + } + } + } + EOF +} + +readonly NGINX_CONF="${PREFIX}/conf/nginx.conf" +readonly NGINX_PID="${PREFIX}/logs/nginx.pid" +rm -f "${NGINX_CONF}" "${NGINX_PID}" +mkdir -p "${PREFIX}/logs" + +function nginx () { + env - PATH="${PATH}" "${PREFIX}/sbin/nginx" "$@" +} + +function nginx_conf () { + nginx_conf_generate "$@" > "${NGINX_CONF}" +} + +function nginx_is_running () { + [[ -r ${NGINX_PID} ]] && kill -0 $(< "${NGINX_PID}") +} + +function nginx_stop () { + if nginx_is_running ; then nginx -s stop ; fi + rm -f "${NGINX_PID}" +} +trap nginx_stop EXIT + +function nginx_start () { + if [[ $# -gt 0 || ! -r ${NGINX_CONF} ]] ; then nginx_conf "$@" ; fi + nginx_stop # Ensure that it is not running. + nginx +} + +function fetch () { + local -a opts=( -q ) + if [[ $1 = --with-headers ]] ; then + opts+=( -S ) + shift + fi + wget "${opts[@]}" -O- "http://localhost:8888${1:-/}" 2>&1 +} + +function fail () { + printf "(FF) " + printf "$@" + exit 1 +} 1>&2 + +function warn () { + printf "(WW)" + printf "$@" +} 1>&2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/t/run new/ngx-fancyindex-0.4.1/t/run --- old/ngx-fancyindex-0.3.5/t/run 1970-01-01 01:00:00.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/t/run 2016-08-18 19:49:47.000000000 +0200 @@ -0,0 +1,67 @@ +#! /bin/bash +set -e + +if [[ $# -lt 1 || $# -gt 2 ]] ; then + echo "Usage: $0 <prefix-path> [1]" 1>&2 + exit 1 +fi + +# Obtain the absolute path to the tests directory +pushd "$(dirname "$0")" &> /dev/null +readonly T=$(pwd) +popd &> /dev/null +export T + +# Same for the nginx prefix directory +pushd "$1" &> /dev/null +readonly prefix=$(pwd) +popd &> /dev/null + +dynamic=false +if [[ $# -gt 1 && $2 -eq 1 ]] ; then + dynamic=true +fi +readonly dynamic + +declare -a t_pass=( ) +declare -a t_fail=( ) + +for t in "$T"/*.test ; do + name="t/${t##*/}" + name=${name%.test} + printf "${name} ... " + errfile="${name}.err" + outfile="${name}.out" + shfile="${name}.sh" + cat > "${shfile}" <<-EOF + readonly DYNAMIC=${dynamic} + readonly TESTDIR='$T' + readonly PREFIX='${prefix}' + $(< "$T/preamble") + $(< "$t") + EOF + if bash -e "${shfile}" > "${outfile}" 2> "${errfile}" ; then + t_pass+=( "${name}" ) + printf '[1;32mpassed[0;0m\n' + else + t_fail+=( "${name}" ) + printf '[1;31mfailed[0;0m\n' + fi +done + +for name in "${t_fail[@]}" ; do + echo + printf '[1m===[0m %s.out\n' "${name}" + cat "${name}.out" + echo + printf '[1m===[0m %s.err\n' "${name}" + cat "${name}.err" + echo +done + +printf '[1m===[0m passed/failed/total: [1;32m%d[0;0m/[1;31m%d[0;0m/[1m%d[0m\n' \ + ${#t_pass[@]} ${#t_fail[@]} $(( ${#t_pass[@]} + ${#t_fail[@]} )) + +if [[ ${#t_fail[@]} -gt 0 ]] ; then + exit 1 +fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/template.h new/ngx-fancyindex-0.4.1/template.h --- old/ngx-fancyindex-0.3.5/template.h 2015-02-19 13:16:36.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/template.h 2016-08-18 19:49:47.000000000 +0200 @@ -66,9 +66,9 @@ "\n" "<thead>" "<tr>" -"<th><a href=\"?C=N&O=A\">File Name</a> <a href=\"?C=N&O=D\"> ↓ </a></th>" -"<th><a href=\"?C=S&O=A\">File Size</a> <a href=\"?C=S&O=D\"> ↓ </a></th>" -"<th><a href=\"?C=M&O=A\">Date</a> <a href=\"?C=M&O=D\"> ↓ </a></th>" +"<th><a href=\"?C=N&O=A\">File Name</a> <a href=\"?C=N&O=D\"> ↓ </a></th>" +"<th><a href=\"?C=S&O=A\">File Size</a> <a href=\"?C=S&O=D\"> ↓ </a></th>" +"<th><a href=\"?C=M&O=A\">Date</a> <a href=\"?C=M&O=D\"> ↓ </a></th>" "</tr>" "</thead>" "\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ngx-fancyindex-0.3.5/template.html new/ngx-fancyindex-0.4.1/template.html --- old/ngx-fancyindex-0.3.5/template.html 2015-02-19 13:16:36.000000000 +0100 +++ new/ngx-fancyindex-0.4.1/template.html 2016-08-18 19:49:47.000000000 +0200 @@ -64,9 +64,9 @@ <thead> <tr> - <th><a href="?C=N&O=A">File Name</a> <a href="?C=N&O=D"> ↓ </a></th> - <th><a href="?C=S&O=A">File Size</a> <a href="?C=S&O=D"> ↓ </a></th> - <th><a href="?C=M&O=A">Date</a> <a href="?C=M&O=D"> ↓ </a></th> + <th><a href="?C=N&O=A">File Name</a> <a href="?C=N&O=D"> ↓ </a></th> + <th><a href="?C=S&O=A">File Size</a> <a href="?C=S&O=D"> ↓ </a></th> + <th><a href="?C=M&O=A">Date</a> <a href="?C=M&O=D"> ↓ </a></th> </tr> </thead>
