From: William A. Rowe Jr
+
+Automatic index generation must be enabled with by the Summary
-
The index of a directory can come from one of two sources:
+Automatic index generation is enabled with using
+
If the FancyIndexing
option is given with the IndexOptions
directive, the column headers are links that control the
order of the display. If you select a header link, the
listing will be regenerated, sorted by the values in that
column. Selecting the same header repeatedly toggles
-between ascending and descending order. This can be suppressed with
-IndexOptions SuppressColumnSorting.
+between ascending and descending order. These column header links are
+suppressed with IndexOptions directive's
+SuppressColumnSorting option.
Note that when the display is sorted by "Size",
@@ -72,6 +84,22 @@ always be displayed before a 1011-byte file (if in ascending
order) even though they both are shown as "1K".
-This provides the alternate text to display for a file, instead of an icon, for
-FancyIndexing. File
+AddAlt provides the alternate text to display for a file, instead of an icon,
+for FancyIndexing. File
is a file extension, partial filename, wild-card expression or full filename for
files to describe. String is enclosed in double quotes (
-This provides the alternate text to display for a file, instead of an icon,
-for FancyIndexing.
+AddAltByEncoding provides the alternate text to display for a file, instead
+of an icon, for FancyIndexing.
MIME-encoding is a valid content-encoding, such as x-compress.
String is enclosed in double quotes (
-This sets the alternate text to display for a file, instead of an icon, for
-FancyIndexing.
+AddAltByType sets the alternate text to display for a file, instead of
+an icon, for FancyIndexing.
MIME-type is a valid content-type, such as text/html.
String is enclosed in double quotes (
-The description field is 23 bytes wide. 7 more bytes may be
-added if the directory is covered by an
-
+See the DescriptionWidth
+IndexOptions keyword for details on overriding the size of this
+column, or allowing descriptions of unlimited length.
+
elements.
These are necessary for HTML 3.2 final formatting rules.
Introduced HTMLTable to create rudimentary HTML table listings
(implies FancyIndexing). Necessary for alternate charsets, since
the columns are borked by multibyte characters.
Re-Introduced the mod_autoindex IndexOptions flag TrackModified
from Apache 1.3.15. This is needed for two reasons, first, given
multiple machines within a server farm, ETags and Last-Modified
stamps won't correspond from machine to machine, and second, many
Unixes don't capture changes to the date or time stamp of existing
files, since these don't modify the dirent itself.
[Originally for 1.3 by me]
Re-Introduced the mod_autoindex InextOptions flag FoldersFirst
and DirectoryWidth options from Apache 1.3.10.
[Originally for 1.3 by Ken Coar]
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89979 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/CHANGES b/CHANGES
index ad6865194e..65bf0bc74d 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,7 +1,28 @@
Changes with Apache 2.0.23-dev
+ *) Introduced new mod_autoindex IndexOptions flags; SuppressIcon to
+ drop the icon column, SuppressRules to drop the
elements,
+ and HTMLTable to create rudimentary HTML table listings (implies
+ FancyIndexing). [William Rowe]
+
+ *) Re-Introduced the mod_autoindex IndexOptions flag TrackModified
+ from Apache 1.3.15. This is needed for two reasons, first, given
+ multiple machines within a server farm, ETags and Last-Modified
+ stamps won't correspond from machine to machine, and second, many
+ Unixes don't capture changes to the date or time stamp of existing
+ files, since these don't modify the dirent itself. [William Rowe]
+
+ *) Re-Introduced the mod_autoindex InextOptions flag FoldersFirst
+ and DirectoryWidth options from Apache 1.3.10.
+ [William Rowe, Ken Coar]
+
+ *) Eliminated FancyIndexing directive, depricated early in Apache
+ 1.3 by the IndexOptions FancyIndexing syntax. [William Rowe]
+
*) mod_autoindex now excludes any file names that would result in
- an error, other than a success or redirect. [William Rowe]
+ an error, other than a success or redirect. Also optimized
+ the parent directory, always included except in the URI '/'.
+ [William Rowe]
*) Refactored mod_negotiation and mod_mime to help mod_dir accept
negotiated index pages, and prevent the server from defaulting
diff --git a/docs/manual/mod/mod_autoindex.html b/docs/manual/mod/mod_autoindex.html
index dab43f9e83..d793b2e353 100644
--- a/docs/manual/mod/mod_autoindex.html
+++ b/docs/manual/mod/mod_autoindex.html
@@ -15,7 +15,14 @@
Module mod_autoindex
-This module provides for automatic directory indexing.
+The module mod_autoindex generates directory indexes, automatically, similar to
+the Unix ls command or the Win32 dir shell command.
+Options
+directive's [+]Indexes
option. See the
+Options
directive for
+more details.
@@ -55,14 +61,20 @@ are controlled by
.mod_autoindex
.
The two functions are separated so that you can completely remove
(or replace) automatic index generation should you want to.
Options +Indexes
. See the
+Options
directive for
+more details.
+Autoindex Request Query Arguments
+
+The column sorting headers are self-referencing hyperlinks that add the following
+query options, they may be added to any request for the directory resource, where
+They have no effect if the IndexOptions directive's
+SuppressColumnSorting option is in effect. In the list below,
+S is the desired sort order, either A for ascending or
+D for descending sequence.
+
+
+
+
Directives
@@ -121,8 +149,8 @@ HREF="mod_dir.html#directoryindex">DirectoryIndex"
).
This alternate text is displayed if the client is image-incapable, has image loading
@@ -154,8 +182,8 @@ disabled, or fails to retrieve the icon.
REL="Help"
>Module: mod_autoindex"
). This alternate
text is displayed if the client is image-incapable, has image loading disabled, or
@@ -187,8 +215,8 @@ fails to retrieve the icon.
REL="Help"
>Module: mod_autoindex"
). This
alternate text is displayed if the client is image-incapable, has image loading
@@ -229,23 +257,23 @@ quotes ("
). Example:
AddDescription "The planet Mars" /web/pics/mars.gif
IndexOptions SuppressSize
, and 19 bytes may be
-added if IndexOptions SuppressLastModified
is
-in effect. The widest this column can be is therefore 49 bytes.
+The typical, default description field is 23 bytes wide. 6 more bytes are
+added by the IndexOptions SuppressIcon
option, 7 bytes are
+added by the IndexOptions SuppressSize
option, and 19 bytes
+are added by the IndexOptions SuppressLastModified
option.
+Therefore, the widest default the description column is ever assigned is 55 bytes.
+
-As of Apache 1.3.10, the
-DescriptionWidth
-IndexOptions keyword allows you to adjust this width
-to any arbitrary size.
-
Caution: Descriptive text defined with AddDescription
may contain HTML markup, such as tags and character entities. If the
width of the description column should happen to truncate a tagged
element (such as cutting off the end of a bolded phrase), the results
may affect the rest of the directory listing.
-
The HeaderName directive sets the name of the file that will be inserted at the top of the index listing. Filename is the name of the file to include.
-Apache 1.3.6 and earlier: -The module first attempts to include filename-.html
-as an HTML document, otherwise it will try to include filename as -plain text. Filename is treated as a filesystem path relative -to the directory being indexed. In no case is SSI processing done. -Example: --when indexing the directoryHeaderName HEADER
/web
, the server will first look for -the HTML file/web/HEADER.html
and include it if found, otherwise -it will include the plain text file/web/HEADER
, if it exists. -
Apache versions after 1.3.6: -Filename is treated as a URI path relative to the one used -to access the directory being indexed, and must resolve to a document -with a major content type of "text" (e.g., -text/html, text/plain, etc.). -This means that filename may refer to a CGI script if the +Changes with Apache 1.3.7: +Both HeaderName and ReadmeName now treat Filename +as a URI path relative to the one used to access the directory being indexed. +Filename must resolve to a document with a major content type of +"text/*" (e.g., text/html, text/plain, +etc.). This means that filename may refer to a CGI script if the script's actual file type (as opposed to its output) is marked as text/html such as with a directive like:@@ -515,12 +532,6 @@ IndexIgnore README .htaccess *~IndexOptions directive
-Syntax: IndexOptions option - [option] ... (Apache 1.3.2 and earlier) -
Compatibility: '+/-' syntax and merging of multiple IndexOptions directives is only available with - Apache 1.3.3 and later; the FoldersFirst and - DescriptionWidth options are only - available with Apache 1.3.10 and later + Apache 1.3.3 and later; specific options are listed below.The IndexOptions directive specifies the behavior of the directory indexing. Option can be one of
-
- DescriptionWidth=[n | *] - (Apache 1.3.10 and later) -
- -The DescriptionWidth keyword allows you to specify the -width of the description column in characters. If the keyword value -is '*', then the column is automatically sized to the -length of the longest filename in the display. -See the section on AddDescription + (Apache 1.3.10 or 2.0.23 and later) +
- The DescriptionWidth keyword allows you to specify the +width of the description column in characters.
+- -DescriptionWidth (or unset) allows mod_autoindex to calculate +the best width.
+- DescriptionWidth=n fixes the column width to n bytes wide.
+- DescriptionWidth=* grows the column to the necessary width.
+- See the section on AddDescription for dangers inherent in truncating descriptions.
- FancyIndexing
- This turns on fancy indexing of directories.
- FoldersFirst - (Apache 1.3.10 and later)
+ (Apache 1.3.10 or 2.0.23 and later)- If this option is enabled, subdirectory listings will always appear first, followed by normal files in the @@ -585,6 +595,14 @@ subdirectory Zed will be listed before subdirectory This option only has an effect if FancyIndexing is also enabled.
+- HTMLTable + (Experimental, Apache 2.0.23 and later) +
- +This experimental option with FancyIndexing constructs a simple table for the +fancy directory listing. Note this will confuse older browsers. It is particularly +necessary if file names or description text will alternate between left-to-right +and right-to-left reading order, as can happen on WinNT or other utf-8 +enabled platforms.
- IconHeight[=pixels] (Apache 1.3 and later)
- @@ -613,34 +631,11 @@ software.
- NameWidth=[n | *] (Apache 1.3.2 and later)
- The NameWidth keyword allows you to specify the width of the -filename column in bytes. If the keyword value is '*', -then the column is automatically sized to the length of the longest -filename in the display. -
- VersionSort (Apache 2.0a3 and later) -
- -The VersionSort keyword causes files containing version numbers to -sort in a natural way. Strings are sorted as usual, except that -substrings of digits in the name and description are compared -according to their numeric value. - -For example: -
- -If the number starts with a zero, then it is considered to be a - fraction: --foo-1.7 -foo-1.7.2 -foo-1.7.12 -foo-1.8.2 -foo-1.8.2a -foo-1.12 -+filename column in bytes. +-foo-1.001 -foo-1.002 -foo-1.030 -foo-1.04 -- -NameWidth (or unset) allows mod_autoindex to calculate +the best width.
+- NameWidth=n fixes the column width to n bytes wide.
+- NameWidth=* grows the column to the necessary width.
- ScanHTMLTitles
- This enables the extraction of the title from HTML documents for fancy @@ -648,13 +643,13 @@ indexing. If the file does not have a description given by AddDescription then httpd will read the document for the value of the TITLE tag. This is CPU and disk intensive.
- SuppressColumnSorting + (Apache 1.3 and later)
- If specified, Apache will not make the column headings in a FancyIndexed directory listing into links for sorting. The default behaviour is for them to be links; selecting the column heading will sort the directory listing by the values in that column. -Only available in Apache 1.3 and later.
- SuppressDescription
- @@ -673,45 +668,75 @@ cetera). The SuppressHTMLPreamble option disables this behaviour, causing the module to start the display with the header file contents. The header file must contain appropriate HTML instructions in this case. If there is no header file, the preamble is generated as usual. +
- SuppressIcon + (Apache 2.0.23 and later) +
- + +This will suppress the icon in fancy indexing listings. Combining +both SuppressIcon and SuppressRules yeilds proper +HTML 3.2 output, which by the final specification prohibits IMG and HR +tags from the PRE block (used to format FancyIndexed listings.)
- SuppressLastModified
- This will suppress the display of the last modification date, in fancy indexing listings. +
- SuppressRules + (Apache 2.0.23 and later) +
- + +This will suppress the horizontal rule lines (HR tags) in directory listings. +Combining both SuppressIcon and SuppressRules yeilds proper +HTML 3.2 output, which by the final specification prohibits IMG and HR tags +from the PRE block (used to format FancyIndexed listings.)
- SuppressSize
- This will suppress the file size in fancy indexing listings. -
-There are some noticeable differences in the behaviour of this -directive in recent (post-1.3.0) versions of Apache. -
--
@@ -839,21 +860,15 @@ the client from requesting the directory listing in a different order. HREF="directive-dict.html#Compatibility" REL="Help" >Compatibility: some features only available after - 1.3.6; see text + 1.3.6; see HeaderName- Apache 1.3.2 and earlier:
+- TrackModified +(Apache 1.3.15 or 2.0.23 and later)
- -
-The default is that no options are enabled. If multiple IndexOptions -could apply to a directory, then the most specific one is taken complete; -the options are not merged. For example: + +This returns the Last-Modified and ETag values for the listed directory +in the HTTP header. It is only valid if the operating system and file +system return appropriate stat() results. Some Unix systems do so, as +do OS2's JFS and Win32's NTFS volumes. OS2 and Win32 FAT volumes, +for example, do not. Once this feature is enabled, the client or proxy +can track changes to the list of files when they perform a HEAD request. +Note some operating systems correctly track new and removed files, but +do not track changes for sizes or dates of the files within the directory. +Changes to the size or date stamp of an existing file will not +update the Last-Modified header on all Unix platforms. If this +is a concern, leave this option disabled. +
- VersionSort (Apache 2.0a3 and later) +
- +The VersionSort keyword causes files containing version numbers to +sort in a natural way. Strings are sorted as usual, except that +substrings of digits in the name and description are compared +according to their numeric value. + +For example:
--then only-<Directory /web/docs> - IndexOptions FancyIndexing -</Directory> -<Directory /web/docs/spec> - IndexOptions ScanHTMLTitles -</Directory> +foo-1.7 +foo-1.7.2 +foo-1.7.12 +foo-1.8.2 +foo-1.8.2a +foo-1.12ScanHTMLTitles
will be set for the /web/docs/spec -directory. - -- Apache 1.3.3 and later:
-- -
-Apache 1.3.3 introduced some significant changes in the handling of + +If the number starts with a zero, then it is considered to be a + fraction: +
++foo-1.001 +foo-1.002 +foo-1.030 +foo-1.04 +Incremental IndexOptions
+- Apache 1.3.3 introduced some significant changes in the handling of IndexOptions directives. In particular, - +
-
- Multiple IndexOptions directives for a single directory are now merged together. The result of the example above @@ -722,30 +747,26 @@ Apache 1.3.3 introduced some significant changes in the handling of keywords with '+' or '-').
+
Whenever a '+' or '-' prefixed keyword is encountered, it is applied to the current IndexOptions settings (which may have been inherited from an upper-level directory). However, whenever an unprefixed keyword is processed, it clears all inherited options and any incremental settings encountered so far. Consider the following example: --IndexOptions +ScanHTMLTitles -IconsAreLinks FancyIndexing -
+
IndexOptions +SuppressSize -
+
The net effect is equivalent to
-IndexOptions FancyIndexing +SuppressSize
, because the unprefixedFancyIndexing
discarded the incremental keywords before it, but allowed them to start accumulating again afterward. -+
+keywords without any '+' or '-' prefixes.
To unconditionally set theIndexOptions
for a particular directory, clearing the inherited settings, specify -keywords without either '+' or '-' prefixes. -The ReadmeName directive sets the name of the file that will be appended to the end of the index listing. Filename is the name of the file to include, and is taken to be relative to the location being indexed.
--The filename argument is treated as a stub filename -in Apache 1.3.6 and earlier, and as a relative URI in later versions. -Details of how it is handled may be found under the description of -the HeaderName directive, which uses the -same mechanism and changed at the same time as ReadmeName. --See also HeaderName.
+
See also HeaderName, where this behavior is +described in greater detail.
diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index fd1c5e49d6..8b093a41ee 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -94,24 +94,21 @@ module AP_MODULE_DECLARE_DATA autoindex_module; * Handling configuration directives... */ -#define HRULE 1 -#define NO_HRULE 0 -#define FRONT_MATTER 1 -#define END_MATTER 0 - -#define FANCY_INDEXING 1 /* Indexing options */ -#define ICONS_ARE_LINKS 2 -#define SCAN_HTML_TITLES 4 -#define SUPPRESS_LAST_MOD 8 -#define SUPPRESS_SIZE 16 -#define SUPPRESS_DESC 32 -#define SUPPRESS_PREAMBLE 64 -#define SUPPRESS_COLSORT 128 -#define NO_OPTIONS 256 -#define VERSION_SORT 512 - -#define K_PAD 1 -#define K_NOPAD 0 +#define NO_OPTIONS 0x0001 /* Indexing options */ +#define ICONS_ARE_LINKS 0x0002 +#define SCAN_HTML_TITLES 0x0004 +#define SUPPRESS_ICON 0x0008 +#define SUPPRESS_LAST_MOD 0x0010 +#define SUPPRESS_SIZE 0x0020 +#define SUPPRESS_DESC 0x0040 +#define SUPPRESS_PREAMBLE 0x0080 +#define SUPPRESS_COLSORT 0x0100 +#define SUPPRESS_RULES 0x0200 +#define FOLDERS_FIRST 0x0400 +#define VERSION_SORT 0x0800 +#define TRACK_MODIFIED 0x1000 +#define FANCY_INDEXING 0x2000 +#define TABLE_INDEXING 0x4000 #define K_NOADJUST 0 #define K_ADJUST 1 @@ -138,6 +135,7 @@ module AP_MODULE_DECLARE_DATA autoindex_module; * Other default dimensions. */ #define DEFAULT_NAME_WIDTH 23 +#define DEFAULT_DESC_WIDTH 23 struct item { char *type; @@ -161,9 +159,12 @@ typedef struct autoindex_config_struct { int decremented_opts; int name_width; int name_adjust; + int desc_width; + int desc_adjust; int icon_width; int icon_height; - char *default_order; + char default_keyid; + char default_direction; apr_array_header_t *icon_list; apr_array_header_t *alt_list; @@ -361,12 +362,21 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) if (!strcasecmp(w, "FancyIndexing")) { option = FANCY_INDEXING; } + else if (!strcasecmp(w, "FoldersFirst")) { + option = FOLDERS_FIRST; + } + else if (!strcasecmp(w, "HTMLTable")) { + option = TABLE_INDEXING; + } else if (!strcasecmp(w, "IconsAreLinks")) { option = ICONS_ARE_LINKS; } else if (!strcasecmp(w, "ScanHTMLTitles")) { option = SCAN_HTML_TITLES; } + else if (!strcasecmp(w, "SuppressIcon")) { + option = SUPPRESS_ICON; + } else if (!strcasecmp(w, "SuppressLastModified")) { option = SUPPRESS_LAST_MOD; } @@ -382,6 +392,12 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) else if (!strcasecmp(w, "SuppressColumnSorting")) { option = SUPPRESS_COLSORT; } + else if (!strcasecmp(w, "SuppressRules")) { + option = SUPPRESS_RULES; + } + else if (!strcasecmp(w, "TrackModified")) { + option = TRACK_MODIFIED; + } else if (!strcasecmp(w, "VersionSort")) { option = VERSION_SORT; } @@ -439,13 +455,38 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) else { int width = atoi(&w[10]); - if (width < 5) { + if (width && (width < 5)) { return "NameWidth value must be greater than 5"; } d_cfg->name_width = width; d_cfg->name_adjust = K_NOADJUST; } } + else if (!strcasecmp(w, "DescriptionWidth")) { + if (action != '-') { + return "DescriptionWidth with no value may only appear as " + "'-DescriptionWidth'"; + } + d_cfg->desc_width = DEFAULT_DESC_WIDTH; + d_cfg->desc_adjust = K_NOADJUST; + } + else if (!strncasecmp(w, "DescriptionWidth=", 17)) { + if (action == '-') { + return "Cannot combine '-' with DescriptionWidth=n"; + } + if (w[17] == '*') { + d_cfg->desc_adjust = K_ADJUST; + } + else { + int width = atoi(&w[17]); + + if (width && (width < 12)) { + return "DescriptionWidth value must be greater than 12"; + } + d_cfg->desc_width = width; + d_cfg->desc_adjust = K_NOADJUST; + } + } else { return "Invalid directory indexing option"; } @@ -475,42 +516,35 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) static const char *set_default_order(cmd_parms *cmd, void *m, const char *direction, const char *key) { - char temp[4]; autoindex_config_rec *d_cfg = (autoindex_config_rec *) m; - apr_cpystrn(temp, "k=d", sizeof(temp)); if (!strcasecmp(direction, "Ascending")) { - temp[2] = D_ASCENDING; + d_cfg->default_direction = D_ASCENDING; } else if (!strcasecmp(direction, "Descending")) { - temp[2] = D_DESCENDING; + d_cfg->default_direction = D_DESCENDING; } else { return "First keyword must be 'Ascending' or 'Descending'"; } if (!strcasecmp(key, "Name")) { - temp[0] = K_NAME; + d_cfg->default_keyid = K_NAME; } else if (!strcasecmp(key, "Date")) { - temp[0] = K_LAST_MOD; + d_cfg->default_keyid = K_LAST_MOD; } else if (!strcasecmp(key, "Size")) { - temp[0] = K_SIZE; + d_cfg->default_keyid = K_SIZE; } else if (!strcasecmp(key, "Description")) { - temp[0] = K_DESC; + d_cfg->default_keyid = K_DESC; } else { return "Second keyword must be 'Name', 'Date', 'Size', or " "'Description'"; } - if (d_cfg->default_order == NULL) { - d_cfg->default_order = apr_palloc(cmd->pool, 4); - d_cfg->default_order[3] = '\0'; - } - apr_cpystrn(d_cfg->default_order, temp, sizeof(temp)); return NULL; } @@ -559,6 +593,8 @@ static void *create_autoindex_config(apr_pool_t *p, char *dummy) new->icon_height = 0; new->name_width = DEFAULT_NAME_WIDTH; new->name_adjust = K_UNSET; + new->desc_width = DEFAULT_DESC_WIDTH; + new->desc_adjust = K_UNSET; new->icon_list = apr_array_make(p, 4, sizeof(struct item)); new->alt_list = apr_array_make(p, 4, sizeof(struct item)); new->desc_list = apr_array_make(p, 4, sizeof(ai_desc_t)); @@ -568,7 +604,8 @@ static void *create_autoindex_config(apr_pool_t *p, char *dummy) new->opts = 0; new->incremented_opts = 0; new->decremented_opts = 0; - new->default_order = NULL; + new->default_keyid = '\0'; + new->default_direction = '\0'; return (void *) new; } @@ -646,9 +683,22 @@ static void *merge_autoindex_configs(apr_pool_t *p, void *basev, void *addv) new->name_width = add->name_width; new->name_adjust = add->name_adjust; } - - new->default_order = (add->default_order != NULL) - ? add->default_order : base->default_order; + /* + * Likewise for DescriptionWidth. + */ + if (add->desc_adjust == K_UNSET) { + new->desc_width = base->desc_width; + new->desc_adjust = base->desc_adjust; + } + else { + new->desc_width = add->desc_width; + new->desc_adjust = add->desc_adjust; + } + + new->default_keyid = add->default_keyid ? add->default_keyid + : base->default_keyid; + new->default_direction = add->default_direction ? add->default_direction + : base->default_direction; return new; } @@ -669,6 +719,7 @@ struct ent { struct ent *next; int ascending, version_sort; char key; + int isdir; }; static char *find_item(request_rec *r, apr_array_header_t *list, int path_only) @@ -1198,14 +1249,17 @@ static struct ent *make_autoindex_entry(const apr_finfo_t *dirent, p->alt = NULL; p->desc = NULL; p->lm = -1; + p->isdir = 0; p->key = apr_toupper(keyid); p->ascending = (apr_toupper(direction) == D_ASCENDING); p->version_sort = autoindex_opts & VERSION_SORT; - - if (autoindex_opts & FANCY_INDEXING) + + if (autoindex_opts & (FANCY_INDEXING | TABLE_INDEXING)) { p->lm = rr->finfo.mtime; if (rr->finfo.filetype == APR_DIR) { + if (autoindex_opts & FOLDERS_FIRST) + p->isdir = 1; if (!(p->icon = find_icon(d, rr, 1))) { p->icon = find_default_icon(d, "^^DIRECTORY^^"); } @@ -1241,19 +1295,29 @@ static struct ent *make_autoindex_entry(const apr_finfo_t *dirent, } static char *terminate_description(autoindex_config_rec *d, char *desc, - int autoindex_opts) + int autoindex_opts, int desc_width) { - int maxsize = 23; + int maxsize = desc_width; register int x; - if (autoindex_opts & SUPPRESS_LAST_MOD) { - maxsize += 19; - } - if (autoindex_opts & SUPPRESS_SIZE) { - maxsize += 7; + /* + * If there's no DescriptionWidth in effect, default to the old + * behaviour of adjusting the description size depending upon + * what else is being displayed. Otherwise, stick with the + * setting. + */ + if (d->desc_adjust == K_UNSET) { + if (autoindex_opts & SUPPRESS_ICON) { + maxsize += 6; + } + if (autoindex_opts & SUPPRESS_LAST_MOD) { + maxsize += 19; + } + if (autoindex_opts & SUPPRESS_SIZE) { + maxsize += 7; + } } - - for (x = 0; desc[x] && (maxsize > 0 || desc[x]=='<'); x++) { + for (x = 0; desc[x] && ((maxsize > 0) || (desc[x] == '<')); x++) { if (desc[x] == '<') { while (desc[x] != '>') { if (!desc[x]) { @@ -1320,8 +1384,10 @@ static void output_directories(struct ent **ar, int n, int static_columns = (autoindex_opts & SUPPRESS_COLSORT); apr_pool_t *scratch; int name_width; + int desc_width; char *name_scratch; char *pad_scratch; + char *breakrow; apr_pool_create(&scratch, r->pool); if (name[0] == '\0') { @@ -1329,30 +1395,92 @@ static void output_directories(struct ent **ar, int n, } name_width = d->name_width; - if (d->name_adjust == K_ADJUST) { - for (x = 0; x < n; x++) { - int t = strlen(ar[x]->name); - if (t > name_width) { - name_width = t; + desc_width = d->desc_width; + + if ((autoindex_opts & (FANCY_INDEXING | TABLE_INDEXING)) + == FANCY_INDEXING) { + if (d->name_adjust == K_ADJUST) { + for (x = 0; x < n; x++) { + int t = strlen(ar[x]->name); + if (t > name_width) { + name_width = t; + } } - } + } + + if (d->desc_adjust == K_ADJUST) { + for (x = 0; x < n; x++) { + if (ar[x]->desc != NULL) { + int t = strlen(ar[x]->desc); + if (t > desc_width) { + desc_width = t; + } + } + } + } } name_scratch = apr_palloc(r->pool, name_width + 1); pad_scratch = apr_palloc(r->pool, name_width + 1); memset(pad_scratch, ' ', name_width); pad_scratch[name_width] = '\0'; - if (autoindex_opts & FANCY_INDEXING) { - ap_rputs("
", r); - if ((tp = find_default_icon(d, "^^BLANKICON^^"))) { - ap_rvputs(r, "icon_width) - ap_rprintf(r, " width=\"%d\"", d->icon_width); - if (d->icon_height) - ap_rprintf(r, " height=\"%d\"", d->icon_height); - ap_rputs(" /> ", r); + if (autoindex_opts & TABLE_INDEXING) { + int cols = 1; + ap_rputs("
\n", r); + else + ap_rputs("\n", r); } else { - ap_rputs("", r); + ap_rputs("\n", r); } } @@ -1491,6 +1708,13 @@ static int dsortf(struct ent **e1, struct ent **e2) if ((*e2)->name[0] == '/') { return 1; } + /* + * Now see if one's a directory and one isn't, if we're set + * isdir for FOLDERS_FIRST. + */ + if ((*e1)->isdir != (*e2)->isdir) { + return (*e1)->isdir ? -1 : 1; + } /* * All of our comparisons will be of the c1 entry against the c2 one, * so assign them appropriately to take care of the ordering. @@ -1566,15 +1790,25 @@ static int index_directory(request_rec *r, #else r->content_type = "text/html"; #endif - ap_update_mtime(r, r->finfo.mtime); - ap_set_last_modified(r); - ap_set_etag(r); - + if (autoindex_opts & TRACK_MODIFIED) { + ap_update_mtime(r, r->finfo.mtime); + ap_set_last_modified(r); + ap_set_etag(r); + } if (r->header_only) { apr_dir_close(thedir); return 0; } + /* + * If there is no specific ordering defined for this directory, + * default to ascending by filename. + */ + keyid = autoindex_conf->default_keyid + ? autoindex_conf->default_keyid : K_NAME; + direction = autoindex_conf->default_direction + ? autoindex_conf->default_direction : D_ASCENDING; + /* Spew HTML preamble */ title_endp = title_name + strlen(title_name) - 1; @@ -1594,28 +1828,21 @@ static int index_directory(request_rec *r, * IndexOrderDefault directive (if there is one); otherwise, * we fall back to ascending by name. */ - qstring = r->args; - if ((autoindex_opts & SUPPRESS_COLSORT) - || ((qstring == NULL) || (*qstring == '\0'))) { - qstring = autoindex_conf->default_order; - } + if (!(autoindex_opts & SUPPRESS_COLSORT)) + qstring = r->args; + else + qstring = NULL; + /* * If there is no specific ordering defined for this directory, - * default to ascending by filename. + * take the defaults above. */ - if ((qstring == NULL) || (*qstring == '\0')) { - keyid = K_NAME; - direction = D_ASCENDING; - } - else { + if ((qstring != NULL) && (*qstring != '\0')) { keyid = *qstring; ap_getword(r->pool, &qstring, '='); if (qstring != '\0') { direction = *qstring; } - else { - direction = D_ASCENDING; - } } /*