coar 99/12/01 14:10:50
Modified: htdocs/manual/mod mod_autoindex.html src CHANGES src/modules/standard mod_autoindex.c Log: Add the long-awaited IndexOptions DescriptionWidth keyword. It was waiting for a way to avoid breaking HTML tags, but that's already been done as much as possible -- we can't do anything about breaking HTML elements without putting a full parser in. PR: 2324 Revision Changes Path 1.33 +22 -1 apache-1.3/htdocs/manual/mod/mod_autoindex.html Index: mod_autoindex.html =================================================================== RCS file: /home/cvs/apache-1.3/htdocs/manual/mod/mod_autoindex.html,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- mod_autoindex.html 1999/12/01 20:33:48 1.32 +++ mod_autoindex.html 1999/12/01 22:10:32 1.33 @@ -215,6 +215,17 @@ <CODE>IndexOptions SuppressSize</CODE>, and 19 bytes may be added if <CODE>IndexOptions SuppressLastModified</CODE> is in effect. The widest this column can be is therefore 49 bytes. +<blockquote> +As of Apache 1.3.10, the +<a href="#indexoptions:descriptionwidth">DescriptionWidth</a> +<samp>IndexOptions</samp> keyword allows you to adjust this width +to any arbitrary size. +</blockquote> +<b>Caution:</b> Descriptive text defined with <samp>AddDescription</samp> +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. </P> <HR> @@ -545,13 +556,23 @@ REL="Help" ><STRONG>Compatibility:</STRONG></A> '+/-' syntax and merging of multiple <SAMP>IndexOptions</SAMP> directives is only available with - Apache 1.3.3 and later; the <samp>FoldersFirst</samp> option is only + Apache 1.3.3 and later; the <samp>FoldersFirst</samp> and + <samp>DescriptionWidth</samp> options are only available with Apache 1.3.10 and later <P> The IndexOptions directive specifies the behavior of the directory indexing. <EM>Option</EM> can be one of <DL> +<dt><a name="indexoptions:descriptionwidth">DescriptionWidth=[<em>n</em> | *] + (<em>Apache 1.3.10 and later</em>)</a> +<dd> +The <samp>DescriptionWidth</samp> keyword allows you to specify the +width of the description column in characters. If the keyword value +is '<samp>*</samp>', then the column is automatically sized to the +length of the longest filename in the display. +<b>See the section on <a href="#adddescription"><samp>AddDescription</samp></a> +for dangers inherent in truncating descriptions.</b></dd> <DT><A NAME="indexoptions:fancyindexing">FancyIndexing</A> <DD><!--%plaintext <?INDEX {\tt FancyIndexing} index option> --> This turns on fancy indexing of directories. 1.1468 +5 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1467 retrieving revision 1.1468 diff -u -r1.1467 -r1.1468 --- CHANGES 1999/12/01 20:54:55 1.1467 +++ CHANGES 1999/12/01 22:10:39 1.1468 @@ -1,5 +1,10 @@ Changes with Apache 1.3.10 + *) Add IndexOptions DescriptionWidth so that the width of the + description field in fancy-indexed directory listings can + be specified. + [Ken Coar] PR#2324, plus lots that are closed unsatisfied + *) EBCDIC: Escaped characters were encoding the ebcdic representation of the special characters, not the latin1 representation. This would result in invalid URI's for, e.g., filenames (with special chars) 1.112 +80 -19 apache-1.3/src/modules/standard/mod_autoindex.c Index: mod_autoindex.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_autoindex.c,v retrieving revision 1.111 retrieving revision 1.112 diff -u -r1.111 -r1.112 --- mod_autoindex.c 1999/12/01 20:34:10 1.111 +++ mod_autoindex.c 1999/12/01 22:10:45 1.112 @@ -125,6 +125,7 @@ * Other default dimensions. */ #define DEFAULT_NAME_WIDTH 23 +#define DEFAULT_DESC_WIDTH 23 struct item { char *type; @@ -141,13 +142,14 @@ } ai_desc_t; typedef struct autoindex_config_struct { - char *default_icon; int opts; int incremented_opts; int decremented_opts; int name_width; int name_adjust; + int desc_width; + int desc_adjust; int icon_width; int icon_height; char *default_order; @@ -465,6 +467,31 @@ 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 < 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"; } @@ -576,6 +603,8 @@ 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 = ap_make_array(p, 4, sizeof(struct item)); new->alt_list = ap_make_array(p, 4, sizeof(struct item)); new->desc_list = ap_make_array(p, 4, sizeof(ai_desc_t)); @@ -663,6 +692,17 @@ new->name_width = add->name_width; new->name_adjust = add->name_adjust; } + /* + * 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_order = (add->default_order != NULL) ? add->default_order : base->default_order; @@ -1208,19 +1248,27 @@ } 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_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]) { @@ -1286,6 +1334,7 @@ int static_columns = (autoindex_opts & SUPPRESS_COLSORT); pool *scratch = ap_make_sub_pool(r->pool); int name_width; + int desc_width; char *name_scratch; char *pad_scratch; @@ -1293,6 +1342,17 @@ name = "/"; } + desc_width = d->desc_width; + 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_width = d->name_width; if (d->name_adjust == K_ADJUST) { for (x = 0; x < n; x++) { @@ -1392,17 +1452,17 @@ nwidth = strlen(t2); if (nwidth > name_width) { - memcpy(name_scratch, t2, name_width - 3); - name_scratch[name_width - 3] = '.'; - name_scratch[name_width - 2] = '.'; - name_scratch[name_width - 1] = '>'; - name_scratch[name_width] = 0; - t2 = name_scratch; - nwidth = name_width; + memcpy(name_scratch, t2, name_width - 3); + name_scratch[name_width - 3] = '.'; + name_scratch[name_width - 2] = '.'; + name_scratch[name_width - 1] = '>'; + name_scratch[name_width] = 0; + t2 = name_scratch; + nwidth = name_width; } ap_rvputs(r, " <A HREF=\"", anchor, "\">", - ap_escape_html(scratch, t2), "</A>", pad_scratch + nwidth, - NULL); + ap_escape_html(scratch, t2), "</A>", + pad_scratch + nwidth, NULL); /* * The blank before the storm.. er, before the next field. */ @@ -1426,7 +1486,8 @@ if (!(autoindex_opts & SUPPRESS_DESC)) { if (ar[x]->desc) { ap_rputs(terminate_description(d, ar[x]->desc, - autoindex_opts), r); + autoindex_opts, + desc_width), r); } } }