oupala / apaxy

a simple, customisable theme for your apache directory listing
https://oupala.github.io/apaxy/
GNU General Public License v3.0
1.86k stars 256 forks source link

refactor: replace some AddIcon directives by AddIconByType #116

Closed oupala closed 5 years ago

oupala commented 6 years ago

I started to replace some AddIcon directives by AddIconByType.

It seems to work and is a good oppotunity to simplify the .htaccess file.

This work needs to find all used mime-types.

ghost commented 5 years ago

Oh if this works, then this is great! It is a much better idea to assign icons based on file type, rather than file extension.

oupala commented 5 years ago

There are many advantages of using mime type instead of using file extension:

The generic mime type video/* is way shorter than a long list of extensions .asf .asx .avi .flv .mkv .mov .mp4 .mpg .rm .srt .swf .vob .wmv .m4v .f4v .f4p .ogv.

Imagine an mp4 video file uncorrectly renamed to myvideo.mp3, it should be displayed as a video, not as an mp3 audio, as it is a video.

The main drawback is that we can no longer use the touch command to create test files. We now have to get real test files.

oupala commented 5 years ago

Mime types are now named media types at IANA.

The list of media types currently supported by apache can be generated using the following oneliner:

wget -qO- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types | egrep -v ^# | sort
wget -qO- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types | egrep -v ^# | awk '{ for (i=2; i<=NF; i++) {print $i" "$1}}' | sort

For file type without supported media type by apache, we'll have to fall back to the old way (AddIcon instead of AddIconByType).

oupala commented 5 years ago

I have added all useful media type in apaxy. Consequently, it should have added a lot of file extensions to apaxy supported file extension list.

It was a long research to switch from file extension to corresponding media type, then from media type to all supported file extension. But htaccess and documentation should be up to date.