--- modules/generators/mod_autoindex.c.old Sun Nov 11 23:32:47 2007 +++ modules/generators/mod_autoindex.c Sun Nov 11 23:33:51 2007 @@ -72,7 +72,8 @@ #define SHOW_FORBIDDEN (1 << 18) #define OPTION_UNSET (1 << 19) #define OPTION_UNSET (1 << 19) +#define ALWAYS_EMIT_H1 (1 << 31) #define K_NOADJUST 0 #define K_ADJUST 1 @@ -101,6 +102,13 @@ #define DEFAULT_NAME_WIDTH 23 #define DEFAULT_DESC_WIDTH 23 +/* + * Thumbnail types + */ +#define THUMB_NONE 'n' +#define THUMB_STATIC 's' +#define THUMB_DYNAMIC 'd' + struct item { char *type; char *apply_to; @@ -136,6 +144,8 @@ apr_array_header_t *desc_list; apr_array_header_t *ign_list; apr_array_header_t *hdr_list; + apr_array_header_t *mnu_list; + apr_array_header_t *thb_list; apr_array_header_t *rdme_list; char *ctype; @@ -148,6 +158,8 @@ #define BY_TYPE &c_by_type #define BY_PATH &c_by_path +static char overall_thumb_type = THUMB_NONE; + /* * This routine puts the standard HTML header at the top of the index page. * We include the DOCTYPE because we may be using features therefrom (i.e., @@ -167,6 +179,16 @@ ap_rvputs(r, " style_sheet, "\" type=\"text/css\"", xhtml ? " />\n" : ">\n", NULL); } + if (overall_thumb_type != THUMB_NONE) { + ap_rvputs(r, " \n" : ">\n", NULL); + } + if (overall_thumb_type == THUMB_DYNAMIC) { + ap_rvputs(r, "", NULL); + } ap_rvputs(r, " \n
\n", NULL); } @@ -307,6 +329,19 @@ return NULL; } +static const char *add_menu(cmd_parms *cmd, void *d, const char *name) +{ + push_item(((autoindex_config_rec *) d)->mnu_list, 0, NULL, cmd->path, + name); + return NULL; +} + +static const char *add_thumb(cmd_parms *cmd, void *d, const char *type, const char* to) +{ + push_item(((autoindex_config_rec *) d)->thb_list, cmd->info, to, cmd->path, type); + return NULL; +} + static const char *add_readme(cmd_parms *cmd, void *d, const char *name) { push_item(((autoindex_config_rec *) d)->rdme_list, 0, NULL, cmd->path, @@ -389,6 +424,9 @@ else if (!strcasecmp(w, "XHTML")) { option = EMIT_XHTML; } + else if (!strcasecmp(w, "AlwaysEmitH1")) { + option = ALWAYS_EMIT_H1; + } else if (!strcasecmp(w, "ShowForbidden")) { option = SHOW_FORBIDDEN; } @@ -574,6 +612,10 @@ "Descriptive text followed by one or more filenames"), AP_INIT_TAKE1("HeaderName", add_header, NULL, DIR_CMD_PERMS, "a filename"), + AP_INIT_TAKE1("MenuName", add_menu, NULL, DIR_CMD_PERMS, + "a filename"), + AP_INIT_ITERATE2("AddThumbByType", add_thumb, BY_TYPE, DIR_CMD_PERMS, + "set default thumb type for one or more MIME types"), AP_INIT_TAKE1("ReadmeName", add_readme, NULL, DIR_CMD_PERMS, "a filename"), AP_INIT_RAW_ARGS("FancyIndexing", ap_set_deprecated, NULL, OR_ALL, @@ -604,6 +646,8 @@ new->desc_list = apr_array_make(p, 4, sizeof(ai_desc_t)); new->ign_list = apr_array_make(p, 4, sizeof(struct item)); new->hdr_list = apr_array_make(p, 4, sizeof(struct item)); + new->mnu_list = apr_array_make(p, 4, sizeof(struct item)); + new->thb_list = apr_array_make(p, 4, sizeof(struct item)); new->rdme_list = apr_array_make(p, 4, sizeof(struct item)); new->opts = 0; new->incremented_opts = 0; @@ -634,6 +678,8 @@ new->alt_list = apr_array_append(p, add->alt_list, base->alt_list); new->ign_list = apr_array_append(p, add->ign_list, base->ign_list); new->hdr_list = apr_array_append(p, add->hdr_list, base->hdr_list); + new->mnu_list = apr_array_append(p, add->mnu_list, base->mnu_list); + new->thb_list = apr_array_append(p, add->thb_list, base->thb_list); new->desc_list = apr_array_append(p, add->desc_list, base->desc_list); new->icon_list = apr_array_append(p, add->icon_list, base->icon_list); new->rdme_list = apr_array_append(p, add->rdme_list, base->rdme_list); @@ -722,6 +768,8 @@ struct ent { char *name; char *icon; + char *thumb; + int thumb_type; char *alt; char *desc; apr_off_t size; @@ -781,6 +829,8 @@ #define find_icon(d,p,t) find_item(p,d->icon_list,t) #define find_alt(d,p,t) find_item(p,d->alt_list,t) #define find_header(d,p) find_item(p,d->hdr_list,0) +#define find_menu(d,p) find_item(p,d->mnu_list,0) +#define find_thumb(d,p) find_item(p,d->thb_list,0) #define find_readme(d,p) find_item(p,d->rdme_list,0) static char *find_default_item(char *bogus_name, apr_array_header_t *list) @@ -912,7 +962,7 @@ * Header file * Emitted if found (and able). * H1 tag line - * Emitted if a header file is NOT emitted. + * Emitted if a header file is NOT emitted OR ALWAYS_EMIT_H1 is set. * Directory stuff * Always emitted. * HR @@ -984,11 +1034,13 @@ * oh well. */ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, - int emit_xhtml, char *title) + int emit_xhtml, char *title, int always_emit_H1, + char *menu_fname) { apr_table_t *hdrs = r->headers_in; apr_file_t *f = NULL; request_rec *rr = NULL; + request_rec *rr_menu = NULL; int emit_amble = 1; int emit_H1 = 1; const char *r_accept; @@ -1008,6 +1060,10 @@ header_fname = apr_pstrcat(r->pool, header_fname, "?", r->args, NULL); } + if ((menu_fname != NULL) && r->args) { + menu_fname = apr_pstrcat(r->pool, menu_fname, "?", r->args, NULL); + } + if ((header_fname != NULL) && (rr = ap_sub_req_lookup_uri(header_fname, r, r->output_filters)) && (rr->status == HTTP_OK) @@ -1075,6 +1131,34 @@ } } + if ((menu_fname != NULL) + && (rr_menu = ap_sub_req_lookup_uri(menu_fname, r, r->output_filters)) + && (rr_menu->status == HTTP_OK) + && (rr_menu->filename != NULL) + && (rr_menu->finfo.filetype == APR_REG)) { + + if (rr_menu->content_type != NULL) { + if (!strcasecmp(ap_field_noparam(r->pool, rr_menu->content_type), + "text/html")) { + ap_filter_t *f; + + if (emit_amble) { + emit_preamble(r, emit_xhtml, title); + } + + /* copy of hack from rr / header_fname request */ + for (f=rr_menu->output_filters; + f->frec != ap_subreq_core_filter_handle; f = f->next); + f->next = r->output_filters; + + if (ap_run_sub_req(rr_menu) == OK) { + /* success */ + emit_amble = 0; + } + } + } + } + if (r_accept) { apr_table_setn(hdrs, "Accept", r_accept); } @@ -1089,12 +1173,15 @@ if (emit_amble) { emit_preamble(r, emit_xhtml, title); } - if (emit_H1) { - ap_rvputs(r, "