Skip to content

Commit

Permalink
Tweak mappings using separate file.
Browse files Browse the repository at this point in the history
- Add separate file `mime.types.custom` for custom mappings.
- Update `bin/generate.php` to read new file with precedence.
- Update `MimeMappingGenerator` to make sure arrays are unique.
- Rebuild `mime.types.php`.
  • Loading branch information
ralouphie committed Jul 6, 2018
1 parent d69688d commit 81e30ea
Show file tree
Hide file tree
Showing 5 changed files with 196 additions and 101 deletions.
3 changes: 2 additions & 1 deletion bin/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

require_once dirname(__DIR__) . '/vendor/autoload.php';

$mime_types_custom_text = file_get_contents(dirname(__DIR__) . '/mime.types.custom');
$mime_types_text = file_get_contents(dirname(__DIR__) . '/mime.types');

$generator = new \Mimey\MimeMappingGenerator($mime_types_text);
$generator = new \Mimey\MimeMappingGenerator($mime_types_custom_text . PHP_EOL . $mime_types_text);
$mapping_code = $generator->generateMappingCode();

file_put_contents(dirname(__DIR__) . '/mime.types.php', $mapping_code);
35 changes: 29 additions & 6 deletions mime.types
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ application/ecmascript ecma
# application/edi-consent
# application/edi-x12
# application/edifact
# application/efi
# application/emergencycalldata.comment+xml
# application/emergencycalldata.deviceinfo+xml
# application/emergencycalldata.providerinfo+xml
Expand All @@ -111,10 +112,9 @@ application/exi exi
# application/fastsoap
# application/fdt+xml
# application/fits
# application/font-sfnt
application/font-tdpfr pfr
application/font-woff woff
# application/framework-attributes+xml
# application/geo+json
application/gml+xml gml
application/gpx+xml gpx
application/gxf gxf
Expand Down Expand Up @@ -156,6 +156,7 @@ application/jsonml+json jsonml
# application/kpml-request+xml
# application/kpml-response+xml
# application/ld+json
# application/lgr+xml
# application/link-format
# application/load-control+xml
application/lost+xml lostxml
Expand Down Expand Up @@ -358,13 +359,15 @@ application/vnd.3gpp.pic-bw-large plb
application/vnd.3gpp.pic-bw-small psb
application/vnd.3gpp.pic-bw-var pvb
# application/vnd.3gpp.sms
# application/vnd.3gpp.sms+xml
# application/vnd.3gpp.srvcc-ext+xml
# application/vnd.3gpp.srvcc-info+xml
# application/vnd.3gpp.state-and-event-info+xml
# application/vnd.3gpp.ussd+xml
# application/vnd.3gpp2.bcmcsinfo+xml
# application/vnd.3gpp2.sms
application/vnd.3gpp2.tcap tcap
# application/vnd.3lightssoftware.imagescal
application/vnd.3m.post-it-notes pwn
application/vnd.accpac.simply.aso aso
application/vnd.accpac.simply.imp imp
Expand All @@ -383,6 +386,7 @@ application/vnd.ahead.space ahead
application/vnd.airzip.filesecure.azf azf
application/vnd.airzip.filesecure.azs azs
application/vnd.amazon.ebook azw
# application/vnd.amazon.mobi8-ebook
application/vnd.americandynamics.acc acc
application/vnd.amiga.ami ami
# application/vnd.amundsen.maze+xml
Expand Down Expand Up @@ -419,6 +423,7 @@ application/vnd.businessobjects rep
# application/vnd.cendio.thinlinc.clientconf
# application/vnd.century-systems.tcp_stream
application/vnd.chemdraw+xml cdxml
# application/vnd.chess-pgn
application/vnd.chipnuts.karaoke-mmd mmd
application/vnd.cinderella cdy
# application/vnd.cirpack.isdn-ext
Expand All @@ -432,9 +437,11 @@ application/vnd.cluetrust.cartomobile-config-pkg c11amz
# application/vnd.collection+json
# application/vnd.collection.doc+json
# application/vnd.collection.next+json
# application/vnd.comicbook+zip
# application/vnd.commerce-battelle
application/vnd.commonspace csp
application/vnd.contact.cmsg cdbcmsg
# application/vnd.coreos.ignition+json
application/vnd.cosmocaller cmc
application/vnd.crick.clicker clkx
application/vnd.crick.clicker.keyboard clkk
Expand Down Expand Up @@ -886,6 +893,8 @@ application/vnd.olpc-sugar xo
application/vnd.oma.dd2+xml dd2
# application/vnd.oma.drm.risd+xml
# application/vnd.oma.group-usage-list+xml
# application/vnd.oma.lwm2m+json
# application/vnd.oma.lwm2m+tlv
# application/vnd.oma.pal+xml
# application/vnd.oma.poc.detailed-progress-report+xml
# application/vnd.oma.poc.final-report+xml
Expand All @@ -899,6 +908,7 @@ application/vnd.oma.dd2+xml dd2
# application/vnd.omads-file+xml
# application/vnd.omads-folder+xml
# application/vnd.omaloc-supl-init
# application/vnd.onepager
# application/vnd.openblox.game+xml
# application/vnd.openblox.game-binary
# application/vnd.openeye.oeb
Expand Down Expand Up @@ -1013,6 +1023,7 @@ application/vnd.pvi.ptid1 ptid
# application/vnd.pwg-multiplexed
# application/vnd.pwg-xhtml-print+xml
# application/vnd.qualcomm.brew-app-res
# application/vnd.quarantainenet
application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb
# application/vnd.quobject-quoxdocument
# application/vnd.radisys.moml+xml
Expand All @@ -1032,6 +1043,7 @@ application/vnd.quark.quarkxpress qxd qxt qwd qwt qxl qxb
# application/vnd.radisys.msml-dialog-transform+xml
# application/vnd.rainstor.data
# application/vnd.rapid
# application/vnd.rar
application/vnd.realvnc.bed bed
application/vnd.recordare.musicxml mxl
application/vnd.recordare.musicxml+xml musicxml
Expand Down Expand Up @@ -1146,6 +1158,7 @@ application/vnd.uoml+xml uoml
application/vnd.vcx vcx
# application/vnd.vd-study
# application/vnd.vectorworks
# application/vnd.vel+json
# application/vnd.verimatrix.vcas
# application/vnd.vidsoft.vidconference
application/vnd.visio vsd vst vss vsw
Expand Down Expand Up @@ -1246,12 +1259,10 @@ application/x-font-bdf bdf
application/x-font-ghostscript gsf
# application/x-font-libgrx
application/x-font-linux-psf psf
application/x-font-otf otf
application/x-font-pcf pcf
application/x-font-snf snf
# application/x-font-speedo
# application/x-font-sunos-news
application/x-font-ttf ttf ttc
application/x-font-type1 pfa pfb pfm afm
# application/x-font-vfont
application/x-freearc arc
Expand Down Expand Up @@ -1355,7 +1366,7 @@ application/zip zip
# audio/3gpp2
# audio/ac3
audio/adpcm adp
audio/amr amr
# audio/amr
# audio/amr-wb
# audio/amr-wb+
# audio/aptx
Expand Down Expand Up @@ -1425,7 +1436,7 @@ audio/mp4 m4a mp4a
# audio/mp4a-latm
# audio/mpa
# audio/mpa-robust
audio/mpeg mp3 mpga mp2 mp2a m2a m3a
audio/mpeg mpga mp2 mp2a mp3 m2a m3a
# audio/mpeg4-generic
# audio/musepack
audio/ogg oga ogg spx
Expand Down Expand Up @@ -1519,13 +1530,22 @@ chemical/x-cml cml
chemical/x-csml csml
# chemical/x-pdb
chemical/x-xyz xyz
font/collection ttc
font/otf otf
# font/sfnt
font/ttf ttf
font/woff woff
font/woff2 woff2
image/bmp bmp
image/cgm cgm
# image/dicom-rle
# image/emf
# image/example
# image/fits
image/g3fax g3
image/gif gif
image/ief ief
# image/jls
# image/jp2
image/jpeg jpeg jpg jpe
# image/jpm
Expand Down Expand Up @@ -1572,6 +1592,7 @@ image/vnd.wap.wbmp wbmp
image/vnd.xiff xif
# image/vnd.zbrush.pcx
image/webp webp
# image/wmf
image/x-3ds 3ds
image/x-cmu-raster ras
image/x-cmx cmx
Expand Down Expand Up @@ -1611,6 +1632,7 @@ message/rfc822 eml mime
# message/vnd.si.simp
# message/vnd.wfa.wsc
# model/example
# model/gltf+json
model/iges igs iges
model/mesh msh mesh silo
model/vnd.collada+xml dae
Expand Down Expand Up @@ -1675,6 +1697,7 @@ text/plain txt text conf def list log in
# text/provenance-notation
# text/prs.fallenstein.rst
text/prs.lines.tag dsc
# text/prs.prop.logic
# text/raptorfec
# text/red
# text/rfc822-headers
Expand Down
20 changes: 20 additions & 0 deletions mime.types.custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This file is in the same format as mime.types but the
# mappings in this file take precedence.
#
# MIME type (lowercased) Extensions
# ============================================ ==========

application/font-woff wof
application/php php
application/x-font-otf otf
application/x-font-ttf ttf ttc
application/x-gzip zip
application/x-httpd-php php
application/x-httpd-php-source php
application/x-php php
audio/amr amr
audio/mpeg mp3 mpga mp2 mp2a m2a m3a
image/jpeg jpg jpeg jpe
image/x-ms-bmp bmp
text/php php
text/x-php php
Loading

0 comments on commit 81e30ea

Please sign in to comment.