Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgwebdir_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 | a63aed912e54 |
comparison
equal
deleted
inserted
replaced
6390:67784cb38d58 | 6391:a1007f7b9b7b |
---|---|
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.repo import RepoError | 11 from mercurial.repo import RepoError |
12 from mercurial import ui, hg, util, templater, templatefilters | 12 from mercurial import ui, hg, util, templater, templatefilters |
13 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen,\ | 13 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen,\ |
14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR | 14 get_contact, HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR |
79 try: | 79 try: |
80 try: | 80 try: |
81 | 81 |
82 virtual = req.env.get("PATH_INFO", "").strip('/') | 82 virtual = req.env.get("PATH_INFO", "").strip('/') |
83 tmpl = self.templater(req) | 83 tmpl = self.templater(req) |
84 try: | 84 ctype = tmpl('mimetype', encoding=util._encoding) |
85 ctype = tmpl('mimetype', encoding=util._encoding) | 85 ctype = templater.stringify(ctype) |
86 ctype = templater.stringify(ctype) | |
87 except KeyError: | |
88 # old templates with inline HTTP headers? | |
89 if 'mimetype' in tmpl: | |
90 raise | |
91 header = tmpl('header', encoding=util._encoding) | |
92 header_file = cStringIO.StringIO(templater.stringify(header)) | |
93 msg = mimetools.Message(header_file, 0) | |
94 ctype = msg['content-type'] | |
95 | 86 |
96 # a static file | 87 # a static file |
97 if virtual.startswith('static/') or 'static' in req.form: | 88 if virtual.startswith('static/') or 'static' in req.form: |
98 static = os.path.join(templater.templatepath(), 'static') | 89 static = os.path.join(templater.templatepath(), 'static') |
99 if virtual.startswith('static/'): | 90 if virtual.startswith('static/'): |
253 **dict(sort)) | 244 **dict(sort)) |
254 | 245 |
255 def templater(self, req): | 246 def templater(self, req): |
256 | 247 |
257 def header(**map): | 248 def header(**map): |
258 header = tmpl('header', encoding=util._encoding, **map) | 249 yield tmpl('header', encoding=util._encoding, **map) |
259 if 'mimetype' not in tmpl: | |
260 # old template with inline HTTP headers | |
261 header_file = cStringIO.StringIO(templater.stringify(header)) | |
262 msg = mimetools.Message(header_file, 0) | |
263 header = header_file.read() | |
264 yield header | |
265 | 250 |
266 def footer(**map): | 251 def footer(**map): |
267 yield tmpl("footer", **map) | 252 yield tmpl("footer", **map) |
268 | 253 |
269 def motd(**map): | 254 def motd(**map): |