From: Rich Bowen Date: Tue, 26 Jan 2010 02:25:04 +0000 (+0000) Subject: Applies the patch provided in ticket 34014, enhancing the CSS abilities X-Git-Tag: 2.3.6~550 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ecdfd66e6eeb0a61f1d501708e2f4c49a0f9381a;p=thirdparty%2Fapache%2Fhttpd.git Applies the patch provided in ticket 34014, enhancing the CSS abilities of mod_autoindex. Documentation to follow momentarily. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@903052 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 620ed3cf88f..b9151693bdc 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -71,6 +71,7 @@ module AP_MODULE_DECLARE_DATA autoindex_module; #define IGNORE_CASE (1 << 16) #define EMIT_XHTML (1 << 17) #define SHOW_FORBIDDEN (1 << 18) +#define ADDALTCLASS (1 << 19) #define K_NOADJUST 0 #define K_ADJUST 1 @@ -399,6 +400,9 @@ static const char *add_opts(cmd_parms *cmd, void *d, int argc, char *const argv[ else if (!strcasecmp(w, "ShowForbidden")) { option = SHOW_FORBIDDEN; } + else if (!strcasecmp(w, "AddAltClass")) { + option = ADDALTCLASS; + } else if (!strcasecmp(w, "None")) { if (action != '\0') { return "Cannot combine '+' or '-' with 'None' keyword"; @@ -1090,9 +1094,18 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, if (emit_amble) { emit_preamble(r, emit_xhtml, title); } + + autoindex_config_rec *d; + d = (autoindex_config_rec *) ap_get_module_config(r->per_dir_config, &autoindex_module); + if (emit_H1) { + if (d->style_sheet != NULL) { + // Insert style id if stylesheet used + ap_rvputs(r, "

Index of ", title, "

\n", NULL); + } else { ap_rvputs(r, "

Index of ", title, "

