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): |