comparison mercurial/hgweb/hgwebdir_mod.py @ 5928:3340aa5a64f7

hgweb: move HTTP content types out of header templates This removes the ability for templates to add custom HTTP headers, which can easily be re-added if someone needs it. Thanks to asak for repeatedly reviewing this patch and helping to iron out the quirks.
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Tue, 22 Jan 2008 10:45:55 +0100
parents d0576d065993
children abe373e16fe6
comparison
equal deleted inserted replaced
5927:b06c56f8fab7 5928:3340aa5a64f7
4 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> 4 # Copyright 2005, 2006 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, mimetools, cStringIO 9 import os
10 from mercurial.i18n import gettext as _ 10 from mercurial.i18n import gettext as _
11 from mercurial import ui, hg, util, templater 11 from mercurial import ui, hg, util, templater
12 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen, \ 12 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen, \
13 get_contact 13 get_contact
14 from hgweb_mod import hgweb 14 from hgweb_mod import hgweb
224 224
225 sort = [("sort_%s" % column, 225 sort = [("sort_%s" % column,
226 "%s%s" % ((not descending and column == sortcolumn) 226 "%s%s" % ((not descending and column == sortcolumn)
227 and "-" or "", column)) 227 and "-" or "", column))
228 for column in sortable] 228 for column in sortable]
229
229 req.write(tmpl("index", entries=entries, subdir=subdir, 230 req.write(tmpl("index", entries=entries, subdir=subdir,
230 sortcolumn=sortcolumn, descending=descending, 231 sortcolumn=sortcolumn, descending=descending,
231 **dict(sort))) 232 **dict(sort)))
232 233
233 def templater(self, req): 234 def templater(self, req):
234 235
235 def header(**map): 236 def header(**map):
236 header_file = cStringIO.StringIO( 237 ctype = tmpl('mimetype', encoding=util._encoding)
237 ''.join(tmpl("header", encoding=util._encoding, **map))) 238 req.httphdr(templater.stringify(ctype))
238 msg = mimetools.Message(header_file, 0) 239 yield tmpl('header', encoding=util._encoding, **map)
239 req.header(msg.items())
240 yield header_file.read()
241 240
242 def footer(**map): 241 def footer(**map):
243 yield tmpl("footer", **map) 242 yield tmpl("footer", **map)
244 243
245 def motd(**map): 244 def motd(**map):