On Wednesday 21 December 2005 16:04, Alberto Bertogli wrote: > On Tue, Dec 20, 2005 at 02:44:28PM +0100, Gaetan Lehmann wrote: > > Is it possible to display an image ? > > When I click on "plain" for an image, I see a PNG appear in the window, > > and some garbage below :-( > > wget tell me the downloaded file is a "text/plain". It surely explain the > > problem > > Yes, but I can't really tell what type of file is it, much less > identifying it as an image. > > What I can do is check if darcs sees the file as a binary one (it matches > regular expressions at /_darcs/prefs/binaries), and if so offer a download > instead of displaying it as text/plain, which is a better behaviour, and > should make wget happier. > > I've applied a patch to do this, it's in the current repository. Is this > useful to you? >
Sure, that's a lot better ! But I should be possible to do better, with the mimetypes module. A small patch is attached Thanks a lot :-) Gaetan
New patches:
[enhance mime type for binary files
[EMAIL PROTECTED] {
hunk ./darcsweb.cgi 23
+import mimetypes
hunk ./darcsweb.cgi 400
- print "Content-type: application/octet-stream"
+ if fname :
+ (mime, enc) = mimetypes.guess_type(fname)
+ else :
+ mime = None
+ if mime :
+ print "Content-type: %s" % mime
+ else :
+ print "Content-type: application/octet-stream"
}
Context:
[Indentation and comment changes to multidir_deep.
Alberto Bertogli <[EMAIL PROTECTED]>**20051221142946]
[Add deep recursion option to multidir configuration
[EMAIL PROTECTED]
[Indentation changes to the uncompression patch.
Alberto Bertogli <[EMAIL PROTECTED]>**20051221134750]
[show raw for noncompressed patches
[EMAIL PROTECTED]
[Identify binary files in plainblob.
Alberto Bertogli <[EMAIL PROTECTED]>**20051221150033
If we want to do a plainblob of a binary file, it's better to offer a proper
download than to display it as text/plain.
This patch identifies binary files (looking at darcs' information) and offers
them for download with the proper name.
]
[TAG 0.13
Alberto Bertogli <[EMAIL PROTECTED]>**20051219174202]
Patch bundle hash:
a82be3e2af0e88bb437016582fb6ff2188cd8dd6
pgpLf63h5ThYN.pgp
Description: PGP signature
_______________________________________________ darcs-users mailing list [email protected] http://www.abridgegame.org/mailman/listinfo/darcs-users
