#2105 closed enhancement (fixed)
identify the mimetype
Reported by: | Otavio Salvador | Owned by: | Christian Boos |
---|---|---|---|
Priority: | high | Milestone: | 0.10 |
Component: | general | Version: | devel |
Severity: | minor | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
Would be great if trac identify the mime type also by reading the file header.
For example, debian/rules files has it's first line set to #!/usr/bin/make -f
and is safe to use Makefile highlight for it. This apply too to shell scripts and others.
Thanks in advance,
Attachments (2)
Change History (11)
comment:1 by , 19 years ago
Milestone: | 0.9 |
---|---|
Owner: | changed from | to
Severity: | normal → minor |
Version: | 0.8.4 → devel |
by , 19 years ago
Attachment: | mimeview-refactoring.patch added |
---|
Implementation of the feature, which required a bit of refactoring (mainly, get the content first, before it can be passed on to Mimeview.get_mimetype()
)
comment:2 by , 19 years ago
Description: | modified (diff) |
---|---|
Milestone: | → 1.0 |
Status: | new → assigned |
comment:3 by , 19 years ago
In the previous comment, by the above refactoring, I was referring to the attachment:mimeview-refactoring.patch
That was not clear in the Trac-Ticket notification mail, since it displayed also my formatting change in the description…
comment:4 by , 19 years ago
Cboos before you start trying to build a mime inspection method into Trac there is already a Python module made to work similarly to the Unix "file" command: http://www.demonseed.net/~jp/code/magic.py
Unfortunately the file has a copyright statement, but no licensing terms, so I'm contacting the author to try to get an acceptable license for it.
There is another similar module listed in the Cheese Shop, but it's licensed under the GPL, so it's not usable for Trac now: http://www.python.org/pypi/pymagic/0.1
I know it's also possible to inspect mime types through the Python bindings to the Gnome libraries, which is not as portable, but could be used in combination with the magic module mentioned above.
I'll let you know what I hear about licencing on that module.
comment:5 by , 19 years ago
The above patch is not doing a mime inspection of the file, it only takes into account the shebang or the Emacs mode. But the refactoring done at that occasion would be benefitial to any other, more complex, auto-detection method.
by , 19 years ago
Attachment: | mimeview-inspect-r2500.patch added |
---|
Refactoring of the way the mimetype is associated to the file: This is now done after the content (or the first chunk of it) is seen, enabling all sorts of detection schemes (a simple shebang detection is done for now, more can be added later, why not in a "pluggable" way)
comment:6 by , 19 years ago
Priority: | normal → high |
---|
Updated version of the patch added (attachment:mime-inspect-r2500.patch)
Please review.
comment:7 by , 19 years ago
Keywords: | review added |
---|
The attachment's link was actually attachment:mimeview-inspect-r2500.patch
comment:8 by , 19 years ago
Keywords: | review removed |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Patch applied in r2653.
comment:9 by , 19 years ago
Milestone: | 1.0 → 0.10 |
---|
Additional requirement: support Emacs mode specification, e.g.