Received: (qmail 18333 invoked by uid 501); 2 Feb 2002 15:32:14 -0000
Message-Id: <20020202153214.18332.qmail@apache.org>
Date: 2 Feb 2002 15:32:14 -0000
From: tom stuart See also: Options and FoldersFirst and DescriptionWidth
options are only available with Apache 1.3.10 and later; the
TrackModified option is only available with Apache
- 1.3.15 and later
+ 1.3.15 and later; the EmitXHTML option is only
+ available with Apache 1.3.24 and later
The IndexOptions directive specifies the behavior of the
directory indexing. Option can be one of See also HeaderName. The StyleName directive is used in combination
+ with the EmitXHTML
+ index option. By default, XHTML directory listings have no
+ CSS stylesheet attached; the StyleName allows you to
+ specify a stylesheet for such a directory listing, giving some
+ control over the visual appearance of the output. StyleName sets the name of the stylesheet file that
+ will be linked in the <head> of the index listing.
+ filename is the name of the file to include. Example:
+ \n", r);
+ ap_rputs((emit_xhtml ? "
\n"), r);
}
/* See mod_include */
@@ -988,13 +1029,16 @@
* instead of a text document, meaning nothing will be displayed, but
* oh well.
*/
-static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
- char *title)
+static void emit_head(request_rec *r, char *header_fname,
+ autoindex_config_rec *autoindex_conf, char *title)
{
FILE *f;
request_rec *rr = NULL;
int emit_amble = 1;
int emit_H1 = 1;
+ int autoindex_opts = autoindex_conf->opts;
+ int suppress_amble = autoindex_opts & SUPPRESS_PREAMBLE;
+ int emit_xhtml = autoindex_opts & EMIT_XHTML;
/*
* If there's a header file, send a subrequest to look for it. If it's
@@ -1019,7 +1063,8 @@
emit_H1 = 0;
if (! suppress_amble) {
- emit_preamble(r, title);
+ emit_preamble(r, title, find_css(autoindex_conf, r),
+ emit_xhtml);
}
/* See mod_include */
@@ -1046,9 +1091,10 @@
* where it belongs.
*/
if ((f = ap_pfopen(r->pool, rr->filename, "r")) != 0) {
- emit_preamble(r, title);
+ emit_preamble(r, title, find_css(autoindex_conf, r),
+ emit_xhtml);
emit_amble = 0;
- do_emit_plain(r, f);
+ do_emit_plain(r, f, emit_xhtml);
ap_pfclose(r->pool, f);
emit_H1 = 0;
}
@@ -1057,10 +1103,13 @@
}
if (emit_amble) {
- emit_preamble(r, title);
+ emit_preamble(r, title, find_css(autoindex_conf, r), emit_xhtml);
}
if (emit_H1) {
- ap_rvputs(r, "\n" : "
\n" : "\n"), r);
while (!feof(f)) {
do {
n = fread(buf, sizeof(char), IOBUFSIZE, f);
@@ -972,7 +1013,7 @@
c = i + 1;
}
}
- ap_rputs("
\n", r);
+ ap_rputs((emit_xhtml ? "Index of ", title, "
\n", NULL);
+ ap_rvputs(r, (emit_xhtml ? "" : "
"),
+ "\n", NULL);
}
if (rr != NULL) {
ap_destroy_sub_req(rr);
@@ -1077,12 +1126,14 @@
* instead of a text document, meaning nothing will be displayed, but
* oh well.
*/
-static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
+static void emit_tail(request_rec *r, char *readme_fname, int autoindex_opts)
{
FILE *f;
request_rec *rr = NULL;
int suppress_post = 0;
int suppress_sig = 0;
+ int suppress_amble = autoindex_opts & SUPPRESS_PREAMBLE;
+ int emit_xhtml = autoindex_opts & EMIT_XHTML;
/*
* If there's a readme file, send a subrequest to look for it. If it's
@@ -1119,7 +1170,7 @@
* If we can open the file, suppress the signature.
*/
if ((f = ap_pfopen(r->pool, rr->filename, "r")) != 0) {
- do_emit_plain(r, f);
+ do_emit_plain(r, f, emit_xhtml);
ap_pfclose(r->pool, f);
suppress_sig = 1;
}
@@ -1131,7 +1182,7 @@
ap_rputs(ap_psignature("", r), r);
}
if (!suppress_post) {
- ap_rputs("\n", r);
+ ap_rputs((emit_xhtml ? "\n\n" : "\n"), r);
}
if (rr != NULL) {
ap_destroy_sub_req(rr);
@@ -1326,7 +1377,7 @@
* selected again. Non-active fields always start in ascending order.
*/
static void emit_link(request_rec *r, char *anchor, char fname, char curkey,
- char curdirection, int nosort)
+ char curdirection, int nosort, int emit_xhtml)
{
char qvalue[5];
int reverse;
@@ -1338,7 +1389,8 @@
qvalue[4] = '\0';
reverse = ((curkey == fname) && (curdirection == D_ASCENDING));
qvalue[3] = reverse ? D_DESCENDING : D_ASCENDING;
- ap_rvputs(r, "", anchor, "", NULL);
+ ap_rvputs(r, (emit_xhtml ? "", anchor, (emit_xhtml ? "" : ""), NULL);
}
else {
ap_rputs(anchor, r);
@@ -1353,6 +1405,7 @@
char *name = r->uri;
char *tp;
int static_columns = (autoindex_opts & SUPPRESS_COLSORT);
+ int emit_xhtml = (autoindex_opts & EMIT_XHTML);
pool *scratch = ap_make_sub_pool(r->pool);
int name_width;
int desc_width;
@@ -1389,44 +1442,78 @@
pad_scratch[name_width] = '\0';
if (autoindex_opts & FANCY_INDEXING) {
- ap_rputs(""),
+ "Index of ", title,
+ (emit_xhtml ? "
" : "", r);
+ ap_rputs((emit_xhtml ?
+ "
\n
\n" : ""), r);
}
else {
- ap_rputs("", r);
+ ap_rputs((emit_xhtml ? "\n" : ""), r);
}
}
@@ -1647,7 +1783,7 @@
}
emit_head(r, find_header(autoindex_conf, r),
- autoindex_opts & SUPPRESS_PREAMBLE, title_name);
+ autoindex_conf, title_name);
/*
* Figure out what sort of indexing (if any) we're supposed to use.
@@ -1713,10 +1849,10 @@
ap_pclosedir(r->pool, d);
if (autoindex_opts & FANCY_INDEXING) {
- ap_rputs("\n" \
+ " \n" : "\n" :
+ " \n"), r);
if ((tp = find_default_icon(d, "^^BLANKICON^^"))) {
- ap_rvputs(r, "icon_width && d->icon_height) {
ap_rprintf
(
r,
- " HEIGHT=\"%d\" WIDTH=\"%d\"",
+ (emit_xhtml ? " height=\"%d\" width=\"%d\""
+ : " HEIGHT=\"%d\" WIDTH=\"%d\""),
d->icon_height,
d->icon_width
);
}
- ap_rputs("> ", r);
+ ap_rputs((emit_xhtml ? " />" : "> "), r);
+ }
+ if(emit_xhtml) {
+ ap_rputs("
", r);
+ }
+ emit_link(r, "Name", K_NAME, keyid, direction, static_columns,
+ emit_xhtml);
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
+ } else {
+ ap_rputs(pad_scratch + 4, r);
+ /*
+ * Emit the guaranteed-at-least-one-space-between-columns byte.
+ */
+ ap_rputs(" ", r);
}
- emit_link(r, "Name", K_NAME, keyid, direction, static_columns);
- ap_rputs(pad_scratch + 4, r);
- /*
- * Emit the guaranteed-at-least-one-space-between-columns byte.
- */
- ap_rputs(" ", r);
if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
+ if(emit_xhtml) {
+ ap_rputs("", r);
+ }
emit_link(r, "Last modified", K_LAST_MOD, keyid, direction,
- static_columns);
- ap_rputs(" ", r);
+ static_columns, emit_xhtml);
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
+ } else {
+ ap_rputs(" ", r);
+ }
}
if (!(autoindex_opts & SUPPRESS_SIZE)) {
- emit_link(r, "Size", K_SIZE, keyid, direction, static_columns);
- ap_rputs(" ", r);
+ if(emit_xhtml) {
+ ap_rputs("", r);
+ }
+ emit_link(r, "Size", K_SIZE, keyid, direction, static_columns,
+ emit_xhtml);
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
+ } else {
+ ap_rputs(" ", r);
+ }
}
if (!(autoindex_opts & SUPPRESS_DESC)) {
+ if(emit_xhtml) {
+ ap_rputs("", r);
+ }
emit_link(r, "Description", K_DESC, keyid, direction,
- static_columns);
+ static_columns, emit_xhtml);
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
+ }
}
- ap_rputs("\n
\n", r);
+ ap_rputs((emit_xhtml ? "
\n"), r);
}
else {
- ap_rputs("", r);
+ ap_rputs((emit_xhtml ? "
\n" : "
"), r);
}
for (x = 0; x < n; x++) {
@@ -1451,24 +1538,34 @@
}
if (autoindex_opts & FANCY_INDEXING) {
+ if(emit_xhtml) {
+ ap_rputs("
\n \n", r);
}
}
else {
- ap_rvputs(r, "", r);
+ }
if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rvputs(r, "", NULL);
+ ap_rvputs(r, (emit_xhtml ? "", NULL);
}
if ((ar[x]->icon) || d->default_icon) {
- ap_rvputs(r, "icon ? ar[x]->icon
: d->default_icon),
- "\" ALT=\"[", (ar[x]->alt ? ar[x]->alt : " "),
+ "\" ", (emit_xhtml ? "alt" : "ALT"),
+ "=\"[", (ar[x]->alt ? ar[x]->alt : " "),
"]\"", NULL);
if (d->icon_width && d->icon_height) {
- ap_rprintf(r, " HEIGHT=\"%d\" WIDTH=\"%d\"",
+ ap_rprintf(r,
+ (emit_xhtml ? " height=\"%d\" width=\"%d\""
+ : " HEIGHT=\"%d\" WIDTH=\"%d\""),
d->icon_height, d->icon_width);
}
- ap_rputs(">", r);
+ ap_rputs((emit_xhtml ? " />" : ">"), r);
}
if (autoindex_opts & ICONS_ARE_LINKS) {
- ap_rputs("", r);
+ ap_rputs((emit_xhtml ? "" : ""), r);
+ }
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
}
nwidth = strlen(t2);
@@ -1481,48 +1578,87 @@
t2 = name_scratch;
nwidth = name_width;
}
- ap_rvputs(r, " ",
- ap_escape_html(scratch, t2), "",
- pad_scratch + nwidth, NULL);
- /*
- * The blank before the storm.. er, before the next field.
- */
- ap_rputs(" ", r);
+ if(emit_xhtml) {
+ ap_rputs("", r);
+ }
+ ap_rvputs(r, (emit_xhtml ? "", ap_escape_html(scratch, t2),
+ (emit_xhtml ? "" : ""),
+ (emit_xhtml ? "" : pad_scratch + nwidth), NULL);
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
+ } else {
+ /*
+ * The blank before the storm.. er, before the next field.
+ */
+ ap_rputs(" ", r);
+ }
if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
+ if(emit_xhtml) {
+ ap_rputs("", r);
+ }
if (ar[x]->lm != -1) {
char time_str[MAX_STRING_LEN];
struct tm *ts = localtime(&ar[x]->lm);
- strftime(time_str, MAX_STRING_LEN, "%d-%b-%Y %H:%M ", ts);
+ strftime(time_str, MAX_STRING_LEN,
+ (emit_xhtml ? "%d-%b-%Y %H:%M"
+ : "%d-%b-%Y %H:%M "),
+ ts);
ap_rputs(time_str, r);
}
else {
/*Length="22-Feb-1998 23:42 " (see 4 lines above) */
- ap_rputs(" ", r);
+ if(!emit_xhtml) {
+ ap_rputs(" ", r);
+ }
+ }
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
}
}
if (!(autoindex_opts & SUPPRESS_SIZE)) {
+ if(emit_xhtml) {
+ ap_rputs("", r);
+ }
ap_send_size(ar[x]->size, r);
- ap_rputs(" ", r);
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
+ } else {
+ ap_rputs(" ", r);
+ }
}
if (!(autoindex_opts & SUPPRESS_DESC)) {
+ if(emit_xhtml) {
+ ap_rputs("", r);
+ }
if (ar[x]->desc) {
ap_rputs(terminate_description(d, ar[x]->desc,
autoindex_opts,
desc_width), r);
}
+ if(emit_xhtml) {
+ ap_rputs(" \n", r);
+ }
+ }
+
+ if(emit_xhtml) {
+ ap_rputs("
\n", r);
+ ap_rputs(((autoindex_opts & EMIT_XHTML) ? "" : "
\n"), r);
}
emit_tail(r, find_readme(autoindex_conf, r),
- autoindex_opts & SUPPRESS_PREAMBLE);
+ autoindex_opts);
ap_kill_timeout(r);
return 0;
Index: htdocs/manual/mod/directives.html.de
===================================================================
RCS file: /home/cvspublic/httpd-docs-1.3/htdocs/manual/mod/directives.html.de,v
retrieving revision 1.2
diff -u -r1.2 directives.html.de
--- htdocs/manual/mod/directives.html.de 28 Sep 2001 07:15:33 -0000 1.2
+++ htdocs/manual/mod/directives.html.de 2 Feb 2002 14:32:27 -0000
@@ -222,6 +222,7 @@
+
+ StyleName
+ directive
+
+ Syntax: StyleName
+ filename
+ Context: server config, virtual
+ host, directory, .htaccess
+ Override: Indexes
+ Status: Base
+ Module: mod_autoindex
+ Compatibility: StyleName is
+ only available in Apache 1.3.24 and later.
+
+ StyleName index.css
+ will, if index.css exists, produce the line:
+ <link type="text/css" href="index.css" rel="stylesheet" />
+ as part of the <head> ... </head>
+ of the index listing.
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 content type of "text/css". Details of + how it is handled may be found under the description of the + HeaderName directive, which + uses the same mechanism (but excludes the text/css + restriction).
+ + +See also the EmitXHTML index option.
[re: ISO 8601: it would be really nice to have ISO 8601 dates in the XHTML directory listing, but after seeing in PR#7710 that this has been ruled out for 1.3, i decided to leave it out of the main patch. however, anybody using EmitXHTML is clearly going to be breaking any parsing client application anyway, so i would hope that ISO 8601 dates would be considered for when EmitXHTML is in effect. a further patch to provide this is below.] --- apache-1.3/src/modules/standard/mod_autoindex.c Sat Feb 2 14:27:52 2002 +++ apache-1.3/src/modules/standard/mod_autoindex.c Sat Feb 2 14:34:34 2002 @@ -1601,7 +1601,7 @@ char time_str[MAX_STRING_LEN]; struct tm *ts = localtime(&ar[x]->lm); strftime(time_str, MAX_STRING_LEN, - (emit_xhtml ? "%d-%b-%Y %H:%M" + (emit_xhtml ? "%Y-%m-%d %H:%M" : "%d-%b-%Y %H:%M "), ts); ap_rputs(time_str, r); >Release-Note: >Audit-Trail: From: tom stuart