comparison mercurial/hgweb/hgweb_mod.py @ 6391:a1007f7b9b7b

Backed out changeset d2bb66a8a435 (temporary template compatibility)
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Mon, 24 Mar 2008 18:18:39 +0100
parents d2bb66a8a435
children 2540521dc7c1
comparison
equal deleted inserted replaced
6390:67784cb38d58 6391:a1007f7b9b7b
4 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com> 4 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
5 # 5 #
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, mimetypes, re, mimetools, cStringIO 9 import os, mimetypes, re
10 from mercurial.node import hex, nullid, short 10 from mercurial.node import hex, nullid, short
11 from mercurial.repo import RepoError 11 from mercurial.repo import RepoError
12 from mercurial import mdiff, ui, hg, util, archival, patch, hook 12 from mercurial import mdiff, ui, hg, util, archival, patch, hook
13 from mercurial import revlog, templater, templatefilters, changegroup 13 from mercurial import revlog, templater, templatefilters, changegroup
14 from common import get_mtime, style_map, paritygen, countgen, get_contact 14 from common import get_mtime, style_map, paritygen, countgen, get_contact
224 # process the web interface request 224 # process the web interface request
225 225
226 try: 226 try:
227 227
228 tmpl = self.templater(req) 228 tmpl = self.templater(req)
229 try: 229 ctype = tmpl('mimetype', encoding=self.encoding)
230 ctype = tmpl('mimetype', encoding=self.encoding) 230 ctype = templater.stringify(ctype)
231 ctype = templater.stringify(ctype)
232 except KeyError:
233 # old templates with inline HTTP headers?
234 if 'mimetype' in tmpl:
235 raise
236 header = tmpl('header', encoding=self.encoding)
237 header_file = cStringIO.StringIO(templater.stringify(header))
238 msg = mimetools.Message(header_file, 0)
239 ctype = msg['content-type']
240 231
241 if cmd == '': 232 if cmd == '':
242 req.form['cmd'] = [tmpl.cache['default']] 233 req.form['cmd'] = [tmpl.cache['default']]
243 cmd = req.form['cmd'][0] 234 cmd = req.form['cmd'][0]
244 235
289 staticurl += '/' 280 staticurl += '/'
290 281
291 # some functions for the templater 282 # some functions for the templater
292 283
293 def header(**map): 284 def header(**map):
294 header = tmpl('header', encoding=self.encoding, **map) 285 yield tmpl('header', encoding=self.encoding, **map)
295 if 'mimetype' not in tmpl:
296 # old template with inline HTTP headers
297 header_file = cStringIO.StringIO(templater.stringify(header))
298 msg = mimetools.Message(header_file, 0)
299 header = header_file.read()
300 yield header
301 286
302 def footer(**map): 287 def footer(**map):
303 yield tmpl("footer", **map) 288 yield tmpl("footer", **map)
304 289
305 def motd(**map): 290 def motd(**map):