comparison mercurial/hgweb/hgwebdir_mod.py @ 2514:419c42223bee

Really fix http headers for web UI and issue 254. This also arranges for static content to allow a keepalive connection.
author Eric Hopper <hopper@omnifarious.org>
date Tue, 27 Jun 2006 09:33:12 -0700
parents 6350b01d173f
children b8ccf6386db7
comparison
equal deleted inserted replaced
2513:f22e3e8fd457 2514:419c42223bee
6 # This software may be used and distributed according to the terms 6 # This software may be used and distributed according to the terms
7 # of the GNU General Public License, incorporated herein by reference. 7 # of the GNU General Public License, incorporated herein by reference.
8 8
9 import os 9 import os
10 from mercurial.demandload import demandload 10 from mercurial.demandload import demandload
11 demandload(globals(), "ConfigParser") 11 demandload(globals(), "ConfigParser mimetools cStringIO")
12 demandload(globals(), "mercurial:ui,hg,util,templater") 12 demandload(globals(), "mercurial:ui,hg,util,templater")
13 demandload(globals(), "mercurial.hgweb.hgweb_mod:hgweb") 13 demandload(globals(), "mercurial.hgweb.hgweb_mod:hgweb")
14 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") 14 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile")
15 from mercurial.i18n import gettext as _ 15 from mercurial.i18n import gettext as _
16 16
46 self.repos.append((name.lstrip(os.sep), repo)) 46 self.repos.append((name.lstrip(os.sep), repo))
47 self.repos.sort() 47 self.repos.sort()
48 48
49 def run(self, req): 49 def run(self, req):
50 def header(**map): 50 def header(**map):
51 yield tmpl("header", **map) 51 header_file = cStringIO.StringIO(''.join(tmpl("header", **map)))
52 msg = mimetools.Message(header_file, 0)
53 req.header(msg.items())
54 yield header_file.read()
52 55
53 def footer(**map): 56 def footer(**map):
54 yield tmpl("footer", motd=self.motd, **map) 57 yield tmpl("footer", motd=self.motd, **map)
55 58
56 m = os.path.join(templater.templatepath(), "map") 59 m = os.path.join(templater.templatepath(), "map")
130 req.write(tmpl("notfound", repo=virtual)) 133 req.write(tmpl("notfound", repo=virtual))
131 else: 134 else:
132 if req.form.has_key('static'): 135 if req.form.has_key('static'):
133 static = os.path.join(templater.templatepath(), "static") 136 static = os.path.join(templater.templatepath(), "static")
134 fname = req.form['static'][0] 137 fname = req.form['static'][0]
135 req.write(staticfile(static, fname) 138 req.write(staticfile(static, fname, req)
136 or tmpl("error", error="%r not found" % fname)) 139 or tmpl("error", error="%r not found" % fname))
137 else: 140 else:
138 sortable = ["name", "description", "contact", "lastchange"] 141 sortable = ["name", "description", "contact", "lastchange"]
139 sortcolumn, descending = self.repos_sorted 142 sortcolumn, descending = self.repos_sorted
140 if req.form.has_key('sort'): 143 if req.form.has_key('sort'):