• Stars
    star
    847
  • Rank 53,812 (Top 2 %)
  • Language
    C
  • License
    Other
  • Created almost 12 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Fancy indexes module for the Nginx web server

Nginx Fancy Index module

Build Status

The Fancy Index module makes possible the generation of file listings, like the built-in autoindex module does, but adding a touch of style. This is possible because the 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.
  • Allow choosing to sort elements by name (default), modification time, or size; both ascending (default), or descending.

This module is designed to work with Nginx, a high performance open source web server written by Igor Sysoev.

Requirements

CentOS, RHEL, Fedora Linux

For users of the official stable Nginx repository, extra packages repository with dynamic modules is available and fancyindex is included.

Install repository configuration, then the module package:

yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y 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; 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 order to use the fancyindex_header_ and fancyindex_footer_ directives you will also need the ngx_http_addition_module built into Nginx.

Building

  1. Unpack the Nginx sources:

    $ gunzip -c nginx-?.?.?.tar.gz | tar -xvf -
    
  2. Unpack the sources for the fancy indexing module:

    $ gunzip -c nginx-fancyindex-?.?.?.tar.gz | tar -xvf -
    
  3. Change to the directory which contains the Nginx sources, run the configuration script with the desired options and be sure to put an --add-module flag pointing to the directory which contains the source of the fancy indexing module:

    $ cd nginx-?.?.?
    $ ./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, using --add-dynamic-module=… instead and load_module "modules/ngx_http_fancyindex_module.so"; in the configuration file

  4. Build and install the software:

    $ make
    

    And then, as root:

    # make install
    
  5. Configure Nginx by using the modules' configuration directives.

Example

You can test the default built-in style by adding the following lines into a server section in your Nginx configuration file:

location / {
  fancyindex on;              # Enable fancy indexes.
  fancyindex_exact_size off;  # Output human-readable file sizes.
}

Themes

The following themes demonstrate the level of customization which can be achieved using the module:

  • Theme by @TheInsomniac. Uses custom header and footer.
  • Theme by @Naereen. Uses custom header and footer. The header includes a search field to filter by file name using JavaScript.
  • Theme by @fraoustin. Responsive theme using Material Design elements.
  • Theme by @alehaa. Simple, flat theme based on Bootstrap 4 and FontAwesome.

Directives

fancyindex

Syntax:fancyindex [on | off]
Default:fancyindex off
Context:http, server, location
Description:Enables or disables fancy directory indexes.

fancyindex_default_sort

Syntax:fancyindex_default_sort [name | size | date | name_desc | size_desc | date_desc]
Default:fancyindex_default_sort name
Context:http, server, location
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]
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
Default:fancyindex_css_href ""
Context:http, server, location
Description:Allows inserting a link to a CSS style sheet in generated listings. The provided uri parameter will be inserted as-is in a <link> HTML tag. The link is inserted after the built-in CSS rules, so you can override the default styles.

fancyindex_exact_size

Syntax:fancyindex_exact_size [on | off]
Default:fancyindex_exact_size on
Context:http, server, location
Description:Defines how to represent file sizes in the directory listing: either accurately, or rounding off to the kilobyte, the megabyte and the gigabyte.

fancyindex_footer

Syntax:fancyindex_footer path [subrequest | local]
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.

Note

Using this directive needs the ngx_http_addition_module built into Nginx.

Warning

When inserting custom a 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 while waiting for the subrequest to complete. If you feel like external header/footer is a must-have for you, please let me know.

fancyindex_header

Syntax:fancyindex_header path [subrequest | local]
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.

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. 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 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_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]
Default:fancyindex_localtime off
Context:http, server, location
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 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.

More Repositories

1

vim-template

Simple templates plugin for Vim
Vim Script
372
star
2

signify

OpenBSD tool to sign and verify signatures on files. Portable version.
C
275
star
3

revolt

Better desktop integration for Riot.im (not only) for GNOME
Python
92
star
4

zsh-fzy

Use the fzy fuzzy-finder in Zsh
Shell
56
star
5

notmuch-addrlookup-c

Address lookup tool for Notmuch in C using GLib and libnotmuch
C
50
star
6

nss-altfiles

NSS module to read passwd/group files from alternate locations
C
41
star
7

hmac-sha256

HMAC-SHA256 implemented in C
C
38
star
8

9pfuse

FUSE-based 9P client from the Plan9 Port project, standalone version
C
30
star
9

luabot

An XMPP (Jabber) bot written in Lua using the protocol implementation from Verse/Prosody
Lua
27
star
10

synpurge

Utility script to Matrix room history purge room in Synapse using the HTTP API
Python
20
star
11

lua-itertools

Functional iterators for Lua based on coroutines
Lua
18
star
12

ljndpi

Lua binding to the nDPI library using the LuaJIT FFI
Lua
16
star
13

lua-wcwidth

Pure Lua implementation of the wcwidth() function
Lua
15
star
14

webkit2gtk-python-webextension-example

Example small C shim to load a Python script as a WebKit2 WebExtension
C
15
star
15

dotfiles

Personal configuration files I often use in my - may contain useful snippets for you as well, YMMV.
Shell
14
star
16

cflag

