edgewall/trac — pull request #5 by kriegaex (2012-08-20 21:26:11+00:00)
Title: mimeview/api: new config setting [mimeviewer] mime_map_patterns

Purpose: enable Trac to determine MIME types for syntax highlighting not
just simply by file extension, but more powerfully by regex file name
matching. This is done by introducing a new trac.ini parameter
'mime_map_patterns' in section [mimeviewer].

How to test:
- Add this to trac.ini, section [mimeviewer]:
mime_map_patterns = text/x-python:.*_py_.*
- Add a Python source file to your source code repository, but rename
it to something containing '_py_' *without* the defauly '.py'
extension, e.g. 'test_py_file'
- Restart Trac
- Check in a web browser if your new repository file is correctly
highlighted as a Python file

This patch was initially developed for the Freetz [1] project by
Alexander Kriegisch and used there [2] successfully ever since it was
suggested in Ticket #10437 [3] in October 2012.

Freetz usage exampe:
`mime_map_patterns = text/x-kconfig:.*Config.in.*|external.in.*|standard-modules.in`

[1] http://freetz.org
[2] http://freetz.org/browser/trunk/tools/developer/mime_map_patterns.trac.patch
[3] http://trac.edgewall.org/ticket/10437#comment:5