Compare commits
No commits in common. "master" and "v0.4.3" have entirely different histories.
37 changed files with 330 additions and 928 deletions
4
.gitattributes
vendored
4
.gitattributes
vendored
|
@ -1,4 +0,0 @@
|
|||
/.gitignore export-ignore
|
||||
/.travis.yml export-ignore
|
||||
/make-dist export-ignore
|
||||
t/* text eol=lf
|
49
.github/workflows/ci.yml
vendored
49
.github/workflows/ci.yml
vendored
|
@ -1,49 +0,0 @@
|
|||
---
|
||||
name: Build
|
||||
on: [pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-18.04]
|
||||
compiler: [gcc, clang]
|
||||
nginx:
|
||||
# Mainline
|
||||
- 1.23.3
|
||||
# Stable.
|
||||
- 1.22.1
|
||||
# First version with loadable module support.
|
||||
- 1.9.15
|
||||
# Oldest supported version.
|
||||
- 0.8.55
|
||||
dynamic: [0, 1]
|
||||
exclude:
|
||||
- nginx: 0.8.55
|
||||
dynamic: 1
|
||||
- nginx: 0.8.55
|
||||
os: macos-latest
|
||||
- compiler: gcc
|
||||
os: macos-latest
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
CFLAGS: "-Wno-error"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Install Packages
|
||||
run: |
|
||||
case $RUNNER_OS in
|
||||
Linux )
|
||||
sudo apt update
|
||||
sudo apt install -y libpcre3-dev libssl-dev
|
||||
;;
|
||||
* )
|
||||
;;
|
||||
esac
|
||||
t/get-pup || echo 'Tests needing pup will be skipped'
|
||||
- name: Test
|
||||
env:
|
||||
CC: ${{ matrix.compiler }}
|
||||
run: t/build-and-run ${{ matrix.nginx }} ${{ matrix.dynamic }}
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,8 +1,4 @@
|
|||
*.sw[op]
|
||||
/nginx-*
|
||||
/t/*.sh
|
||||
/t/*.out
|
||||
/t/*.err
|
||||
/t/pup*
|
||||
/t/bug*/
|
||||
/prefix/
|
||||
|
|
39
.travis.yml
Normal file
39
.travis.yml
Normal file
|
@ -0,0 +1,39 @@
|
|||
language: c
|
||||
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
|
||||
env:
|
||||
# Mainline.
|
||||
- NGINX=1.15.0
|
||||
- NGINX=1.15.0 DYNAMIC=1
|
||||
# Stable.
|
||||
- NGINX=1.14.0
|
||||
- NGINX=1.14.0 DYNAMIC=1
|
||||
# Other configurations.
|
||||
- NGINX=1.12.2
|
||||
- NGINX=1.12.2 DYNAMIC=1
|
||||
- NGINX=1.10.3
|
||||
# Version 1.9.15 was the first with loadable module support.
|
||||
- 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/get-pup || echo 'Tests needing pup will be skipped'
|
||||
- t/build-and-run ${NGINX} ${DYNAMIC}
|
58
CHANGELOG.md
58
CHANGELOG.md
|
@ -3,58 +3,6 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.5.2] - 2021-10-28
|
||||
### Fixed
|
||||
- Properly escape file names to ensure that file names are never renreded
|
||||
as HTML. (Patch by Anthony Ryan <<anthonyryan1@gmail.com>>,
|
||||
[#128](https://github.com/aperezdc/ngx-fancyindex/pull/128).)
|
||||
|
||||
## [0.5.1] - 2020-10-26
|
||||
### Fixed
|
||||
- Properly handle optional second argument to `fancyindex_header` and
|
||||
`fancyindex_footer`
|
||||
([#117](https://github.com/aperezdc/ngx-fancyindex/issues/117)).
|
||||
|
||||
## [0.5.0] - 2020-10-24
|
||||
### Added
|
||||
- New option `fancyindex_show_dotfiles`. (Path by Joshua Shaffer
|
||||
<<joshua.shaffer@icmrl.net>>.)
|
||||
- The `fancyindex_header` and `fancyindex_footer` options now support local
|
||||
files properly, by means of a `local` flag. (Patches by JoungKyun Kim
|
||||
<<joungkyun@gmail.com>> and Adrián Pérez <<aperez@igalia.com>>.)
|
||||
|
||||
### Changed
|
||||
- Improved performance of directory entry sorting, which should be quite
|
||||
noticeable for directories with thousands of files. (Patch by
|
||||
[Yuxiang Zhang](https://github.com/z4yx).)
|
||||
- The minimum Nginx version supported by the module is now 0.8.x.
|
||||
|
||||
### Fixed
|
||||
- Properly escape square brackets in directory entry names when the module
|
||||
is built with older versions of Nginx. (Patch by Adrián Pérez
|
||||
<<aperez@igalia.com>>.)
|
||||
- Fix directory entry listing not being shown when using the
|
||||
[nginx-auth-ldap](https://github.com/kvspb/nginx-auth-ldap) module. (Patch
|
||||
by JoungKyun Kim <<joungkyun@gmail.com>>.)
|
||||
|
||||
## [0.4.4] - 2020-02-19
|
||||
### Added
|
||||
- New option `fancyindex_hide_parent_dir`, which disables generating
|
||||
links to parent directories in listings. (Patch by Kawai Ryota
|
||||
<<admin@mail.kr-kp.com>>.)
|
||||
|
||||
### Changed
|
||||
- Each table row is now separated by a new line (as a matter of fact,
|
||||
a `CRLF` sequence), which makes it easier to parse output using simple
|
||||
text tools. (Patch by Anders Trier <<anders.trier.olesen@gmail.com>>.)
|
||||
- Some corrections and additions to the README file. (Patches by Nicolas
|
||||
Carpi <<nicolas.carpi@curie.fr>> and David Beitey <<david@davidjb.com>>.)
|
||||
|
||||
### Fixed
|
||||
- Use correct character references for `&` characters in table sorter URLs
|
||||
within the template (Patch by David Beitey <<david@davidjb.com>>.)
|
||||
- Properly encode filenames when used as URI components.
|
||||
|
||||
## [0.4.3] - 2018-07-03
|
||||
### Added
|
||||
- Table cells now have class names, which allows for better CSS styling.
|
||||
|
@ -182,11 +130,7 @@ All notable changes to this project will be documented in this file.
|
|||
- `NEWS.rst` file, to act as change log.
|
||||
|
||||
|
||||
[Unreleased]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.5.2...HEAD
|
||||
[0.5.2]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.5.1...v0.5.2
|
||||
[0.5.1]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.5.0...v0.5.1
|
||||
[0.5.0]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.4...v0.5.0
|
||||
[0.4.4]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.3...v0.4.4
|
||||
[Unreleased]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.3...HEAD
|
||||
[0.4.3]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.2...v0.4.3
|
||||
[0.4.2]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.1...v0.4.2
|
||||
[0.4.1]: https://github.com/aperezdc/ngx-fancyindex/compare/v0.4.0...v0.4.1
|
||||
|
|
|
@ -21,10 +21,4 @@ is known to work flawlessly. Just do:
|
|||
$ awk -f template.awk template.html > template.h
|
||||
|
||||
If your copy of `awk` is not the GNU implementation, you will need to
|
||||
install it and use `gawk` instead in the command line above.
|
||||
|
||||
This includes macOS where the current built-in `awk` (currently version
|
||||
20070501 at time of testing on 10.13.6) doesn't apply correctly and causes
|
||||
characters to be omitted from the output. `gawk` can be installed with a
|
||||
package manager such as [Homebrew](https://brew.sh) or
|
||||
[MacPorts](https://ports.macports.org/port/gawk).
|
||||
install it and use `gawk` instead in the command line above.
|
||||
|
|
106
README.rst
106
README.rst
|
@ -2,8 +2,8 @@
|
|||
Nginx Fancy Index module
|
||||
========================
|
||||
|
||||
.. image:: https://travis-ci.com/aperezdc/ngx-fancyindex.svg?branch=master
|
||||
:target: https://travis-ci.com/aperezdc/ngx-fancyindex
|
||||
.. image:: https://travis-ci.org/aperezdc/ngx-fancyindex.svg?branch=master
|
||||
:target: https://travis-ci.org/aperezdc/ngx-fancyindex
|
||||
:alt: Build Status
|
||||
|
||||
.. contents::
|
||||
|
@ -11,11 +11,11 @@ Nginx Fancy Index module
|
|||
The Fancy Index module makes possible the generation of file listings, like
|
||||
the built-in `autoindex <http://wiki.nginx.org/NginxHttpAutoindexModule>`__
|
||||
module does, but adding a touch of style. This is possible because the module
|
||||
allows a certain degree of customization of the generated content:
|
||||
module allows a certain degree of customization of the generated content:
|
||||
|
||||
* Custom headers, either local or stored remotely.
|
||||
* Custom footers, either local or stored remotely.
|
||||
* Add your own CSS style rules.
|
||||
* Custom headers. Either local or stored remotely.
|
||||
* Custom footers. Either local or stored remotely.
|
||||
* Add you own CSS style rules.
|
||||
* Allow choosing to sort elements by name (default), modification time, or
|
||||
size; both ascending (default), or descending.
|
||||
|
||||
|
@ -26,35 +26,33 @@ server written by `Igor Sysoev <http://sysoev.ru>`__.
|
|||
Requirements
|
||||
============
|
||||
|
||||
CentOS, RHEL, Fedora Linux
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
CentOS 7
|
||||
~~~~~~~~
|
||||
|
||||
For users of the `official stable <https://www.nginx.com/resources/wiki/start/topics/tutorials/install/>`__ Nginx repository, `extra packages repository with dynamic modules <https://www.getpagespeed.com/redhat>`__ is available and fancyindex is included.
|
||||
|
||||
Install repository configuration, then the module package::
|
||||
Install directly::
|
||||
|
||||
yum -y install https://extras.getpagespeed.com/release-latest.rpm
|
||||
yum -y install nginx-module-fancyindex
|
||||
yum install https://extras.getpagespeed.com/redhat/7/x86_64/RPMS/nginx-module-fancyindex-1.12.0.0.4.1-1.el7.gps.x86_64.rpm
|
||||
|
||||
Alternatively, add extras repository first (for future updates) and install the module::
|
||||
|
||||
yum install nginx-module-fancyindex
|
||||
|
||||
Then load the module in `/etc/nginx/nginx.conf` using::
|
||||
|
||||
load_module "modules/ngx_http_fancyindex_module.so";
|
||||
|
||||
macOS
|
||||
~~~~~
|
||||
|
||||
Users can `install Nginx on macOS with MacPorts <https://ports.macports.org/port/nginx>`__; fancyindex is included::
|
||||
|
||||
sudo port install nginx
|
||||
|
||||
Other platforms
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
In most other cases you will need the sources for Nginx_. Any version starting
|
||||
from the 0.8 series should work.
|
||||
In most other cases you will need the sources for Nginx_. Any version starting from the 0.7
|
||||
series onwards will work. Note that the modules *might* compile with
|
||||
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 <https://nginx.org/en/docs/http/ngx_http_addition_module.html>`_
|
||||
you will also need the `ngx_http_addition_module <http://nginx.org/en/docs/http/ngx_http_addition_module.html>`_
|
||||
built into Nginx.
|
||||
|
||||
|
||||
|
@ -117,8 +115,8 @@ achieved using the module:
|
|||
`@TheInsomniac <https://github.com/TheInsomniac>`__. Uses custom header and
|
||||
footer.
|
||||
* `Theme <https://github.com/Naereen/Nginx-Fancyindex-Theme>`__ by
|
||||
`@Naereen <https://github.com/Naereen/>`__. Uses custom header and footer. The
|
||||
header includes a search field to filter by file name using JavaScript.
|
||||
`@Naereen <https://github.com/Naereen/>`__. Uses custom header and footer, the
|
||||
header includes search field to filter by filename using JavaScript.
|
||||
* `Theme <https://github.com/fraoustin/Nginx-Fancyindex-Theme>`__ by
|
||||
`@fraoustin <https://github.com/fraoustin>`__. Responsive theme using
|
||||
Material Design elements.
|
||||
|
@ -146,15 +144,6 @@ fancyindex_default_sort
|
|||
:Description:
|
||||
Defines sorting criterion by default.
|
||||
|
||||
fancyindex_case_sensitive
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_case_sensitive* [*on* | *off*]
|
||||
:Default: fancyindex_case_sensitive on
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
If enabled (default setting), sorting by name will be case-sensitive.
|
||||
If disabled, case will be ignored when sorting by name.
|
||||
|
||||
fancyindex_directories_first
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_directories_first* [*on* | *off*]
|
||||
|
@ -181,26 +170,32 @@ fancyindex_exact_size
|
|||
:Default: fancyindex_exact_size on
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
Defines how to represent file sizes in the directory listing: either
|
||||
Defines how to represent file sizes in the directory listing; either
|
||||
accurately, or rounding off to the kilobyte, the megabyte and the
|
||||
gigabyte.
|
||||
|
||||
fancyindex_name_length
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_name_length length*
|
||||
:Default: fancyindex_name_length 50
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
Defines the maximum file name length limit in bytes.
|
||||
|
||||
fancyindex_footer
|
||||
~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_footer path* [*subrequest* | *local*]
|
||||
:Syntax: *fancyindex_footer path*
|
||||
:Default: fancyindex_footer ""
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
Specifies which file should be inserted at the foot of directory listings.
|
||||
If set to an empty string, the default footer supplied by the module will
|
||||
be sent. The optional parameter indicates whether the *path* is to be
|
||||
treated as a URI to load using a *subrequest* (the default), or whether
|
||||
it refers to a *local* file.
|
||||
be sent.
|
||||
|
||||
.. note:: Using this directive needs the ngx_http_addition_module_ built
|
||||
into Nginx.
|
||||
|
||||
.. warning:: When inserting custom a header/footer, a subrequest will be
|
||||
.. 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.
|
||||
External URLs are totally untested and using them will make Nginx_ block
|
||||
|
@ -210,49 +205,38 @@ fancyindex_footer
|
|||
|
||||
fancyindex_header
|
||||
~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_header path* [*subrequest* | *local*]
|
||||
:Syntax: *fancyindex_header path*
|
||||
:Default: fancyindex_header ""
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
Specifies which file should be inserted at the head of directory listings.
|
||||
If set to an empty string, the default header supplied by the module will
|
||||
be sent. The optional parameter indicates whether the *path* is to be
|
||||
treated as a URI to load using a *subrequest* (the default), or whether
|
||||
it refers to a *local* file.
|
||||
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 or not to output the path and the closing </h1> tag after the header.
|
||||
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_show_dotfiles
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_show_dotfiles* [*on* | *off*]
|
||||
:Default: fancyindex_show_dotfiles off
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
Whether to list files that are preceded with a dot. Normal convention is to
|
||||
hide these.
|
||||
|
||||
fancyindex_ignore
|
||||
~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_ignore string1 [string2 [... stringN]]*
|
||||
:Default: No default.
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
Specifies a list of file names which will not be shown in generated
|
||||
listings. If Nginx was built with PCRE support, strings are interpreted as
|
||||
Specifies a list of file names which will be not be shown in generated
|
||||
listings. If Nginx was built with PCRE support strings are interpreted as
|
||||
regular expressions.
|
||||
|
||||
fancyindex_hide_symlinks
|
||||
|
@ -263,14 +247,6 @@ fancyindex_hide_symlinks
|
|||
:Description:
|
||||
When enabled, generated listings will not contain symbolic links.
|
||||
|
||||
fancyindex_hide_parent_dir
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_hide_parent_dir* [*on* | *off*]
|
||||
:Default: fancyindex_hide_parent_dir off
|
||||
:Context: http, server, location
|
||||
:Description:
|
||||
When enabled, it will not show the parent directory.
|
||||
|
||||
fancyindex_localtime
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
:Syntax: *fancyindex_localtime* [*on* | *off*]
|
||||
|
@ -286,7 +262,7 @@ fancyindex_time_format
|
|||
:Context: http, server, location
|
||||
:Description:
|
||||
Format string used for timestamps. The format specifiers are a subset of
|
||||
those supported by the `strftime <https://linux.die.net/man/3/strftime>`_
|
||||
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:
|
||||
|
||||
|
@ -319,6 +295,6 @@ fancyindex_time_format
|
|||
* ``%Y``: Year as a decimal number including the century.
|
||||
|
||||
|
||||
.. _nginx: https://nginx.org
|
||||
.. _nginx: http://nginx.net
|
||||
|
||||
.. vim:ft=rst:spell:spelllang=en:
|
||||
|
|
10
make-dist
10
make-dist
|
@ -1,10 +0,0 @@
|
|||
#! /bin/sh
|
||||
set -e
|
||||
|
||||
GIT_TAG=$(git describe --tags HEAD)
|
||||
VERSION=${GIT_TAG#v}
|
||||
PV="ngx-fancyindex-${VERSION}"
|
||||
|
||||
set -x
|
||||
git archive --worktree-attributes --prefix="${PV}/" -o "${PV}.tar" "${GIT_TAG}"
|
||||
xz -f9 "${PV}.tar"
|
23
nginx-0.6-support.patch
Normal file
23
nginx-0.6-support.patch
Normal file
|
@ -0,0 +1,23 @@
|
|||
=== modified file 'ngx_http_fancyindex_module.c'
|
||||
--- ngx_http_fancyindex_module.c 2008-09-11 17:55:52 +0000
|
||||
+++ ngx_http_fancyindex_module.c 2008-12-10 01:33:43 +0000
|
||||
@@ -383,7 +383,7 @@
|
||||
entry->mtime = ngx_de_mtime(&dir);
|
||||
entry->size = ngx_de_size(&dir);
|
||||
entry->utf_len = (r->utf8)
|
||||
- ? ngx_utf8_length(entry->name.data, entry->name.len)
|
||||
+ ? ngx_utf_length(entry->name.data, entry->name.len)
|
||||
: len;
|
||||
}
|
||||
|
||||
@@ -478,8 +478,7 @@
|
||||
copy = NGX_HTTP_FANCYINDEX_NAME_LEN + 1;
|
||||
}
|
||||
|
||||
- b->last = ngx_utf8_cpystrn(b->last, entry[i].name.data,
|
||||
- copy, entry[i].name.len);
|
||||
+ b->last = ngx_utf_cpystrn(b->last, entry[i].name.data, copy);
|
||||
last = b->last;
|
||||
|
||||
} else {
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
* Base functionality heavy based upon the stock nginx autoindex module,
|
||||
* which in turn was made by Igor Sysoev, like the majority of nginx.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
* Distributed under terms of the BSD license.
|
||||
*/
|
||||
|
||||
#include <ngx_config.h>
|
||||
|
@ -37,7 +37,7 @@ static const char *short_weekday[] = {
|
|||
"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun",
|
||||
};
|
||||
static const char *long_weekday[] = {
|
||||
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday",
|
||||
"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Sunday",
|
||||
};
|
||||
static const char *short_month[] = {
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
|
@ -140,34 +140,27 @@ ngx_fancyindex_timefmt (u_char *buffer, const ngx_str_t *fmt, const ngx_tm_t *tm
|
|||
#undef DATETIME_CASE
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
ngx_str_t path;
|
||||
ngx_str_t local;
|
||||
} ngx_fancyindex_headerfooter_conf_t;
|
||||
|
||||
/**
|
||||
* Configuration structure for the fancyindex module. The configuration
|
||||
* commands defined in the module do fill in the members of this structure.
|
||||
*/
|
||||
typedef struct {
|
||||
ngx_flag_t enable; /**< Module is enabled. */
|
||||
ngx_uint_t default_sort; /**< Default sort criterion. */
|
||||
ngx_flag_t case_sensitive; /**< Case-sensitive name sorting */
|
||||
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_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_flag_t hide_parent; /**< Hide parent directory. */
|
||||
ngx_flag_t show_dot_files; /**< Show files that start with a dot.*/
|
||||
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 css_href; /**< Link to a CSS stylesheet, or empty if none. */
|
||||
ngx_str_t time_format; /**< Format used for file timestamps. */
|
||||
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_fancyindex_headerfooter_conf_t header;
|
||||
ngx_fancyindex_headerfooter_conf_t footer;
|
||||
ngx_array_t *ignore; /**< List of files to ignore in listings. */
|
||||
} ngx_http_fancyindex_loc_conf_t;
|
||||
|
||||
#define NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME 0
|
||||
|
@ -187,106 +180,6 @@ static ngx_conf_enum_t ngx_http_fancyindex_sort_criteria[] = {
|
|||
{ ngx_null_string, 0 }
|
||||
};
|
||||
|
||||
enum {
|
||||
NGX_HTTP_FANCYINDEX_HEADERFOOTER_SUBREQUEST,
|
||||
NGX_HTTP_FANCYINDEX_HEADERFOOTER_LOCAL,
|
||||
};
|
||||
|
||||
static ngx_uint_t
|
||||
headerfooter_kind(const ngx_str_t *value)
|
||||
{
|
||||
static const struct {
|
||||
ngx_str_t name;
|
||||
ngx_uint_t value;
|
||||
} values[] = {
|
||||
{ ngx_string("subrequest"), NGX_HTTP_FANCYINDEX_HEADERFOOTER_SUBREQUEST },
|
||||
{ ngx_string("local"), NGX_HTTP_FANCYINDEX_HEADERFOOTER_LOCAL },
|
||||
};
|
||||
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < sizeof(values) / sizeof(values[0]); i++) {
|
||||
if (value->len == values[i].name.len &&
|
||||
ngx_strcasecmp(value->data, values[i].name.data) == 0)
|
||||
{
|
||||
return values[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
return NGX_CONF_UNSET_UINT;
|
||||
}
|
||||
|
||||
static char*
|
||||
ngx_fancyindex_conf_set_headerfooter(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
{
|
||||
ngx_fancyindex_headerfooter_conf_t *item =
|
||||
(void*) (((char*) conf) + cmd->offset);
|
||||
ngx_str_t *values = cf->args->elts;
|
||||
|
||||
if (item->path.data)
|
||||
return "is duplicate";
|
||||
|
||||
item->path = values[1];
|
||||
|
||||
/* Kind of path. Default is "subrequest". */
|
||||
ngx_uint_t kind = NGX_HTTP_FANCYINDEX_HEADERFOOTER_SUBREQUEST;
|
||||
if (cf->args->nelts == 3) {
|
||||
kind = headerfooter_kind(&values[2]);
|
||||
if (kind == NGX_CONF_UNSET_UINT) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
||||
"unknown header/footer kind \"%V\"", &values[2]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
if (kind == NGX_HTTP_FANCYINDEX_HEADERFOOTER_LOCAL) {
|
||||
ngx_file_t file;
|
||||
ngx_file_info_t fi;
|
||||
ssize_t n;
|
||||
|
||||
ngx_memzero(&file, sizeof(ngx_file_t));
|
||||
file.log = cf->log;
|
||||
file.fd = ngx_open_file(item->path.data, NGX_FILE_RDONLY, 0, 0);
|
||||
if (file.fd == NGX_INVALID_FILE) {
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
||||
"cannot open file \"%V\"", &values[1]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (ngx_fd_info(file.fd, &fi) == NGX_FILE_ERROR) {
|
||||
ngx_close_file(file.fd);
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
||||
"cannot get info for file \"%V\"", &values[1]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
item->local.len = ngx_file_size(&fi);
|
||||
item->local.data = ngx_pcalloc(cf->pool, item->local.len + 1);
|
||||
if (item->local.data == NULL) {
|
||||
ngx_close_file(file.fd);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
n = item->local.len;
|
||||
while (n > 0) {
|
||||
ssize_t r = ngx_read_file(&file,
|
||||
item->local.data + file.offset,
|
||||
n,
|
||||
file.offset);
|
||||
if (r == NGX_ERROR) {
|
||||
ngx_close_file(file.fd);
|
||||
ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
|
||||
"cannot read file \"%V\"", &values[1]);
|
||||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
n -= r;
|
||||
}
|
||||
item->local.data[item->local.len] = '\0';
|
||||
}
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
#define NGX_HTTP_FANCYINDEX_PREALLOCATE 50
|
||||
|
||||
|
@ -328,7 +221,6 @@ typedef struct {
|
|||
ngx_str_t name;
|
||||
size_t utf_len;
|
||||
ngx_uint_t escape;
|
||||
ngx_uint_t escape_html;
|
||||
ngx_uint_t dir;
|
||||
time_t mtime;
|
||||
off_t size;
|
||||
|
@ -336,21 +228,19 @@ typedef struct {
|
|||
|
||||
|
||||
|
||||
static int ngx_libc_cdecl
|
||||
ngx_http_fancyindex_cmp_entries_name_cs_desc(const void *one, const void *two);
|
||||
static int ngx_libc_cdecl
|
||||
ngx_http_fancyindex_cmp_entries_name_ci_desc(const void *one, const void *two);
|
||||
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 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
|
||||
ngx_http_fancyindex_cmp_entries_name_cs_asc(const void *one, const void *two);
|
||||
static int ngx_libc_cdecl
|
||||
ngx_http_fancyindex_cmp_entries_name_ci_asc(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 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,
|
||||
|
@ -368,7 +258,7 @@ static char *ngx_http_fancyindex_ignore(ngx_conf_t *cf,
|
|||
void *conf);
|
||||
|
||||
static uintptr_t
|
||||
ngx_fancyindex_escape_filename(u_char *dst, u_char*src, size_t size);
|
||||
ngx_fancyindex_escape_uri(u_char *dst, u_char*src, size_t size);
|
||||
|
||||
/*
|
||||
* These are used only once per handler invocation. We can tell GCC to
|
||||
|
@ -379,6 +269,11 @@ static ngx_inline ngx_buf_t*
|
|||
make_header_buf(ngx_http_request_t *r, const ngx_str_t css_href)
|
||||
ngx_force_inline;
|
||||
|
||||
static ngx_inline ngx_buf_t*
|
||||
make_footer_buf(ngx_http_request_t *r)
|
||||
ngx_force_inline;
|
||||
|
||||
|
||||
|
||||
static ngx_command_t ngx_http_fancyindex_commands[] = {
|
||||
|
||||
|
@ -396,13 +291,6 @@ static ngx_command_t ngx_http_fancyindex_commands[] = {
|
|||
offsetof(ngx_http_fancyindex_loc_conf_t, default_sort),
|
||||
&ngx_http_fancyindex_sort_criteria },
|
||||
|
||||
{ ngx_string("fancyindex_case_sensitive"),
|
||||
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, case_sensitive),
|
||||
NULL },
|
||||
|
||||
{ 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,
|
||||
|
@ -424,16 +312,23 @@ static ngx_command_t ngx_http_fancyindex_commands[] = {
|
|||
offsetof(ngx_http_fancyindex_loc_conf_t, exact_size),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("fancyindex_name_length"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
||||
ngx_conf_set_num_slot,
|
||||
NGX_HTTP_LOC_CONF_OFFSET,
|
||||
offsetof(ngx_http_fancyindex_loc_conf_t, name_length),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("fancyindex_header"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
|
||||
ngx_fancyindex_conf_set_headerfooter,
|
||||
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, header),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("fancyindex_footer"),
|
||||
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
|
||||
ngx_fancyindex_conf_set_headerfooter,
|
||||
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, footer),
|
||||
NULL },
|
||||
|
@ -466,20 +361,6 @@ static ngx_command_t ngx_http_fancyindex_commands[] = {
|
|||
offsetof(ngx_http_fancyindex_loc_conf_t, show_path),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("fancyindex_show_dotfiles"),
|
||||
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_dot_files),
|
||||
NULL },
|
||||
|
||||
{ ngx_string("fancyindex_hide_parent_dir"),
|
||||
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_parent),
|
||||
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,
|
||||
|
@ -501,8 +382,8 @@ static ngx_http_module_t ngx_http_fancyindex_module_ctx = {
|
|||
NULL, /* create server configuration */
|
||||
NULL, /* merge server configuration */
|
||||
|
||||
ngx_http_fancyindex_create_loc_conf, /* create location configuration */
|
||||
ngx_http_fancyindex_merge_loc_conf /* merge location configuration */
|
||||
ngx_http_fancyindex_create_loc_conf, /* create location configration */
|
||||
ngx_http_fancyindex_merge_loc_conf /* merge location configration */
|
||||
};
|
||||
|
||||
|
||||
|
@ -529,15 +410,8 @@ static const ngx_str_t css_href_post =
|
|||
ngx_string("\" type=\"text/css\"/>\n");
|
||||
|
||||
|
||||
#ifdef NGX_ESCAPE_URI_COMPONENT
|
||||
static inline uintptr_t
|
||||
ngx_fancyindex_escape_filename(u_char *dst, u_char *src, size_t size)
|
||||
{
|
||||
return ngx_escape_uri(dst, src, size, NGX_ESCAPE_URI_COMPONENT);
|
||||
}
|
||||
#else /* !NGX_ESCAPE_URI_COMPONENT */
|
||||
static uintptr_t
|
||||
ngx_fancyindex_escape_filename(u_char *dst, u_char *src, size_t size)
|
||||
ngx_fancyindex_escape_uri(u_char *dst, u_char *src, size_t size)
|
||||
{
|
||||
/*
|
||||
* The ngx_escape_uri() function will not escape colons or the
|
||||
|
@ -555,8 +429,6 @@ ngx_fancyindex_escape_filename(u_char *dst, u_char *src, size_t size)
|
|||
switch (*psrc++) {
|
||||
case ':':
|
||||
case '?':
|
||||
case '[':
|
||||
case ']':
|
||||
escapes++;
|
||||
break;
|
||||
}
|
||||
|
@ -598,16 +470,6 @@ ngx_fancyindex_escape_filename(u_char *dst, u_char *src, size_t size)
|
|||
*dst++ = '3';
|
||||
*dst++ = 'F';
|
||||
break;
|
||||
case '[':
|
||||
*dst++ = '%';
|
||||
*dst++ = '5';
|
||||
*dst++ = 'B';
|
||||
break;
|
||||
case ']':
|
||||
*dst++ = '%';
|
||||
*dst++ = '5';
|
||||
*dst++ = 'D';
|
||||
break;
|
||||
default:
|
||||
*dst++ = *buf;
|
||||
}
|
||||
|
@ -621,13 +483,11 @@ ngx_fancyindex_escape_filename(u_char *dst, u_char *src, size_t size)
|
|||
return escapes + uescapes;
|
||||
}
|
||||
}
|
||||
#endif /* NGX_ESCAPE_URI_COMPONENT */
|
||||
|
||||
|
||||
static ngx_inline ngx_buf_t*
|
||||
make_header_buf(ngx_http_request_t *r, const ngx_str_t css_href)
|
||||
{
|
||||
ngx_buf_t *b;
|
||||
size_t blen = r->uri.len
|
||||
+ ngx_sizeof_ssz(t01_head1)
|
||||
+ ngx_sizeof_ssz(t02_head2)
|
||||
|
@ -642,8 +502,9 @@ make_header_buf(ngx_http_request_t *r, const ngx_str_t css_href)
|
|||
;
|
||||
}
|
||||
|
||||
if ((b = ngx_create_temp_buf(r->pool, blen)) == NULL)
|
||||
return NULL;
|
||||
ngx_buf_t *b = ngx_create_temp_buf(r->pool, blen);
|
||||
|
||||
if (b == NULL) goto bailout;
|
||||
|
||||
b->last = ngx_cpymem_ssz(b->last, t01_head1);
|
||||
|
||||
|
@ -658,10 +519,31 @@ make_header_buf(ngx_http_request_t *r, const ngx_str_t css_href)
|
|||
b->last = ngx_cpymem_ssz(b->last, t03_head3);
|
||||
b->last = ngx_cpymem_ssz(b->last, t04_body1);
|
||||
|
||||
bailout:
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ngx_inline ngx_buf_t*
|
||||
make_footer_buf(ngx_http_request_t *r)
|
||||
{
|
||||
/*
|
||||
* TODO: Make this buffer static (i.e. readonly and reusable from
|
||||
* one request to another.
|
||||
*/
|
||||
ngx_buf_t *b = ngx_create_temp_buf(r->pool, ngx_sizeof_ssz(t08_foot1));
|
||||
|
||||
if (b == NULL) goto bailout;
|
||||
|
||||
b->last = ngx_cpymem_ssz(b->last, t08_foot1);
|
||||
|
||||
bailout:
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static ngx_inline ngx_int_t
|
||||
make_content_buf(
|
||||
ngx_http_request_t *r, ngx_buf_t **pb,
|
||||
|
@ -669,11 +551,11 @@ make_content_buf(
|
|||
{
|
||||
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;
|
||||
size_t len, root, allocated, escape_html;
|
||||
size_t len, root, copy, allocated;
|
||||
int64_t multiplier;
|
||||
u_char *filename, *last;
|
||||
ngx_tm_t tm;
|
||||
|
@ -696,10 +578,7 @@ make_content_buf(
|
|||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
|
||||
allocated = path.len;
|
||||
path.len = last - path.data;
|
||||
if (path.len > 1) {
|
||||
path.len--;
|
||||
}
|
||||
path.len = last - path.data - 1;
|
||||
path.data[path.len] = '\0';
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
|
@ -759,7 +638,7 @@ make_content_buf(
|
|||
|
||||
len = ngx_de_namelen(&dir);
|
||||
|
||||
if (!alcf->show_dot_files && ngx_de_name(&dir)[0] == '.')
|
||||
if (ngx_de_name(&dir)[0] == '.')
|
||||
continue;
|
||||
|
||||
if (alcf->hide_symlinks && ngx_de_is_link (&dir))
|
||||
|
@ -837,12 +716,9 @@ make_content_buf(
|
|||
return ngx_http_fancyindex_error(r, &dir, &path);
|
||||
|
||||
ngx_cpystrn(entry->name.data, ngx_de_name(&dir), len + 1);
|
||||
entry->escape = 2 * ngx_fancyindex_escape_filename(NULL,
|
||||
ngx_de_name(&dir),
|
||||
len);
|
||||
entry->escape_html = ngx_escape_html(NULL,
|
||||
entry->name.data,
|
||||
entry->name.len);
|
||||
entry->escape = 2 * ngx_fancyindex_escape_uri(NULL,
|
||||
ngx_de_name(&dir),
|
||||
len);
|
||||
|
||||
entry->dir = ngx_de_is_dir(&dir);
|
||||
entry->mtime = ngx_de_mtime(&dir);
|
||||
|
@ -861,11 +737,8 @@ make_content_buf(
|
|||
/*
|
||||
* Calculate needed buffer length.
|
||||
*/
|
||||
|
||||
escape_html = ngx_escape_html(NULL, r->uri.data, r->uri.len);
|
||||
|
||||
if (alcf->show_path)
|
||||
len = r->uri.len + escape_html
|
||||
len = r->uri.len
|
||||
+ ngx_sizeof_ssz(t05_body2)
|
||||
+ ngx_sizeof_ssz(t06_list1)
|
||||
+ ngx_sizeof_ssz(t_parentdir_entry)
|
||||
|
@ -873,7 +746,7 @@ make_content_buf(
|
|||
+ ngx_fancyindex_timefmt_calc_size (&alcf->time_format) * entries.nelts
|
||||
;
|
||||
else
|
||||
len = r->uri.len + escape_html
|
||||
len = r->uri.len
|
||||
+ ngx_sizeof_ssz(t06_list1)
|
||||
+ ngx_sizeof_ssz(t_parentdir_entry)
|
||||
+ ngx_sizeof_ssz(t07_list2)
|
||||
|
@ -899,13 +772,14 @@ make_content_buf(
|
|||
* <td>size</td><td>date</td>
|
||||
* </tr>
|
||||
*/
|
||||
len += ngx_sizeof_ssz("<tr><td colspan=\"2\" class=\"link\"><a href=\"")
|
||||
len += ngx_sizeof_ssz("<tr><td class=\"link\"><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 + entry[i].escape_html
|
||||
+ entry[i].name.len + entry[i].utf_len
|
||||
+ ngx_sizeof_ssz("\">")
|
||||
+ entry[i].name.len + entry[i].utf_len + entry[i].escape_html
|
||||
+ entry[i].name.len + entry[i].utf_len
|
||||
+ alcf->name_length + ngx_sizeof_ssz(">")
|
||||
+ ngx_sizeof_ssz("</a></td><td class=\"size\">")
|
||||
+ 20 /* File size */
|
||||
+ ngx_sizeof_ssz("</td><td class=\"date\">") /* Date prefix */
|
||||
|
@ -962,16 +836,12 @@ make_content_buf(
|
|||
case 'N': /* Sort by name */
|
||||
default:
|
||||
if (sort_descending) {
|
||||
sort_cmp_func = alcf->case_sensitive
|
||||
? ngx_http_fancyindex_cmp_entries_name_cs_desc
|
||||
: ngx_http_fancyindex_cmp_entries_name_ci_desc;
|
||||
sort_cmp_func = ngx_http_fancyindex_cmp_entries_name_desc;
|
||||
if (alcf->default_sort != NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME_DESC)
|
||||
sort_url_args = "?C=N&O=D";
|
||||
}
|
||||
else {
|
||||
sort_cmp_func = alcf->case_sensitive
|
||||
? ngx_http_fancyindex_cmp_entries_name_cs_asc
|
||||
: ngx_http_fancyindex_cmp_entries_name_ci_asc;
|
||||
sort_cmp_func = ngx_http_fancyindex_cmp_entries_name_asc;
|
||||
if (alcf->default_sort != NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME)
|
||||
sort_url_args = "?C=N&O=A";
|
||||
}
|
||||
|
@ -993,61 +863,35 @@ make_content_buf(
|
|||
sort_cmp_func = ngx_http_fancyindex_cmp_entries_size_asc;
|
||||
break;
|
||||
case NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME_DESC:
|
||||
sort_cmp_func = alcf->case_sensitive
|
||||
? ngx_http_fancyindex_cmp_entries_name_cs_desc
|
||||
: ngx_http_fancyindex_cmp_entries_name_ci_desc;
|
||||
sort_cmp_func = ngx_http_fancyindex_cmp_entries_name_desc;
|
||||
break;
|
||||
case NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME:
|
||||
default:
|
||||
sort_cmp_func = alcf->case_sensitive
|
||||
? ngx_http_fancyindex_cmp_entries_name_cs_asc
|
||||
: ngx_http_fancyindex_cmp_entries_name_ci_asc;
|
||||
sort_cmp_func = ngx_http_fancyindex_cmp_entries_name_asc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort entries, if needed */
|
||||
if (entries.nelts > 1) {
|
||||
/* 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)
|
||||
{
|
||||
ngx_http_fancyindex_entry_t *l, *r;
|
||||
|
||||
l = entry;
|
||||
r = entry + entries.nelts - 1;
|
||||
while (l < r)
|
||||
{
|
||||
while (l < r && l->dir)
|
||||
l++;
|
||||
while (l < r && !r->dir)
|
||||
r--;
|
||||
if (l < r) {
|
||||
/* Now l points a file while r points a directory */
|
||||
ngx_http_fancyindex_entry_t tmp;
|
||||
tmp = *l;
|
||||
*l = *r;
|
||||
*r = tmp;
|
||||
}
|
||||
}
|
||||
if (r->dir)
|
||||
r++;
|
||||
|
||||
if (r > entry)
|
||||
/* Sort directories */
|
||||
ngx_qsort(entry, (size_t)(r - entry),
|
||||
sizeof(ngx_http_fancyindex_entry_t), sort_cmp_func);
|
||||
if (r < entry + entries.nelts)
|
||||
/* Sort files */
|
||||
ngx_qsort(r, (size_t)(entry + entries.nelts - r),
|
||||
sizeof(ngx_http_fancyindex_entry_t), sort_cmp_func);
|
||||
} else {
|
||||
ngx_qsort(entry, (size_t)entries.nelts,
|
||||
sizeof(ngx_http_fancyindex_entry_t), sort_cmp_func);
|
||||
/* Sort directories first */
|
||||
ngx_sort(entry, (size_t) entries.nelts,
|
||||
sizeof(ngx_http_fancyindex_entry_t),
|
||||
ngx_http_fancyindex_cmp_entries_dirs_first);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Display the path, if needed */
|
||||
if (alcf->show_path){
|
||||
b->last = last = (u_char *) ngx_escape_html(b->last, r->uri.data, r->uri.len);
|
||||
b->last = ngx_cpymem_str(b->last, r->uri);
|
||||
b->last = ngx_cpymem_ssz(b->last, t05_body2);
|
||||
}
|
||||
|
||||
|
@ -1057,10 +901,10 @@ make_content_buf(
|
|||
tp = ngx_timeofday();
|
||||
|
||||
/* "Parent dir" entry, always first if displayed */
|
||||
if (r->uri.len > 1 && alcf->hide_parent == 0) {
|
||||
if (r->uri.len > 1) {
|
||||
b->last = ngx_cpymem_ssz(b->last,
|
||||
"<tr>"
|
||||
"<td colspan=\"2\" class=\"link\"><a href=\"../");
|
||||
"<td class=\"link\"><a href=\"../");
|
||||
if (*sort_url_args) {
|
||||
b->last = ngx_cpymem(b->last,
|
||||
sort_url_args,
|
||||
|
@ -1070,18 +914,17 @@ make_content_buf(
|
|||
"\">Parent directory/</a></td>"
|
||||
"<td class=\"size\">-</td>"
|
||||
"<td class=\"date\">-</td>"
|
||||
"</tr>"
|
||||
CRLF);
|
||||
"</tr>");
|
||||
}
|
||||
|
||||
/* Entries for directories and files */
|
||||
for (i = 0; i < entries.nelts; i++) {
|
||||
b->last = ngx_cpymem_ssz(b->last, "<tr><td colspan=\"2\" class=\"link\"><a href=\"");
|
||||
b->last = ngx_cpymem_ssz(b->last, "<tr><td class=\"link\"><a href=\"");
|
||||
|
||||
if (entry[i].escape) {
|
||||
ngx_fancyindex_escape_filename(b->last,
|
||||
entry[i].name.data,
|
||||
entry[i].name.len);
|
||||
ngx_fancyindex_escape_uri(b->last,
|
||||
entry[i].name.data,
|
||||
entry[i].name.len);
|
||||
|
||||
b->last += entry[i].name.len + entry[i].escape;
|
||||
|
||||
|
@ -1100,21 +943,40 @@ make_content_buf(
|
|||
|
||||
*b->last++ = '"';
|
||||
b->last = ngx_cpymem_ssz(b->last, " title=\"");
|
||||
b->last = (u_char *) ngx_escape_html(b->last, entry[i].name.data, entry[i].name.len);
|
||||
b->last = ngx_cpymem_str(b->last, entry[i].name);
|
||||
*b->last++ = '"';
|
||||
*b->last++ = '>';
|
||||
|
||||
len = entry[i].utf_len;
|
||||
|
||||
b->last = (u_char *) ngx_escape_html(b->last, entry[i].name.data, entry[i].name.len);
|
||||
last = b->last - 3;
|
||||
if (entry[i].name.len - len) {
|
||||
if (len > alcf->name_length) {
|
||||
copy = alcf->name_length - 3 + 1;
|
||||
} else {
|
||||
copy = alcf->name_length + 1;
|
||||
}
|
||||
|
||||
if (entry[i].dir) {
|
||||
*b->last++ = '/';
|
||||
len++;
|
||||
b->last = ngx_utf8_cpystrn(b->last, entry[i].name.data,
|
||||
copy, entry[i].name.len);
|
||||
last = b->last;
|
||||
|
||||
} else {
|
||||
b->last = ngx_cpystrn(b->last, entry[i].name.data,
|
||||
alcf->name_length + 1);
|
||||
last = b->last - 3;
|
||||
}
|
||||
|
||||
b->last = ngx_cpymem_ssz(b->last, "</a></td><td class=\"size\">");
|
||||
if (len > alcf->name_length) {
|
||||
b->last = ngx_cpymem_ssz(last, "..></a></td><td class=\"size\">");
|
||||
|
||||
} else {
|
||||
if (entry[i].dir && alcf->name_length - len > 0) {
|
||||
*b->last++ = '/';
|
||||
len++;
|
||||
}
|
||||
|
||||
b->last = ngx_cpymem_ssz(b->last, "</a></td><td class=\"size\">");
|
||||
}
|
||||
|
||||
if (alcf->exact_size) {
|
||||
if (entry[i].dir) {
|
||||
|
@ -1137,7 +999,7 @@ make_content_buf(
|
|||
if (j == DIM(sizes) - 1)
|
||||
b->last = ngx_sprintf(b->last, "%O %s", length, sizes[j]);
|
||||
else
|
||||
b->last = ngx_sprintf(b->last, "%.1f %s",
|
||||
b->last = ngx_sprintf(b->last, "%.1f %s",
|
||||
(float) length / multiplier, sizes[j]);
|
||||
}
|
||||
}
|
||||
|
@ -1209,19 +1071,19 @@ ngx_http_fancyindex_handler(ngx_http_request_t *r)
|
|||
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only)
|
||||
return rc;
|
||||
|
||||
if (alcf->header.path.len > 0 && alcf->header.local.len == 0) {
|
||||
if (alcf->header.len > 0) {
|
||||
/* URI is configured, make Nginx take care of with a subrequest. */
|
||||
sr_uri = &alcf->header.path;
|
||||
sr_uri = &alcf->header;
|
||||
|
||||
if (*sr_uri->data != '/') {
|
||||
/* Relative path */
|
||||
rel_uri.len = r->uri.len + alcf->header.path.len;
|
||||
rel_uri.len = r->uri.len + alcf->header.len;
|
||||
rel_uri.data = ngx_palloc(r->pool, rel_uri.len);
|
||||
if (rel_uri.data == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
ngx_memcpy(ngx_cpymem(rel_uri.data, r->uri.data, r->uri.len),
|
||||
alcf->header.path.data, alcf->header.path.len);
|
||||
alcf->header.data, alcf->header.len);
|
||||
sr_uri = &rel_uri;
|
||||
}
|
||||
|
||||
|
@ -1249,42 +1111,25 @@ ngx_http_fancyindex_handler(ngx_http_request_t *r)
|
|||
}
|
||||
else {
|
||||
add_builtin_header:
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http fancyindex: adding built-in header");
|
||||
/* Make space before */
|
||||
out[1].next = out[0].next;
|
||||
out[1].buf = out[0].buf;
|
||||
/* Chain header buffer */
|
||||
out[0].next = &out[1];
|
||||
if (alcf->header.local.len > 0) {
|
||||
/* Header buffer is local, make a buffer pointing to the data. */
|
||||
out[0].buf = ngx_calloc_buf(r->pool);
|
||||
if (out[0].buf == NULL)
|
||||
return NGX_ERROR;
|
||||
out[0].buf->memory = 1;
|
||||
out[0].buf->pos = alcf->header.local.data;
|
||||
out[0].buf->last = alcf->header.local.data + alcf->header.local.len;
|
||||
} else {
|
||||
/* Prepare a buffer with the contents of the builtin header. */
|
||||
out[0].buf = make_header_buf(r, alcf->css_href);
|
||||
}
|
||||
out[0].buf = make_header_buf(r, alcf->css_href);
|
||||
}
|
||||
|
||||
/* If footer is disabled, chain up footer buffer. */
|
||||
if (alcf->footer.path.len == 0 || alcf->footer.local.len > 0) {
|
||||
ngx_uint_t last = (alcf->header.path.len == 0) ? 2 : 1;
|
||||
if (alcf->footer.len == 0) {
|
||||
ngx_uint_t last = (alcf->header.len == 0) ? 2 : 1;
|
||||
|
||||
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http fancyindex: adding built-in footer at %i", last);
|
||||
|
||||
out[last-1].next = &out[last];
|
||||
out[last].buf = ngx_calloc_buf(r->pool);
|
||||
if (out[last].buf == NULL)
|
||||
return NGX_ERROR;
|
||||
|
||||
out[last].buf->memory = 1;
|
||||
if (alcf->footer.local.len > 0) {
|
||||
out[last].buf->pos = alcf->footer.local.data;
|
||||
out[last].buf->last = alcf->footer.local.data + alcf->footer.local.len;
|
||||
} else {
|
||||
out[last].buf->pos = (u_char*) t08_foot1;
|
||||
out[last].buf->last = (u_char*) t08_foot1 + sizeof(t08_foot1) - 1;
|
||||
}
|
||||
out[last].buf = make_footer_buf(r);
|
||||
|
||||
out[last-1].buf->last_in_chain = 0;
|
||||
out[last].buf->last_in_chain = 1;
|
||||
|
@ -1305,17 +1150,17 @@ add_builtin_header:
|
|||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
|
||||
/* URI is configured, make Nginx take care of with a subrequest. */
|
||||
sr_uri = &alcf->footer.path;
|
||||
sr_uri = &alcf->footer;
|
||||
|
||||
if (*sr_uri->data != '/') {
|
||||
/* Relative path */
|
||||
rel_uri.len = r->uri.len + alcf->footer.path.len;
|
||||
rel_uri.len = r->uri.len + alcf->footer.len;
|
||||
rel_uri.data = ngx_palloc(r->pool, rel_uri.len);
|
||||
if (rel_uri.data == NULL) {
|
||||
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
ngx_memcpy(ngx_cpymem(rel_uri.data, r->uri.data, r->uri.len),
|
||||
alcf->footer.path.data, alcf->footer.path.len);
|
||||
alcf->footer.data, alcf->footer.len);
|
||||
sr_uri = &rel_uri;
|
||||
}
|
||||
|
||||
|
@ -1340,12 +1185,7 @@ add_builtin_header:
|
|||
* we get something different from a 404?
|
||||
*/
|
||||
out[0].next = NULL;
|
||||
out[0].buf = ngx_calloc_buf(r->pool);
|
||||
if (out[0].buf == NULL)
|
||||
return NGX_ERROR;
|
||||
out[0].buf->memory = 1;
|
||||
out[0].buf->pos = (u_char*) t08_foot1;
|
||||
out[0].buf->last = (u_char*) t08_foot1 + sizeof(t08_foot1) - 1;
|
||||
out[0].buf = make_footer_buf(r);
|
||||
out[0].buf->last_in_chain = 1;
|
||||
out[0].buf->last_buf = 1;
|
||||
/* Directly send out the builtin footer */
|
||||
|
@ -1355,9 +1195,26 @@ add_builtin_header:
|
|||
return (r != r->main) ? rc : ngx_http_send_special(r, NGX_HTTP_LAST);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
static int ngx_libc_cdecl
|
||||
ngx_http_fancyindex_cmp_entries_name_cs_desc(const void *one, const void *two)
|
||||
/* move the directories to the start */
|
||||
if (first->dir && !second->dir) {
|
||||
return -1;
|
||||
}
|
||||
if (!first->dir && second->dir) {
|
||||
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;
|
||||
|
@ -1366,17 +1223,7 @@ ngx_http_fancyindex_cmp_entries_name_cs_desc(const void *one, const void *two)
|
|||
}
|
||||
|
||||
|
||||
static int ngx_libc_cdecl
|
||||
ngx_http_fancyindex_cmp_entries_name_ci_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_strcasecmp(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;
|
||||
|
@ -1386,7 +1233,7 @@ 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)
|
||||
{
|
||||
ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one;
|
||||
|
@ -1396,8 +1243,8 @@ ngx_http_fancyindex_cmp_entries_mtime_desc(const void *one, const void *two)
|
|||
}
|
||||
|
||||
|
||||
static int ngx_libc_cdecl
|
||||
ngx_http_fancyindex_cmp_entries_name_cs_asc(const void *one, const void *two)
|
||||
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;
|
||||
|
@ -1406,17 +1253,7 @@ ngx_http_fancyindex_cmp_entries_name_cs_asc(const void *one, const void *two)
|
|||
}
|
||||
|
||||
|
||||
static int ngx_libc_cdecl
|
||||
ngx_http_fancyindex_cmp_entries_name_ci_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;
|
||||
|
||||
return (int) ngx_strcasecmp(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;
|
||||
|
@ -1426,7 +1263,7 @@ 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)
|
||||
{
|
||||
ngx_http_fancyindex_entry_t *first = (ngx_http_fancyindex_entry_t *) one;
|
||||
|
@ -1460,26 +1297,24 @@ ngx_http_fancyindex_create_loc_conf(ngx_conf_t *cf)
|
|||
|
||||
/*
|
||||
* 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->case_sensitive = NGX_CONF_UNSET;
|
||||
conf->dirs_first = NGX_CONF_UNSET;
|
||||
conf->localtime = NGX_CONF_UNSET;
|
||||
conf->exact_size = NGX_CONF_UNSET;
|
||||
conf->ignore = NGX_CONF_UNSET_PTR;
|
||||
conf->hide_symlinks = NGX_CONF_UNSET;
|
||||
conf->show_path = NGX_CONF_UNSET;
|
||||
conf->hide_parent = NGX_CONF_UNSET;
|
||||
conf->show_dot_files = NGX_CONF_UNSET;
|
||||
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;
|
||||
}
|
||||
|
@ -1495,27 +1330,22 @@ ngx_http_fancyindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
|
||||
ngx_conf_merge_value(conf->enable, prev->enable, 0);
|
||||
ngx_conf_merge_uint_value(conf->default_sort, prev->default_sort, NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME);
|
||||
ngx_conf_merge_value(conf->case_sensitive, prev->case_sensitive, 1);
|
||||
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_value(conf->show_dot_files, prev->show_dot_files, 0);
|
||||
|
||||
ngx_conf_merge_str_value(conf->header.path, prev->header.path, "");
|
||||
ngx_conf_merge_str_value(conf->header.path, prev->header.local, "");
|
||||
ngx_conf_merge_str_value(conf->footer.path, prev->footer.path, "");
|
||||
ngx_conf_merge_str_value(conf->footer.path, prev->footer.local, "");
|
||||
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);
|
||||
ngx_conf_merge_value(conf->hide_parent, prev->hide_parent, 0);
|
||||
|
||||
/* Just make sure we haven't disabled the show_path directive without providing a custom header */
|
||||
if (conf->show_path == 0 && conf->header.path.len == 0)
|
||||
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;
|
||||
|
|
|
@ -7,5 +7,5 @@ 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 '\<table\>' <<< "${content}" # It contains a table
|
||||
grep '^ Content-Type:[[:space:]]*text/html' <<< "${content}"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks if the output from using "fancyindex_exact_size off"
|
||||
looks sane.
|
||||
We test if the output from using "fancyindex_exact_size off" looks sane
|
||||
--
|
||||
nginx_start 'fancyindex_exact_size off;'
|
||||
content=$(fetch)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test fetches the root directory served by Nginx, which has no index
|
||||
file, and checks that the output contains a few HTML elements known to
|
||||
exist in a directory index.
|
||||
file, and checks the output contains a few HTML elements know to exist in
|
||||
a directory index.
|
||||
--
|
||||
use pup
|
||||
nginx_start
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks the output using "fancyindex_hide_parent_dir on".
|
||||
--
|
||||
use pup
|
||||
nginx_start 'fancyindex_hide_parent_dir on;'
|
||||
|
||||
content=$( fetch /child-directory/ )
|
||||
|
||||
# Check page title
|
||||
[[ $(pup -p title text{} <<< "${content}") = "Index of /child-directory/" ]]
|
||||
|
||||
# Check table headers
|
||||
[[ $(pup -n body table tbody tr:first-child td <<< "${content}") -eq 3 ]]
|
||||
{
|
||||
read -r name_label
|
||||
read -r size_label
|
||||
read -r date_label
|
||||
} < <( pup -p body table tbody tr:first-child td text{} <<< "${content}" )
|
||||
[[ ${name_label} != Parent\ Directory/ ]]
|
||||
[[ ${name_label} = empty-file.txt ]]
|
||||
[[ ${size_label} != - ]]
|
||||
[[ ${date_label} != - ]]
|
|
@ -1,50 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks the output using "fancyindex_directories_first on".
|
||||
--
|
||||
use pup
|
||||
|
||||
for d in "008d" "000d" "004d" ; do
|
||||
mkdir -p "${TESTDIR}/dir_first/${d}"
|
||||
done
|
||||
for f in "005f" "001f" "003f"; do
|
||||
touch "${TESTDIR}/dir_first/${f}"
|
||||
done
|
||||
for d in "006d" "002d" ; do
|
||||
mkdir -p "${TESTDIR}/dir_first/${d}"
|
||||
done
|
||||
|
||||
nginx_start 'fancyindex_directories_first on;'
|
||||
previous=''
|
||||
cur_type=''
|
||||
while read -r name ; do
|
||||
case "$name" in
|
||||
*Parent*)
|
||||
;;
|
||||
*d*)
|
||||
echo "dir $name"
|
||||
[[ "$cur_type" = f ]] && fail 'Directories should come before files'
|
||||
cur_type=d
|
||||
if [[ -z ${previous} ]] ; then
|
||||
previous=${name}
|
||||
else
|
||||
[[ ${previous} < ${name} ]] || fail \
|
||||
'Name %s should come before %s\n' "${previous}" "${name}"
|
||||
fi
|
||||
;;
|
||||
*f*)
|
||||
echo "file $name"
|
||||
[[ -z "$cur_type" ]] && fail 'Directories should come before files'
|
||||
if [[ "$cur_type" = d ]] ; then
|
||||
cur_type=f
|
||||
previous=${name}
|
||||
else
|
||||
[[ ${previous} < ${name} ]] || fail \
|
||||
'Name %s should come before %s\n' "${previous}" "${name}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done < <( fetch '/dir_first/' \
|
||||
| pup -p body table tbody 'td:nth-child(1)' text{} )
|
||||
|
||||
nginx_is_running || fail "Nginx died"
|
|
@ -1,21 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks the option to show dotfiles.
|
||||
--
|
||||
# Turn it on.
|
||||
nginx_start 'fancyindex_show_dotfiles on;'
|
||||
on_content=$(fetch /show_dotfiles/)
|
||||
nginx_stop
|
||||
if [ $(grep '.okay' <<< "${on_content}") -ne 0 ] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Turn it off.
|
||||
nginx_start
|
||||
off_content=$(fetch /show_dotfiles/)
|
||||
nginx_stop
|
||||
if [ $(grep '.okay' <<< "${on_content}") -eq 0] ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -1,17 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that a local footer can be included with
|
||||
"fancyindex_header ... local".
|
||||
--
|
||||
use pup
|
||||
|
||||
cat > "${TESTDIR}/footer" <<EOF
|
||||
<div id="customfooter">yes</div>
|
||||
EOF
|
||||
|
||||
nginx_start "fancyindex_footer \"${TESTDIR}/footer\" local;"
|
||||
|
||||
T=$(fetch / | pup -p body 'div#customfooter' text{})
|
||||
[[ $T == yes ]] || fail 'Custom header missing'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
|
@ -1,17 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that a local header can be included with
|
||||
"fancyindex_header ... local".
|
||||
--
|
||||
use pup
|
||||
|
||||
cat > "${TESTDIR}/header" <<EOF
|
||||
<div id="customheader">yes</div>
|
||||
EOF
|
||||
|
||||
nginx_start "fancyindex_header \"${TESTDIR}/header\" local;"
|
||||
|
||||
T=$(fetch / | pup -p body 'div#customheader' text{})
|
||||
[[ $T == yes ]] || fail 'Custom header missing'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
|
@ -1,26 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that both a local header and footer can be included with
|
||||
"fancyindex_{header,footer} ... local".
|
||||
--
|
||||
use pup
|
||||
|
||||
cat > "${TESTDIR}/header" <<EOF
|
||||
<div id="customheader">yes</div>
|
||||
EOF
|
||||
cat > "${TESTDIR}/footer" <<EOF
|
||||
<div id="customfooter">yes</div>
|
||||
EOF
|
||||
|
||||
nginx_start "fancyindex_header \"${TESTDIR}/header\" local;
|
||||
fancyindex_footer \"${TESTDIR}/footer\" local;"
|
||||
|
||||
P=$(fetch /)
|
||||
|
||||
H=$(pup -p body 'div#customheader' text{} <<< "$P")
|
||||
[[ $H == yes ]] || fail 'Custom header missing'
|
||||
|
||||
F=$(pup -p body 'div#customfooter' text{} <<< "$P")
|
||||
[[ $F == yes ]] || fail 'Custom footer missing'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
|
@ -1,31 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that local footers are correctly included in the presence of
|
||||
directives in nested locations:
|
||||
|
||||
fancyindex_footer <one> local;
|
||||
location /sub {
|
||||
fancyindex_footer <another> local;
|
||||
}
|
||||
|
||||
--
|
||||
use pup
|
||||
|
||||
echo '<div id="topfooter">yes</div>' > "${TESTDIR}/top-footer"
|
||||
echo '<div id="subfooter">yes</div>' > "${TESTDIR}/sub-footer"
|
||||
|
||||
nginx_start "fancyindex_footer \"${TESTDIR}/top-footer\" local;
|
||||
location /child-directory {
|
||||
fancyindex_footer \"${TESTDIR}/sub-footer\" local;
|
||||
}"
|
||||
|
||||
T=$(fetch /)
|
||||
echo "$T" > "$TESTDIR/top.html"
|
||||
[[ $(pup -p body 'div#topfooter' text{} <<< "$T") = yes ]] || fail 'Custom header missing at /'
|
||||
[[ -z $(pup -p body 'div#subfooter' text{} <<< "$T") ]] || fail 'Wrong header at /'
|
||||
|
||||
T=$(fetch /child-directory/)
|
||||
[[ $(pup -p body 'div#subfooter' text{} <<< "$T") = yes ]] || fail 'Custom header missing at /sub/'
|
||||
[[ -z $(pup -p body 'div#topfooter' text{} <<< "$T") ]] || fail 'Wrong header at /sub/'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
|
@ -1,11 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that the configuration file is properly parsed if there
|
||||
is only one parameter passed to the fancyindex_header and fancyindex_footer
|
||||
configuration directives.
|
||||
--
|
||||
|
||||
nginx_start 'fancyindex_header "/header";
|
||||
fancyindex_footer "/footer";'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
|
@ -1,9 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
Bug #107: 404 is returned when indexing filesystem root
|
||||
https://github.com/aperezdc/ngx-fancyindex/issues/107
|
||||
--
|
||||
nginx_start 'root /;'
|
||||
content=$(fetch)
|
||||
grep 'Index of /' <<< "${content}" # It is an index
|
||||
grep '<table\>' <<< "${content}" # It contains a table
|
|
@ -1,27 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
Check whether the Saturday long day name is available.
|
||||
https://github.com/aperezdc/ngx-fancyindex/issues/157
|
||||
--
|
||||
use pup
|
||||
nginx_start 'fancyindex_time_format "%A"; fancyindex_default_sort date;'
|
||||
|
||||
mkdir -p "${TESTDIR}/weekdays"
|
||||
for (( i=2 ; i <= 8 ; i++ )) ; do
|
||||
TZ=UTC touch -d "2023-01-0${i}T06:00:00" "${TESTDIR}/weekdays/day$i.txt"
|
||||
done
|
||||
ls "${TESTDIR}/weekdays"
|
||||
content=$(fetch /weekdays/)
|
||||
|
||||
# We need row+1 because the first one is the table header.
|
||||
dayname=$(pup -p body table tbody \
|
||||
'tr:nth-child(7)' 'td:nth-child(3)' 'text{}' \
|
||||
<<< "$content")
|
||||
[[ $dayname = Saturday ]] || fail 'Sixth day is not Saturday'
|
||||
|
||||
dayname=$(pup -p body table tbody \
|
||||
'tr:nth-child(8)' 'td:nth-child(3)' 'text{}' \
|
||||
<<< "$content")
|
||||
[[ $dayname = Sunday ]] || fail 'Seventh day is not Sunday'
|
||||
|
||||
nginx_is_running || fail 'Nginx died'
|
|
@ -1,8 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that case-insensitive sorting works.
|
||||
--
|
||||
|
||||
nginx_start 'fancyindex_case_sensitive off;'
|
||||
content=$(fetch /case-sensitivity/)
|
||||
grep -A 999 '\<alice\>' <<< "${content}" | grep '\<Bob\>' # Bob is after alice
|
|
@ -1,8 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
This test checks that case-sensitive sorting works.
|
||||
--
|
||||
|
||||
nginx_start 'fancyindex_case_sensitive on;'
|
||||
content=$(fetch /case-sensitivity/)
|
||||
grep -A 999 '\<Bob\>' <<< "${content}" | grep '\<alice\>' # alice is after Bob
|
|
@ -1,19 +0,0 @@
|
|||
#! /bin/bash
|
||||
cat <<---
|
||||
Bug #95: FancyIndex does not encode square brackets
|
||||
https://github.com/aperezdc/ngx-fancyindex/issues/95
|
||||
--
|
||||
use pup
|
||||
|
||||
# Prepare a directory with a file that contains square brackets in the name.
|
||||
mkdir -p "${TESTDIR}/bug95"
|
||||
touch "${TESTDIR}"/bug95/'bug[95].txt'
|
||||
|
||||
nginx_start
|
||||
content=$(fetch /bug95/)
|
||||
test -n "${content}" || fail 'Empty response'
|
||||
|
||||
expected_href='bug%5B95%5D.txt'
|
||||
obtained_href=$(pup -p body tbody 'tr:nth-child(2)' a 'attr{href}' <<< "${content}")
|
||||
test "${expected_href}" = "${obtained_href}" || \
|
||||
fail 'Expected: %s - Obtained: %s' "${expected_href}" "${obtained_href}"
|
|
@ -12,15 +12,6 @@ if [[ $2 -eq 1 ]] ; then
|
|||
readonly DYNAMIC=$2
|
||||
fi
|
||||
|
||||
case $(uname -s) in
|
||||
Darwin)
|
||||
JOBS=$(sysctl -n hw.activecpu)
|
||||
;;
|
||||
*)
|
||||
JOBS=1
|
||||
;;
|
||||
esac
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
wget -O - http://nginx.org/download/nginx-${NGINX}.tar.gz | tar -xzf -
|
||||
rm -rf prefix/
|
||||
|
@ -28,9 +19,7 @@ cd nginx-${NGINX}
|
|||
./configure \
|
||||
--add-${DYNAMIC:+dynamic-}module=.. \
|
||||
--with-http_addition_module \
|
||||
--without-http_rewrite_module \
|
||||
--prefix="$(pwd)/../prefix"
|
||||
make -j"$JOBS"
|
||||
make install
|
||||
cd ..
|
||||
exec ./t/run prefix ${DYNAMIC}
|
||||
|
|
54
t/get-pup
54
t/get-pup
|
@ -1,8 +1,8 @@
|
|||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
declare -r VERSION='0.4.0'
|
||||
declare -r SHASUMS='\
|
||||
ec9522193516ad49c78d40a8163f1d92e98866892a11aadb7be584a975026a8a pup_69c02e189c2aaed331061ee436c39e72b830ef32_darwin_amd64.xz
|
||||
75c27caa0008a9cc639beb7506077ad9f32facbffcc4e815e999eaf9588a527e pup_v0.4.0_darwin_386.zip
|
||||
c539a697efee2f8e56614a54cb3b215338e00de1f6a7c2fa93144ab6e1db8ebe pup_v0.4.0_darwin_amd64.zip
|
||||
259eee82c7d7d766f1b8f93a382be21dcfefebc855a9ce8124fd78717f9df439 pup_v0.4.0_dragonfly_amd64.zip
|
||||
|
@ -33,73 +33,49 @@ e965c6f04b897240d84c60e2c18226deb231a657c5583680f58a61051ff5a100 pup_v0.4.0_ope
|
|||
6755cbd43e94eaf173689e93e914c7056a2249c2977e5b90024fb397f9b45ba4 pup_v0.4.0_windows_amd64.zip
|
||||
'
|
||||
|
||||
declare -r BASEURL="https://github.com/ericchiang/pup/releases/download/v${VERSION}"
|
||||
declare -r TDIR=$(dirname "$0")
|
||||
ARCH=''
|
||||
OS=''
|
||||
|
||||
case $(uname -m) in
|
||||
x86_64 | amd64 ) ARCH=amd64 ;;
|
||||
i[3456]86 ) ARCH=386 ;;
|
||||
* ) ARCH= ;;
|
||||
esac
|
||||
|
||||
OS=$(uname -s | tr 'A-Z' 'a-z')
|
||||
case ${OS} in
|
||||
linux | freebsd | openbsd | netbsd | darwin ) ;;
|
||||
* ) OS= ;;
|
||||
* ) OS=''
|
||||
esac
|
||||
|
||||
# The binary of pup 0.4.0 for macOS provided by the original project
|
||||
# crashes immediately on macOS 10.13 (Darwin 17) and up so use a fork:
|
||||
# https://github.com/ericchiang/pup/issues/85
|
||||
if [[ ${OS} = darwin && $(uname -r | cut -d. -f1) -ge 17 ]] ; then
|
||||
USE_FORK=1
|
||||
else
|
||||
USE_FORK=0
|
||||
fi
|
||||
|
||||
if (( USE_FORK )) ; then
|
||||
declare -r VERSION=69c02e189c2aaed331061ee436c39e72b830ef32
|
||||
declare -r DISTFILE="pup_${VERSION}_${OS}_${ARCH}.xz"
|
||||
declare -r URL="https://github.com/frioux/pup/releases/download/untagged-${VERSION}/pup.mac.xz"
|
||||
if ! command -v xz >/dev/null ; then
|
||||
echo "xz not found" 1>&2
|
||||
exit 3
|
||||
fi
|
||||
else
|
||||
declare -r VERSION=0.4.0
|
||||
declare -r DISTFILE="pup_v${VERSION}_${OS}_${ARCH}.zip"
|
||||
declare -r URL="https://github.com/ericchiang/pup/releases/download/v${VERSION}/${DISTFILE}"
|
||||
fi
|
||||
|
||||
if [[ -z ${ARCH} || -z ${OS} ]] ; then
|
||||
echo "pup ${VERSION} is not available for $(uname -s) on $(uname -m)" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
EXPECT_SHA=
|
||||
declare -r ZIPFILE="pup_v${VERSION}_${OS}_${ARCH}.zip"
|
||||
EXPECT_SHA=''
|
||||
|
||||
while read sum fname ; do
|
||||
if [[ ${fname} = ${DISTFILE} ]] ; then
|
||||
if [[ ${fname} = ${ZIPFILE} ]] ; then
|
||||
EXPECT_SHA=${sum}
|
||||
break
|
||||
fi
|
||||
done <<< "${SHASUMS}"
|
||||
|
||||
wget -cO "${TDIR}/${DISTFILE}" "${URL}"
|
||||
wget -cO "${TDIR}/${ZIPFILE}" "${BASEURL}/${ZIPFILE}"
|
||||
|
||||
read -r _ GOT_SHA < <( openssl sha256 < "${TDIR}/${DISTFILE}" )
|
||||
read -r GOT_SHA _ < <( sha256sum "${TDIR}/${ZIPFILE}" )
|
||||
if [[ ${EXPECT_SHA} = ${GOT_SHA} ]] ; then
|
||||
echo "Checksum for ${DISTFILE} verified :-)"
|
||||
echo "Checksum for ${ZIPFILE} verified :-)"
|
||||
else
|
||||
rm -f "${TDIR}/${DISTFILE}" "${TDIR}/pup"
|
||||
echo "Checksum for ${DISTFILE} does not match :-("
|
||||
rm -f "${TDIR}/${ZIPFILE}" "${TDIR}/pup"
|
||||
echo "Checksum for ${ZIPFILE} does not match :-("
|
||||
echo " Expected: ${EXPECT_SHA}"
|
||||
echo " Got: ${GOT_SHA}"
|
||||
exit 2
|
||||
fi 1>&2
|
||||
|
||||
rm -f "${TDIR}/pup"
|
||||
|
||||
if (( USE_FORK )) ; then
|
||||
(cd "${TDIR}" && xz -dk "${DISTFILE}" && mv "${DISTFILE%.*}" pup && chmod a+x pup)
|
||||
else
|
||||
unzip "${TDIR}/${DISTFILE}" pup -d "${TDIR}"
|
||||
fi
|
||||
unzip "${TDIR}/${ZIPFILE}" pup -d "${TDIR}"
|
||||
|
|
24
t/preamble
24
t/preamble
|
@ -3,7 +3,7 @@
|
|||
# preamble
|
||||
# Copyright (C) 2016 Adrian Perez <aperez@igalia.com>
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
# Distributed under terms of the MIT license.
|
||||
#
|
||||
|
||||
function nginx_conf_generate () {
|
||||
|
@ -20,7 +20,7 @@ function nginx_conf_generate () {
|
|||
keepalive_timeout 65;
|
||||
server {
|
||||
server_name localhost;
|
||||
listen 127.0.0.1:${NGINX_PORT};
|
||||
listen 127.0.0.1:8888;
|
||||
root ${TESTDIR};
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html { root html; }
|
||||
|
@ -36,19 +36,6 @@ function nginx_conf_generate () {
|
|||
|
||||
readonly NGINX_CONF="${PREFIX}/conf/nginx.conf"
|
||||
readonly NGINX_PID="${PREFIX}/logs/nginx.pid"
|
||||
|
||||
case $(uname -s) in
|
||||
Darwin)
|
||||
NGINX_PORT=$(netstat -a -n -finet -ptcp | awk '/LISTEN/ { sub(".+\\.", "", $4) ; seen[$4]=1 }
|
||||
END { p=1025 ; while (seen[p]) p++; print p}')
|
||||
;;
|
||||
*)
|
||||
NGINX_PORT=$(ss -4Htnl | awk '{ sub("[^:]+:", "", $4) ; seen[$4]=1 }
|
||||
END { p=1025 ; while (seen[p]) p++; print p}')
|
||||
;;
|
||||
esac
|
||||
readonly NGINX_PORT
|
||||
|
||||
rm -f "${NGINX_CONF}" "${NGINX_PID}"
|
||||
mkdir -p "${PREFIX}/logs"
|
||||
|
||||
|
@ -90,11 +77,6 @@ function nginx_start () {
|
|||
if [[ $# -gt 0 || ! -r ${NGINX_CONF} ]] ; then nginx_conf "$@" ; fi
|
||||
nginx_stop # Ensure that it is not running.
|
||||
nginx
|
||||
local n=0
|
||||
while [[ ! -r ${NGINX_PID} && n -lt 20 ]] ; do
|
||||
sleep 0.1 # Wait until pid exists.
|
||||
n=$((n+1))
|
||||
done
|
||||
}
|
||||
|
||||
function fetch () {
|
||||
|
@ -103,7 +85,7 @@ function fetch () {
|
|||
opts+=( -S )
|
||||
shift
|
||||
fi
|
||||
wget "${opts[@]}" -O- "http://localhost:${NGINX_PORT}${1:-/}" 2>&1
|
||||
wget "${opts[@]}" -O- "http://localhost:8888${1:-/}" 2>&1
|
||||
}
|
||||
|
||||
function skip () {
|
||||
|
|
2
t/run
2
t/run
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#! /bin/bash
|
||||
set -e
|
||||
|
||||
if [[ $# -lt 1 || $# -gt 2 ]] ; then
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright © Adrian Perez <aperez@igalia.com>
|
||||
#
|
||||
# Converts an HTML template into a C header suitable for inclusion.
|
||||
# Take a look at the HACKING.md file to know how to use it :-)
|
||||
# Take a look at the HACKING.rst file to know how to use it :-)
|
||||
#
|
||||
# This code is placed in the public domain.
|
||||
|
||||
|
|
16
template.h
16
template.h
|
@ -11,9 +11,6 @@ static const u_char t01_head1[] = ""
|
|||
"font-family:\"Bitstream Vera Sans\",\"Lucida Grande\","
|
||||
"\"Lucida Sans Unicode\",Lucidux,Verdana,Lucida,sans-serif;"
|
||||
"}"
|
||||
"table {"
|
||||
"table-layout: fixed;"
|
||||
"}"
|
||||
"tr:nth-child(even) {"
|
||||
"background:#f4f4f4;"
|
||||
"}"
|
||||
|
@ -36,11 +33,6 @@ static const u_char t01_head1[] = ""
|
|||
"a:hover {"
|
||||
"color:#e33;"
|
||||
"}"
|
||||
".link {"
|
||||
"white-space: nowrap;"
|
||||
"text-overflow: '>';"
|
||||
"overflow: hidden;"
|
||||
"}"
|
||||
"</style>"
|
||||
"\n"
|
||||
;
|
||||
|
@ -65,9 +57,9 @@ static const u_char t06_list1[] = ""
|
|||
"<table id=\"list\">"
|
||||
"<thead>"
|
||||
"<tr>"
|
||||
"<th colspan=\"2\"><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 style=\"width:55%\"><a href=\"?C=N&O=A\">File Name</a> <a href=\"?C=N&O=D\"> ↓ </a></th>"
|
||||
"<th style=\"width:20%\"><a href=\"?C=S&O=A\">File Size</a> <a href=\"?C=S&O=D\"> ↓ </a></th>"
|
||||
"<th style=\"width:25%\"><a href=\"?C=M&O=A\">Date</a> <a href=\"?C=M&O=D\"> ↓ </a></th>"
|
||||
"</tr>"
|
||||
"</thead>"
|
||||
"\n"
|
||||
|
@ -75,7 +67,7 @@ static const u_char t06_list1[] = ""
|
|||
;
|
||||
static const u_char t_parentdir_entry[] = ""
|
||||
"<tr>"
|
||||
"<td colspan=\"2\" class=\"link\"><a href=\"../?C=N&O=A\">Parent directory/</a></td>"
|
||||
"<td class=\"link\"><a href=\"../?C=N&O=A\">Parent directory/</a></td>"
|
||||
"<td class=\"size\">-</td>"
|
||||
"<td class=\"date\">-</td>"
|
||||
"</tr>"
|
||||
|
|
|
@ -10,9 +10,6 @@
|
|||
font-family:"Bitstream Vera Sans","Lucida Grande",
|
||||
"Lucida Sans Unicode",Lucidux,Verdana,Lucida,sans-serif;
|
||||
}
|
||||
table {
|
||||
table-layout: fixed;
|
||||
}
|
||||
tr:nth-child(even) {
|
||||
background:#f4f4f4;
|
||||
}
|
||||
|
@ -35,11 +32,6 @@
|
|||
a:hover {
|
||||
color:#e33;
|
||||
}
|
||||
.link {
|
||||
white-space: nowrap;
|
||||
text-overflow: '>';
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- var t02_head2 -->
|
||||
|
@ -63,33 +55,33 @@
|
|||
<table id="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="2"><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 style="width:55%"><a href="?C=N&O=A">File Name</a> <a href="?C=N&O=D"> ↓ </a></th>
|
||||
<th style="width:20%"><a href="?C=S&O=A">File Size</a> <a href="?C=S&O=D"> ↓ </a></th>
|
||||
<th style="width:25%"><a href="?C=M&O=A">Date</a> <a href="?C=M&O=D"> ↓ </a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<!-- var t_parentdir_entry -->
|
||||
<tr>
|
||||
<td colspan="2" class="link"><a href="../?C=N&O=A">Parent directory/</a></td>
|
||||
<td class="link"><a href="../?C=N&O=A">Parent directory/</a></td>
|
||||
<td class="size">-</td>
|
||||
<td class="date">-</td>
|
||||
</tr>
|
||||
|
||||
<!-- var NONE -->
|
||||
<tr>
|
||||
<td colspan="2">test file 1</td>
|
||||
<td>test file 1</td>
|
||||
<td>123kB</td>
|
||||
<td>date</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">test file 2</td>
|
||||
<td>test file 2</td>
|
||||
<td>321MB</td>
|
||||
<td>date</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">test file 3</td>
|
||||
<td>test file 3</td>
|
||||
<td>666</td>
|
||||
<td>date</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Reference in a new issue