Received: (from majordom@localhost) by hyperreal.com (8.8.5/8.8.5) id RAA10534; Mon, 16 Jun 1997 17:02:21 -0700 (PDT) Received: from DECUS.Org (Topaz.DECUS.Org [192.67.173.1]) by hyperreal.com (8.8.5/8.8.5) with ESMTP id RAA10521 for ; Mon, 16 Jun 1997 17:02:17 -0700 (PDT) Received: from Lucy.DECUS.Org (lucy.process.com) by DECUS.Org (PMDF V4.2-13 #18511) id <01IK5I5IXGJK8WXWIT@DECUS.Org>; Mon, 16 Jun 1997 20:02:03 EDT Received: from master.process.com by Lucy.DECUS.Org; (5.65v3.2/1.1.8.2/16Sep96-0258PM) id AA18302; Mon, 16 Jun 1997 20:05:29 -0400 Date: Mon, 16 Jun 1997 19:58:42 -0400 From: coar@decus.org (Rodent of Unusual Size) Subject: [PATCH] to let mod_dir include HEIGHT/WIDTH attributes on icon IMGs To: New-HTTPd@apache.org, Coar@decus.org Message-id: <97061619584220@decus.org> X-VMS-To: NH X-VMS-Cc: COAR Content-transfer-encoding: 7BIT Sender: new-httpd-owner@apache.org Precedence: bulk Reply-To: new-httpd@apache.org This patch adds two new options to mod_dir's IndexOptions: "IconHeight[=n]" and "IconWidth[=n]". If both options are present, the IMG tags for the FancyIndexing tags will include HEIGHT and WIDTH attributes, allowing faster browser real-estate layout while the images are loading. If either of the options is specified without an explicit value, the corresponding dimension of the default Apache icons (20x22) is used. E.g., "IndexOptions IconHeight IconWidth" leads to "HEIGHT=22 WIDTH=20", and "IndexOptions IconHeight=44 IconWidth" leads to double-height, normal-width ("HEIGHT=44 WIDTH=20"). Two files in the patch: src/mod_dir.c and the documentation, htdocs/manual/mod/mod_dir.html. #ken :-)} Index: mod_dir.c =================================================================== RCS file: /export/home/cvs/apache/src/mod_dir.c,v retrieving revision 1.26 diff -c -r1.26 mod_dir.c *** mod_dir.c 1997/05/13 04:01:50 1.26 --- mod_dir.c 1997/06/15 19:16:47 *************** *** 82,87 **** --- 82,93 ---- #define SUPPRESS_SIZE 16 #define SUPPRESS_DESC 32 + /* + * These are the dimensions of the default icons supplied with Apache. + */ + #define DEFAULT_ICON_WIDTH 20 + #define DEFAULT_ICON_HEIGHT 22 + struct item { char *type; char *apply_to; *************** *** 93,98 **** --- 99,106 ---- char *default_icon; char *index_names; + int icon_width; + int icon_height; array_header *icon_list, *alt_list, *desc_list, *ign_list; array_header *hdr_list, *rdme_list, *opts_list; *************** *** 188,193 **** --- 196,202 ---- const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) { char *w; int opts = 0; + dir_config_rec *d_cfg = (dir_config_rec *) d; while(optstr[0]) { w = getword_conf(cmd->pool, &optstr); *************** *** 205,210 **** --- 214,243 ---- opts |= SUPPRESS_DESC; else if(!strcasecmp(w,"None")) opts = 0; + else if (! strncasecmp (w, "IconWidth", 9)) { + if (strchr (w, '=') != NULL) { + const char *x = pstrdup (cmd->pool, w); + char *val; + val = getword (cmd->pool, &x, '='); + val = getword (cmd->pool, &x, '='); + d_cfg->icon_width = atoi(val); + } + else { + d_cfg->icon_width = DEFAULT_ICON_WIDTH; + } + } + else if (! strncasecmp (w, "IconHeight", 10)) { + if (strchr (w, '=') != NULL) { + const char *x = pstrdup (cmd->pool, w); + char *val; + val = getword (cmd->pool, &x, '='); + val = getword (cmd->pool, &x, '='); + d_cfg->icon_height = atoi(val); + } + else { + d_cfg->icon_height = DEFAULT_ICON_HEIGHT; + } + } else return "Invalid directory indexing option"; } *************** *** 250,255 **** --- 283,290 ---- (dir_config_rec *) pcalloc (p, sizeof(dir_config_rec)); new->index_names = NULL; + new->icon_width = 0; + new->icon_height = 0; new->icon_list = make_array (p, 4, sizeof (struct item)); new->alt_list = make_array (p, 4, sizeof (struct item)); new->desc_list = make_array (p, 4, sizeof (struct item)); *************** *** 269,274 **** --- 304,311 ---- new->default_icon = add->default_icon?add->default_icon:base->default_icon; new->index_names = add->index_names? add->index_names: base->index_names; + new->icon_height = add->icon_height ? add->icon_height : base->icon_height; + new->icon_width = add->icon_width ? add->icon_width : base->icon_width; new->alt_list = append_arrays (p, add->alt_list, base->alt_list); new->ign_list = append_arrays (p, add->ign_list, base->ign_list); *************** *** 573,581 **** if(dir_opts & FANCY_INDEXING) { rputs("
", r);
!         if((tp = find_default_icon(d,"^^BLANKICON^^")))
              rvputs(r, "\" ", NULL);
          rputs("Name                   ", r);
          if(!(dir_opts & SUPPRESS_LAST_MOD))
              rputs("Last modified     ", r);
--- 610,629 ----
  
      if(dir_opts & FANCY_INDEXING) {
          rputs("
", r);
!         if((tp = find_default_icon(d,"^^BLANKICON^^"))) {
              rvputs(r, "\"icon_width && d->icon_height) {
! 		rprintf
! 		    (
! 			r,
! 			" HEIGHT=\"%d\" WIDTH=\"%d\"",
! 			d->icon_height,
! 			d->icon_width
! 		    );
! 	    }
! 	    rputs ("> ", r);
! 	}
          rputs("Name                   ", r);
          if(!(dir_opts & SUPPRESS_LAST_MOD))
              rputs("Last modified     ", r);
***************
*** 633,640 ****
  		       escape_html(scratch, ar[x]->icon ?
  				   ar[x]->icon : d->default_icon),
  		       "\" ALT=\"[", (ar[x]->alt ? ar[x]->alt : "   "),
! 		       "]\">", NULL);
!             }
              if(dir_opts & ICONS_ARE_LINKS) 
                  rputs("", r);
  
--- 681,698 ----
  		       escape_html(scratch, ar[x]->icon ?
  				   ar[x]->icon : d->default_icon),
  		       "\" ALT=\"[", (ar[x]->alt ? ar[x]->alt : "   "),
! 		       "]\"", NULL);
! 		if (d->icon_width && d->icon_height) {
! 		    rprintf
! 			(
! 			    r,
! 			    " HEIGHT=\"%d\" WIDTH=\"%d\"",
! 			    d->icon_height,
! 			    d->icon_width
! 			);
! 		}
! 		rputs (">", r);
! 	    }
              if(dir_opts & ICONS_ARE_LINKS) 
                  rputs("", r);
  
Index: mod_dir.html
===================================================================
RCS file: /export/home/cvs/apache/htdocs/manual/mod/mod_dir.html,v
retrieving revision 1.6
diff -c -r1.6 mod_dir.html
*** mod_dir.html	1997/06/04 16:14:19	1.6
--- mod_dir.html	1997/06/15 19:17:49
***************
*** 324,329 ****
--- 324,349 ----
  
This will suppress the file description in fancy indexing listings. +
IconHeight[=pixels] +
+ + Presence of this option, when used with IconWidth, will cause the server + to include HEIGHT and WIDTH attributes in the + IMG tag for the file icon. This allows browser to + precalculate the page layout without having to wait until all the + images have been loaded. If no value is given for the option, it + defaults to the standard height of the icons supplied with the Apache + software. +
IconWidth[=pixels] +
+ + Presence of this option, when used with IconHeight, will cause the server + to include HEIGHT and WIDTH attributes in the + IMG tag for the file icon. This allows browser to + precalculate the page layout without having to wait until all the + images have been loaded. If no value is given for the option, it + defaults to the standard width of the icons supplied with the Apache + software. This default is that no options are enabled. If multiple IndexOptions could apply to a directory, then the most specific one is taken complete;