Show More
@@ -6,7 +6,7 | |||||
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 |
|
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 | |
@@ -226,17 +226,8 class hgweb(object): | |||||
226 | try: |
|
226 | try: | |
227 |
|
227 | |||
228 | tmpl = self.templater(req) |
|
228 | tmpl = self.templater(req) | |
229 | try: |
|
|||
230 |
|
|
229 | ctype = tmpl('mimetype', encoding=self.encoding) | |
231 |
|
|
230 | 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']] | |
@@ -291,13 +282,7 class hgweb(object): | |||||
291 | # some functions for the templater |
|
282 | # some functions for the templater | |
292 |
|
283 | |||
293 | def header(**map): |
|
284 | def header(**map): | |
294 |
|
|
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) |
@@ -6,7 +6,7 | |||||
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 | |
@@ -81,17 +81,8 class hgwebdir(object): | |||||
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: |
|
|||
85 |
|
|
84 | ctype = tmpl('mimetype', encoding=util._encoding) | |
86 |
|
|
85 | 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: | |
@@ -255,13 +246,7 class hgwebdir(object): | |||||
255 | def templater(self, req): |
|
246 | def templater(self, req): | |
256 |
|
247 | |||
257 | def header(**map): |
|
248 | def header(**map): | |
258 |
|
|
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) |
General Comments 0
You need to be logged in to leave comments.
Login now