Override Apache's DirectoryIndex with your own custom index.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
cgi-bin
doc
html
README

README

#
# README - CGIndex
#
# This file is part of CGIndex.
# https://github.com/userbrett/cgindex
#
# ###########################################################################

For the impatient:
    1. See a demonstration of this project at:  http://www.etpenguin.com

For installation instructions, please see the INSTALL file.

------------------------------------------------------------------------------

This project provides a customizable replacement for the standard directory
listing that Apache webserver provides.

When looking for other options beyond "Fancy Indexing" from Apache, I found:

  1.  Support for CSS in LIGHTTPD via "mod_dirlisting"
  2.  Several ways using JavaScript and CSS
  3.  PHP scripts that seemed to require traversal via the document root

So I set out to write my own, and discovered one familiar little option that
made the whole exercise trivial:  DirectoryIndex

Typically, the DirectoryIndex variable looks something like this:
DirectoryIndex          index.html index.shtml index.htm

However, it can also look like this:
DirectoryIndex          index.html index.shtml index.htm /cgi-bin/index.cgi

Which means, all you have to do is write a CGI script, put it into the
/cgi-bin directory, and any directory listing that doesn't have a appropriate
file will get the local /cgi-bin/index.cgi script INSTEAD OF the Apache
Directory Index.

------------------------------------------------------------------------------

To drive the CGI scripts, in fact to see the big picture in action, look
at the file html/index.shtml.  That file contains the following:

      <!--#include file="cgi.header" -->
      <!--#include file="main.html" -->
      <!--#include file="cgi.footer" -->

As you can see above, a static header and footer are created, and there is
also a static body (main).  This provides the initial page.  When content is
selected, one of the two CGI files runs - either /cgi-bin/index.cgi when a
specific file was not selected, or /cgi-bin/showfile.cgi when a file is
selected.

Both index.cgi and showfile.cgi include the same cgi.header and cgi.footer
files, so the four sides remain the same while only changing the content in
the middle - either displaying a directory tree or displaying a file.

------------------------------------------------------------------------------

What about photo thumbnails instead of icons?

The next goal was, for directories containing a list of photos, to display a
thumbnail of the actual photo next to the link to the file.  To accomplish
this:

  1) the "convert" program from ImageMagick was used to create the thumbnail,
     and
  2) the script "createthumbs.pl" was written to recursively create a
     thumbnail for each photo in a directory tree.

Integration of the thumbnails into the directory listing is done by having
/cgi-bin/index.cgi check if the file to be listed has an associated
thumbnail.  If so, it displays the thumbnail alongside the link to the
photo.

------------------------------------------------------------------------------

This project is grateful to the following:

Justin Hagstrom: for his icons available at
                 http://autoindex.sourceforge.net/

Dale Bewley:     for his ImageMagick/convert Perl wrapper at
                 http://bewley.net/perl/thumbnail.html

------------------------------------------------------------------------------