]> git.pld-linux.org Git - packages/lighttpd.git/blobdiff - lighttpd-mime.types.sh
- rel 2; use branch diff until .41 is released
[packages/lighttpd.git] / lighttpd-mime.types.sh
index 089dbd034a3ba719b9c02ca7f7542e6d1ee5a9bf..5252638ff7cc945ab38c71d9d9a2565be0205bea 100644 (file)
@@ -13,7 +13,19 @@ awk '{for (a=2; a <= NF; a++) {printf("%s\t%s\n", $1, $a)}}' | \
 LC_ALL=C sort -u > mime.types
 
 # build lighttpd.conf fragment
-awk '{ printf("\t\".%s\"%s=> \"%s\",\n", $2, (length($2) > 4 ? "\t" : "\t\t"), $1)}' \
+awk '{
+       ext = $2;
+       type = $1;
+       charset = "";
+       # add charset for "text/*" types
+       if (type ~ "text/") {
+               type = "\"" type "\" + mimetype_textcharsetheader"
+       } else {
+               type = "\"" type "\""
+       }
+
+       printf("\t\".%s\"%s=> %s,\n", ext, (length(ext) > 4 ? "\t" : "\t\t"), type);
+}' \
        < mime.types | LC_ALL=C sort -r > mime.types.conf
 
 # sanity check. there can't be more than one mime type mapping for same extension
@@ -28,6 +40,14 @@ mv -f mime.types.conf mime.types.conf.tmp
 
 # header
 cat >> mime.types.conf <<EOF
+# charset used for "text/*" mimetypes
+# Apache's AddCharset equivalent. Leave empty to add no charset.
+# AddCharset "utf-8" would be "; charset=\"utf-8\""
+# See this post about what it affects:
+# http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2012-February/022499.html
+mimetype_textcharsetheader = ""
+#mimetype_textcharsetheader = "; charset=\"utf-8\""
+
 # mimetype mapping
 mimetype.assign = (
 EOF
@@ -39,3 +59,5 @@ cat mime.types.conf.tmp >> mime.types.conf
 cat >> mime.types.conf <<EOF
 )
 EOF
+
+rm -f mime.types.conf.tmp
This page took 0.1016 seconds and 4 git commands to generate.