CleanCode Perl Libraries
Multi-Lingual Library Maintainability
available: Perl not available: Java not available: JavaScript not available: Certified
Class
not available: Testable
Class
not available: Standalone
Mode
available: Diagnostic
Enabled

NAME

list - List a directory as a web page, textually or graphically.

SYNOPSIS

list [ options ]

proj=<project>

Specifies the project ID to display, which is used as a key to the configuration file to obtain specs for the project.

dir=<dir>

Specifies the directory within the project to display as the current directory.

col=<column name>

Specifies the name of a column to use as the sort key for list view. Note that this is not the display name for the column, but rather the internal name in the column, which is specified as the name field in the @COLS list.

sortDir=<boolean>

Specifies the direction of sort for the current sort column. A true value will sort ascending, a false value, descending.

x=<mode>

Specifies program mode: list (shows current directory with subdirectory names first), listflat (shows current directory with subdirectory details inline), imglist (shows current directory with subdirectories, then image previews, then non-image files), img (an image-only view), tree (shows all nested directories), or faq (the faq page).

pffft="all"|"now"

With an "all" value forgets that the user ever visited. With a "now" value, does not record the current visit.

REQUIRES

CGI, CGI::Carp, File::stat, User::pwent, User::grent, HTML::Template, XML::DOM, CGI::Handy, File::Handy, Data::Handy, XML::DocumentPlus

DESCRIPTION

This program is a simple file manager to provide web access to a directory. The display of a directory depends upon the program mode. The modes are specified via the mode parameter given above; see subsequent sections for how to customize the display.

list view (mode = "list" or "listflat" or "imglist")

A directory listing, showing the contents of a single directory, akin to a standard Unix directory listing, with a couple enhancements. Each plain file shows name, owner, group, last modified date, and permissions, plus an icon representing the file type. Sub-directories, on the other hand, are listed with just a folder icon and a name, and are listed first. Both files and sub-directories include a hyperlink to access the item. Any given directory may have either files, subdirectories, both, or neither.

The listflat mode is a variation of the ordinary list view; this displays sub-directories inline with full details, just like plain files.

The imglist mode is another variation that starts with the ordinary list view (subdirectory names first, then file details). However, any image files are shown as thumbnail previews rather than being in the file list.

tree view (mode = "tree")

A hirerarchical directory listing, showing the contents of a directory and all of its descendants. Both files and subdirectories display the same information, an icon and a name, with a hyperlink to access the item. Each nested subdirectory is indented to display the hierarchy. The tree view shows hierarchy for the current directory and its descendants. Thus, from the starting directory, this will display the entire hierarchy, but invoked from a lower directory, it will show a smaller branch of the tree.

graphical view (mode = "img")

A graphical listing, displaying an image and a name for each entry. This will only be a useful listing if you have set up the contents of your directory appropriately. For each document file to be listed you must have a correspondingly named image file. For example, if you have a document file file.xyz then you must also have an image file file.xyz.jpg (or .jpeg or .gif or .png) in the same directory. Any file without a corresponding image file will be silently ignored.

faq page (mode = "faq")

A dynamically generated FAQ page, which describes basic operations of the file manager for both users and project administrators. This FAQ page includes a list of all known file types, which is generated dynamically, so when new ones are added to the icon directory, they will automatically show up on the FAQ page. (The table of contents at the top of the page is also generated dynamically, so that as new questions are added, they will automatically be indexed.)

Project Specification

When invoked, one provides a project identifier which is used as a key into the project list specifications in the configuration file. The project configuration file must be called list.xml and stored in the same directory as the program itself. All other support files may be located where you please, as you specify the location in the configuration file.

The configuration file contains global definitions, (such as the location of the support files), project-specific definitions (such as the display name of a project), and some definitions which may be specified globally as a default, but then overridden at the project level if desired (such as the administrator e-mail address).

doc/defaultProject

Global; One of the project identifiers defined in the same file.

doc/supportDirWeb

Global; Web path to the directory containing the support files needed by this program. Must resolve to the same location as supportDirFile.

doc/supportDirFile

Global; Filesystem path to the directory containing the support files needed by this program. Must resolve to the same location as supportDirWeb.

doc/imageDirWeb

Global; Web path to the directory containing the image files needed by this program. Must resolve to the same location as imageDirFile.

doc/imageDirFile

Global; Filesystem path to the directory containing the image files needed by this program. Must resolve to the same location as imageDirWeb.

doc/admin

Global or project; Email address of the default administrator for this program. If specified locally, will override the global value.

doc/project/@id

Project: Identifier for the project, selected via the proj command-line parameter.

doc/project/webRoot

Project; Web path to the root directory for the containing project. Must resolve to the same location as fileRoot.

doc/project/fileRoot

Project; Filesystem path to the root directory for the containing project. Must resolve to the same location as webRoot.

doc/project/title

Project; Display name for this project.

doc/project/imageBrowse

Project; Boolean indicating to use graphical view or not.

doc/project/sortDir

Project; Specifies the direction of sort for the current sort column. A true value will sort ascending, a false value, descending. This is the starting default for the project; it may be overridden from client interactions.

Web Page Customization

The listing generated by this program is delivered to the client browser as XML (for the tree view) or HTML for all others (list view, faq, etc.). These pages are generated from templates, an XSL template for the tree view, an HTML::Template type for the others. These templates, along with other support files, are stored in a directory specified in the configuration file (the doc/supportDirWeb and doc/supportDirFile parameters). The list below specifies the template file used for each file mode.

x=tree

list.xsl

x=list or x=listflat or x=imglist

template.html

x=img

template-img.html

x=faq

template-faq.html

These templates are global to all projects, so any customization applies to all projects. There is, however, some flexibility to customize on a per-project basis as follows.

The files .header.htm and .footer.htm, placed in your project's root directory, allow you to customize all pages within your project. As one might infer, the contents of .header.htm go near the top of the web page; the contents of .footer.htm go near the bottom. Besides this project-level customization, you may further customize on a directory-by-directory basis within your project. Place a file named .directory.htm in any directory you choose; the contents of this file, if present, will immediately follow the contents of .header.htm.

Note that various fatal initialization errors will generate a simple error output, bypassing the templates. This includes: a project ID not found, a specified subdirectory not found, non-wellformed XML in the configuration file, key nodes missing from the configuration file, and so forth.

Images on the Site

Images are stored in a directory specified in the configuration file (the doc/imageDirWeb and doc/imageDirFile parameters). Beneath this directory, there are two subdirectories, for file icons ("icons") and for web buttons ("buttons"). The file icons are used to graphically display the type of each file in a list view or tree view, whether it be an Excel file, an HTML file, a plain text file, a folder, etc. If a file has an extension which is not in the icon library, a question-mark graphic is displayed indicating unknown type.

BUGS

Occasional reports of tree mode failure have me stumped; the browser just displays the text of the xml rather than processing it through the xsl template. The msxml and browser versions both seem to work in other circumstances, so I've not been able to isolate what is different.

AUTHOR

Michael Sorens

VERSION

$Revision: 1356 $ $Date: 2013-03-17 22:08:33 -0700 (Sun, 17 Mar 2013) $

SINCE

CleanCode 0.9


CleanCode Perl Libraries Copyright © 2001-2013 Michael Sorens - Revised 2013.06.30 Get CleanCode at SourceForge.net. Fast, secure and Free Open Source software downloads