coar 98/12/01 19:45:54
Modified: . STATUS htdocs/manual/mod mod_mime.html src CHANGES src/modules/standard mod_mime.c Log: Put in Paul's DefaultLanguage code. I don't recall seeing any negative comments, and it's pretty valuable for multilingual sites. Revision Changes Path 1.546 +1 -8 apache-1.3/STATUS Index: STATUS =================================================================== RCS file: /home/cvs/apache-1.3/STATUS,v retrieving revision 1.545 retrieving revision 1.546 diff -u -r1.545 -r1.546 --- STATUS 1998/12/01 15:39:04 1.545 +++ STATUS 1998/12/02 03:45:50 1.546 @@ -1,4 +1,4 @@ - 1.3 STATUS: + 1.3 STATUS: Release: @@ -110,13 +110,6 @@ change "httpd" to "apache" or to whatever for the particular installation. Status: Ralf +1 - - * Paul's [PATCH] adding a DefaultLanguage directive - This patch implements a DefaultLanguage directive. It sets the - language to apply to files with no explicit language set via - AddLanguage. - Message-ID: <[EMAIL PROTECTED]> - Status: Paul +1, Ken +1 * Michael van Elst's patch [PR#3160] to improve mod_rewrite's in-core cache handling by using a hash table. 1.26 +49 -9 apache-1.3/htdocs/manual/mod/mod_mime.html Index: mod_mime.html =================================================================== RCS file: /home/cvs/apache-1.3/htdocs/manual/mod/mod_mime.html,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- mod_mime.html 1998/11/20 15:45:36 1.25 +++ mod_mime.html 1998/12/02 03:45:51 1.26 @@ -36,11 +36,11 @@ file. Respectively they set the content-encoding, handler, content-language and MIME-type (content-type) of documents. The directive <A HREF="#typesconfig">TypesConfig</A> is used to specify a -file which also maps extensions onto mime types. The directives <A +file which also maps extensions onto MIME types. The directives <A HREF="#forcetype">ForceType</A> and <A HREF="#sethandler">SetHandler</A> are used to associated all the files in a given location (<EM>e.g.</EM>, a particular directory) onto a particular -mime type or handler. +MIME type or handler. <P> @@ -90,6 +90,7 @@ <LI><A HREF="#addhandler">AddHandler</A> <LI><A HREF="#addlanguage">AddLanguage</A> <LI><A HREF="#addtype">AddType</A> +<LI><A HREF="#defaultlanguage">DefaultLanguage</A> <LI><A HREF="#forcetype">ForceType</A> <LI><A HREF="#sethandler">SetHandler</A> <LI><A HREF="#typesconfig">TypesConfig</A> @@ -121,7 +122,7 @@ ><STRONG>Module:</STRONG></A> mod_mime<P> The AddEncoding directive maps the given filename extensions to the -specified encoding type. <EM>Mime-enc</EM> is the mime encoding to use +specified encoding type. <EM>MIME-enc</EM> is the MIME encoding to use for documents containing the <EM>extension</EM>. This mapping is added to any already in force, overriding any mappings that already exist for the same <EM>extension</EM>. @@ -227,7 +228,7 @@ ><STRONG>Module:</STRONG></A> mod_mime<P> The AddLanguage directive maps the given filename extensions to the -specified content language. <EM>Mime-lang</EM> is the mime language of +specified content language. <EM>MIME-lang</EM> is the MIME language of filenames containing <EM>extension</EM>. This mapping is added to any already in force, overriding any mappings that already exist for the same <EM>extension</EM>. @@ -275,18 +276,18 @@ ><STRONG>Module:</STRONG></A> mod_mime<P> The AddType directive maps the given filename extensions onto the -specified content type. <EM>Mime-enc</EM> is the mime type to use for +specified content type. <EM>MIME-enc</EM> is the MIME type to use for filenames containing <EM>extension</EM>. This mapping is added to any already in force, overriding any mappings that already exist for the same <EM>extension</EM>. This directive can be used to add mappings -not listed in the mime types file (see the <CODE><A +not listed in the MIME types file (see the <CODE><A HREF="#typesconfig">TypesConfig</A></CODE> directive). Example: <BLOCKQUOTE><CODE> AddType image/gif GIF </CODE></BLOCKQUOTE> -It is recommended that new mime types be added using the AddType directive +It is recommended that new MIME types be added using the AddType directive rather than changing the <A HREF="#typesconfig">TypesConfig</A> file.<P> Note that, unlike the NCSA httpd, this directive cannot be used to set the type of particular files.<P> @@ -298,6 +299,45 @@ <HR> +<H2><A NAME="defaultlanguage">DefaultLanguage</A></H2> +<!--%plaintext <?INDEX {\tt DefaultLanguage} directive> --> +<A + HREF="directive-dict.html#Syntax" + REL="Help" +><STRONG>Syntax:</STRONG></A> DefaultLanguage <EM>MIME-lang</EM><BR> +<A + HREF="directive-dict.html#Context" + REL="Help" +><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR> +<A + HREF="directive-dict.html#Override" + REL="Help" +><STRONG>Override:</STRONG></A> FileInfo<BR> +<A + HREF="directive-dict.html#Status" + REL="Help" +><STRONG>Status:</STRONG></A> Base<BR> +<A + HREF="directive-dict.html#Module" + REL="Help" +><STRONG>Module:</STRONG></A> mod_mime<P> + +The DefaultLanguage directive tells Apache that all files in the +directive's scope (<EM>e.g.</EM>, all files covered by the current +<CODE><Directory></CODE> container) that don't have an explicit language +extension (such as <SAMP>.fr</SAMP> or <SAMP>.de</SAMP>) should be +considered to be the specified <EM>MIME-lang</EM> language +by default, rather than English. This allows entire directories +to be marked as containing Dutch content, for instance, without +having to rename each file. + +<P> + +<STRONG>See also</STRONG>: <A HREF="#multipleext">Files with +multiple extensions</A> + +<HR> + <H2><A NAME="forcetype">ForceType</A></H2> <A @@ -389,7 +429,7 @@ <A HREF="directive-dict.html#Default" REL="Help" -><STRONG>Default:</STRONG></A> <CODE>TypesConfig conf/mime.types</CODE><BR> +><STRONG>Default:</STRONG></A> <CODE>TypesConfig conf/MIME.types</CODE><BR> <A HREF="directive-dict.html#Context" REL="Help" @@ -403,7 +443,7 @@ REL="Help" ><STRONG>Module:</STRONG></A> mod_mime<P> -The TypesConfig directive sets the location of the mime types configuration +The TypesConfig directive sets the location of the MIME types configuration file. <EM>Filename</EM> is relative to the <A HREF="core.html#serverroot">ServerRoot</A>. This file sets the default list of mappings from filename extensions to content types; changing this file is not 1.1154 +7 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1153 retrieving revision 1.1154 diff -u -r1.1153 -r1.1154 --- CHANGES 1998/12/01 23:59:53 1.1153 +++ CHANGES 1998/12/02 03:45:52 1.1154 @@ -1,4 +1,11 @@ Changes with Apache 1.3.4 + + *) Add a DefaultLanguage directive so that files missing a language + extension (e.g., .fr, .de) can be labelled as being some other + language than English by default. DefaultLanguage can appear in + <Directory> and <Files> containers as well as .htaccess files. + [Paul Sutton] + *) Fix TARGET configuration when configuring and installing using APACI configure. TARGET now defines the basename of the configuration file, startup script, manual page, etc. log_error_core() now reports 1.47 +24 -3 apache-1.3/src/modules/standard/mod_mime.c Index: mod_mime.c =================================================================== RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_mime.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- mod_mime.c 1998/12/02 00:00:17 1.46 +++ mod_mime.c 1998/12/02 03:45:53 1.47 @@ -81,6 +81,7 @@ char *type; /* Type forced with ForceType */ char *handler; /* Handler forced with SetHandler */ + char *default_language; /* Language if no AddLanguage ext found */ } mime_dir_config; module MODULE_VAR_EXPORT mime_module; @@ -98,6 +99,7 @@ new->type = NULL; new->handler = NULL; + new->default_language = NULL; return new; } @@ -107,13 +109,13 @@ mime_dir_config *base = (mime_dir_config *) basev; mime_dir_config *add = (mime_dir_config *) addv; mime_dir_config *new = - (mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config)); + (mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config)); int i; handlers_info *hand; hand = (handlers_info *) add->handlers_remove->elts; for (i = 0; i < add->handlers_remove->nelts; i++) { - ap_table_unset(base->handlers, hand[i].name); + ap_table_unset(base->handlers, hand[i].name); } new->forced_types = ap_overlay_tables(p, add->forced_types, @@ -127,6 +129,8 @@ new->type = add->type ? add->type : base->type; new->handler = add->handler ? add->handler : base->handler; + new->default_language = add->default_language ? + add->default_language : base->default_language; return new; } @@ -182,7 +186,7 @@ handlers_info *hand; if (*ext == '.') { - ++ext; + ++ext; } hand = (handlers_info *) ap_push_array(mcfg->handlers_remove); hand->name = ap_pstrdup(cmd->pool, ext); @@ -219,6 +223,9 @@ "a handler name"}, {"TypesConfig", set_types_config, NULL, RSRC_CONF, TAKE1, "the MIME types config file"}, + {"DefaultLanguage", ap_set_string_slot, + (void*)XtOffsetOf(mime_dir_config, default_language), OR_FILEINFO, TAKE1, + "language to use for documents with no other language file extension" }, {NULL} }; @@ -347,6 +354,20 @@ r->handler = orighandler; } + } + + /* Set default language, if none was specified by the extensions + * and we have a DefaultLanguage setting in force + */ + + if (!r->content_languages && conf->default_language) { + const char **new; + + r->content_language = conf->default_language; /* back compat. only */ + if (!r->content_languages) + r->content_languages = ap_make_array(r->pool, 2, sizeof(char *)); + new = (const char **) ap_push_array(r->content_languages); + *new = conf->default_language; } /* Check for overrides with ForceType/SetHandler */