Non-allocating command line flag parser
C
12
star
17

zsh-notes

Quick selection widget for Markdown notes, inspired by terminal_velocity
Shell
11
star
18

lua-matrix

Matrix Client-Server API for Lua and LuaJIT
Lua
10
star
19

virtualz

Virtualfish-alike Python virtualenv wrapper for Zsh
Shell
9
star
20

rockz

Virtualfish-alike Lua+LuaRocks “Rockenv” wrapper for Zsh
Shell
9
star
21

dwt

Simple no-frills terminal emulator using VTE -- for (x)dwm
C
8
star
22

ulid-c

Plain C implementation of ULID — Lexicographically sortable unique IDs
C
8
star
23

autocleanup

Macros and helper inlines to automatically cleanup scoped resources
C
7
star
24

dmon

Small process daemonization and monitorization tool.
C
7
star
25

icetop

Console monitor for the icecream/icecc distributed compilation system
C++
6
star
26

perezdecastro.org

Personal website and static site generator in NodeJS
CSS
6
star
27

netdial

Utility library to simplify socket setup code
C
6
star
28

clog

Non-allocating runtime configurable logger
C
5
star
29

popsicle

Toolchain tarball creator for Icecream
Rust
5
star
30

gnarl

Lightweight module to define serializable, schema-validated classes
Python
5
star
31

esh

esh, Unix Shell with LISP-ish syntax originally from Ivan Tkatchev
C
4
star
32

xdwm

My fork of the DWM window manager. Includes 3rd party patches and some own modifications. Branch “upstream” tracks the tip from the DWM Hg repository, which is periodically merged back on “master”.
C
4
star
33

ggtraybar

Minimal top panel bar, with desktop pager, window selector, system tray, clock, and a mini command line
C
4
star
34

wheel

The “wheel” library aims to provide basic (and some not-that-basic) facilities that one would expect to have in C.
C
4
star
35

safecat

Copies standard input safely to a specified directory using qmail's Maildir algorithm
C
3
star
36

mwerlin

Presentation tool for HTML-based slides
Lua
3
star
37

vim-lining

The silver lining of Vim/NeoVim statuslines
Vim Script
3
star
38

pebble-beats

Swatch @beats Internet Time watchface for Pebble / Pebble Time
C
3
star
39

pktgen

Declarative network packet flow generator
Python
3
star
40

vim-elrond

Vim colorscheme based on the build-in “elflord” scheme, with extras for 256-color terminals
Vim Script
3
star
41

lua-dotty

Idiomatic wrapper for terminal handling in Lua
Lua
2
star
42

galaxy-desktop

Franken desktop session using a mix of GNOME and Pantheon components
C
2
star
43

lua-shelve

Serialization and on-disk persistence for Lua values
C
2
star
44

doin

Runs *any* binary in *any* container. Without platform-dependent kludges.
C
2
star
45

hipack-c

HiPack (de)serialization library in C
C
2
star
46

nihil

The Nothing-but-Iffy HTTP I/O Library, for Python's asyncio
Python
1
star
47

hipack

Site for the HiPack serialization format
CSS
1
star
48

bill

Bash Improved Leveraging Library —
Shell
1
star
49

lua-lineinput

A pure-Lua readline/editline/linenoise alike module
Lua
1
star
50

indicium

Unified API to multiple key-value stores
Python
1
star
51

hipack-js

HiPack (de)serialization library in JavaScript
JavaScript
1
star
52

ltree

Utility to work with file lists in the format of the BSD mtree tool
C
1
star
53

jsinception

Slides for my JSConf EU 2014 talk “JS: Inception”
Shell
1
star
54

lua-delog

Fast, extensible, optionally zero-impact Lua logging module.
Lua
1
star
55

vim-lift

Completion system for Vim which “lifts” candidates from other completion functions
Vim Script
1
star
56

microwl

Micro Wayland-EGL “windowing” system
1
star
57

icecc-rs

Idiomatic Rust wrapper for the libicecc library
Rust
1
star
58

guru-runit

GuruPlug boot scripts to use in Debian Wheezy with runit for fast booting, bypassing most of the unneeded init crap
Shell
1
star
59

key-input-fwd

C
1
star
60

miju-goudy

A version of Goudy Oldstyle with all four body text variants
Python
1
star
61

websnap

Tool to measure QtWebKit rendering performance
C++
1
star
62

intheam-python

Python module to for accessing the inthe.am API
Python
1
star
63

fightcode-bots

Bots for http://fightcodegame.com
JavaScript
1
star
64

indicium-git

Git-backed key-value store for Indicium
Python
1
star
65

levi-asher-memoir

Tools to assemble an EPUB of Levi Asher's memoirs about the Internet boom and being a software developer.
Python
1
star
66

python-cmdcmd

Ergonomic and flexible commands-with-subcommands command line parser
Python
1
star
67

abtool

Unpack and repack unencrypted ADB backups
Shell
1
star
68

hipack-python

HiPack (de)serialization library in Python
Python
1
star
69

nfwx

Nokia Firmware Explorer
Python
1
star
70

apicheck

Assertion macros for checking function parameters
C
1
star
71

hipack-rs

HiPack (de)serialization library in Rust
Rust
1
star