\n", NULL); } + } if (rr != NULL) { ap_destroy_sub_req(rr); } @@ -1162,7 +1175,7 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble) ap_rputs(ap_psignature("", r), r); } if (!suppress_post) { - ap_rputs("\n", r); + ap_rputs(" \n\n", r); } if (rr != NULL) { ap_destroy_sub_req(rr); @@ -1267,7 +1280,9 @@ static struct ent *make_parent_entry(apr_int32_t autoindex_opts, } if (!(p->alt = find_default_alt(d, testpath))) { if (!(p->alt = find_default_alt(d, "^^DIRECTORY^^"))) { - p->alt = "DIR"; + // Special alt text for parent dir to distinguish it from other directories + // this is essential when trying to style this dir entry via AddAltClass + p->alt = "PARENTDIR"; } } p->desc = find_desc(d, testpath); @@ -1531,9 +1546,14 @@ static void output_directories(struct ent **ar, int n, if (autoindex_opts & TABLE_INDEXING) { int cols = 1; - ap_rputs("", r); + if (d->style_sheet != NULL) { + // Emit table with style id + ap_rputs("
\n ", r); + } else { + ap_rputs("
\n ", r); + } if (!(autoindex_opts & SUPPRESS_ICON)) { - ap_rputs("style_sheet != NULL) ? " class=\"indexcollastmod\">" : ">", NULL); emit_link(r, "Last modified", K_LAST_MOD, keyid, direction, colargs, static_columns); ++cols; } if (!(autoindex_opts & SUPPRESS_SIZE)) { - ap_rputs("style_sheet != NULL) ? " class=\"indexcolsize\">" : ">", NULL); emit_link(r, "Size", K_SIZE, keyid, direction, colargs, static_columns); ++cols; } if (!(autoindex_opts & SUPPRESS_DESC)) { - ap_rputs("style_sheet != NULL) ? " class=\"indexcoldesc\">" : ">", NULL); emit_link(r, "Description", K_DESC, keyid, direction, colargs, static_columns); ++cols; } if (!(autoindex_opts & SUPPRESS_RULES)) { breakrow = apr_psprintf(r->pool, - "\n", cols, + " \n", + (d->style_sheet != NULL) ? " class=\"indexbreakrow\"" : "", + cols, (autoindex_opts & EMIT_XHTML) ? " /" : ""); } - ap_rvputs(r, "", breakrow, NULL); + ap_rvputs(r, "\n", breakrow, NULL); } else if (autoindex_opts & FANCY_INDEXING) { ap_rputs("
", r);
@@ -1659,25 +1681,23 @@ static void output_directories(struct ent **ar, int n,
         }
 
         if (autoindex_opts & TABLE_INDEXING) {
-            ap_rputs("style_sheet != NULL) {
-                ap_rputs(" class=\"", r);
-                if ( row_count % 2 == 0 ) {
-                    ap_rputs("ai_tr_even", r);
+                if (ar[x]->alt && (autoindex_opts & ADDALTCLASS)) {
+                    // Include alt text in class name, distinguish between odd and even rows
+                    char *altclass = apr_pstrdup(scratch, ar[x]->alt);
+                    ap_str_tolower(altclass);
+                    ap_rvputs(r, "   
", NULL); + } else { + // Distinguish between odd and even rows + ap_rvputs(r, " ", NULL); } - else { - ap_rputs("ai_tr_odd", r); - } - ap_rputs("\"", r); - row_count++; + } else { + ap_rputs("", r); } - ap_rputs(">", r); - if (!(autoindex_opts & SUPPRESS_ICON)) { - ap_rputs("style_sheet != NULL) ? " class=\"indexcollastmod\">" : " align=\"right\">",time_str, NULL); } else { - ap_rputs("style_sheet != NULL) ? " class=\"indexcollastmod\"> " : "> ", NULL); } } if (!(autoindex_opts & SUPPRESS_SIZE)) { char buf[5]; - ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcolsize\">" : " align=\"right\">", apr_strfsize(ar[x]->size, buf), NULL); } if (!(autoindex_opts & SUPPRESS_DESC)) { if (ar[x]->desc) { if (d->desc_adjust == K_ADJUST) { - ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcoldesc\">" : ">", ar[x]->desc, NULL); } else { - ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcoldesc\">" : ">", terminate_description(d, ar[x]->desc, autoindex_opts, desc_width), NULL); @@ -1823,11 +1843,11 @@ static void output_directories(struct ent **ar, int n, apr_time_exp_t ts; apr_time_exp_lt(&ts, ar[x]->lm); apr_strftime(time_str, &rv, MAX_STRING_LEN, - "%d-%b-%Y %H:%M ", &ts); + "%Y-%m-%d %H:%M ", &ts); ap_rputs(time_str, r); } else { - /*Length="22-Feb-1998 23:42 " (see 4 lines above) */ + /*Length="1975-04-07 01:23 " (see 4 lines above) */ ap_rputs(" ", r); } }
", r); + ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcolicon\">" : " valign=\"top\">", NULL); if ((tp = find_default_icon(d, "^^BLANKICON^^"))) { ap_rvputs(r, "\"[ICO]\"",", r); + ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcolname\">" : ">", NULL); emit_link(r, "Name", K_NAME, keyid, direction, colargs, static_columns); if (!(autoindex_opts & SUPPRESS_LAST_MOD)) { - ap_rputs("", r); + ap_rvputs(r, "", r); + ap_rvputs(r, "", r); + ap_rvputs(r, "
" - "
" + "
", r); + ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcolicon\">" : " valign=\"top\">", NULL); if (autoindex_opts & ICONS_ARE_LINKS) { ap_rvputs(r, "", NULL); } @@ -1711,7 +1731,7 @@ static void output_directories(struct ent **ar, int n, } } if (d->name_adjust == K_ADJUST) { - ap_rvputs(r, "", + ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcolname\">" : ">", "", ap_escape_html(scratch, t2), "", NULL); } else { @@ -1725,7 +1745,7 @@ static void output_directories(struct ent **ar, int n, t2 = name_scratch; nwidth = name_width; } - ap_rvputs(r, "", + ap_rvputs(r, "style_sheet != NULL) ? " class=\"indexcolname\">" : ">", "", ap_escape_html(scratch, t2), "", pad_scratch + nwidth, NULL); } @@ -1735,26 +1755,26 @@ static void output_directories(struct ent **ar, int n, apr_time_exp_t ts; apr_time_exp_lt(&ts, ar[x]->lm); apr_strftime(time_str, &rv, MAX_STRING_LEN, - "%d-%b-%Y %H:%M ", + "%Y-%m-%d %H:%M ", &ts); - ap_rputs(time_str, r); + ap_rvputs(r, " ", r); + ap_rvputs(r, "", + ap_rvputs(r, "", ar[x]->desc, NULL); + ap_rvputs(r, "", + ap_rvputs(r, "