Fix raw files in the web UI.
authorEric Hopper <hopper@omnifarious.org>
Thu, 29 Jun 2006 18:34:26 -0700
changeset 2534 d5a3cc6520d5
parent 2533 589474a1dc36
child 2535 b8ccf6386db7
Fix raw files in the web UI.
mercurial/hgweb/hgweb_mod.py
templates/map-raw
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jun 29 18:31:17 2006 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jun 29 18:34:26 2006 -0700
@@ -657,6 +657,12 @@
             req.header(msg.items())
             yield header_file.read()
 
+        def rawfileheader(**map):
+            req.header([('Content-type', map['mimetype']),
+                        ('Content-disposition', 'filename=%s' % map['file']),
+                        ('Content-length', str(len(map['raw'])))])
+            yield ''
+
         def footer(**map):
             yield self.t("footer",
                          motd=self.repo.ui.config("web", "motd", ""),
@@ -714,6 +720,7 @@
                                                "repo": self.reponame,
                                                "header": header,
                                                "footer": footer,
+                                               "rawfileheader": rawfileheader,
                                                })
 
         if not req.form.has_key('cmd'):
--- a/templates/map-raw	Thu Jun 29 18:31:17 2006 -0700
+++ b/templates/map-raw	Thu Jun 29 18:34:26 2006 -0700
@@ -8,7 +8,7 @@
 changesetparent = '# parent: #node#'
 changesetchild = '# child: #node#'
 filenodelink = ''
-filerevision = 'Content-Type: #mimetype#\nContent-Disposition: filename=#file#\n\n#raw#'
+filerevision = '#rawfileheader##raw#'
 fileline = '#line#'
 diffblock = '#lines#'
 filediff = filediff-raw.tmpl