##// END OF EJS Templates
hgweb: move HTTP content types out of header templates...
Dirkjan Ochtman -
r5928:3340aa5a default
parent child Browse files
Show More
@@ -6,7 +6,7 b''
6 6 # This software may be used and distributed according to the terms
7 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 10 from mercurial.node import *
11 11 from mercurial import mdiff, ui, hg, util, archival, patch, hook
12 12 from mercurial import revlog, templater
@@ -253,11 +253,9 b' class hgweb(object):'
253 253 # some functions for the templater
254 254
255 255 def header(**map):
256 header_file = cStringIO.StringIO(
257 ''.join(tmpl("header", encoding=self.encoding, **map)))
258 msg = mimetools.Message(header_file, 0)
259 req.header(msg.items())
260 yield header_file.read()
256 ctype = tmpl('mimetype', encoding=self.encoding)
257 req.httphdr(templater.stringify(ctype))
258 yield tmpl('header', encoding=self.encoding, **map)
261 259
262 260 def footer(**map):
263 261 yield tmpl("footer", **map)
@@ -6,7 +6,7 b''
6 6 # This software may be used and distributed according to the terms
7 7 # of the GNU General Public License, incorporated herein by reference.
8 8
9 import os, mimetools, cStringIO
9 import os
10 10 from mercurial.i18n import gettext as _
11 11 from mercurial import ui, hg, util, templater
12 12 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen, \
@@ -226,6 +226,7 b' class hgwebdir(object):'
226 226 "%s%s" % ((not descending and column == sortcolumn)
227 227 and "-" or "", column))
228 228 for column in sortable]
229
229 230 req.write(tmpl("index", entries=entries, subdir=subdir,
230 231 sortcolumn=sortcolumn, descending=descending,
231 232 **dict(sort)))
@@ -233,11 +234,9 b' class hgwebdir(object):'
233 234 def templater(self, req):
234 235
235 236 def header(**map):
236 header_file = cStringIO.StringIO(
237 ''.join(tmpl("header", encoding=util._encoding, **map)))
238 msg = mimetools.Message(header_file, 0)
239 req.header(msg.items())
240 yield header_file.read()
237 ctype = tmpl('mimetype', encoding=util._encoding)
238 req.httphdr(templater.stringify(ctype))
239 yield tmpl('header', encoding=util._encoding, **map)
241 240
242 241 def footer(**map):
243 242 yield tmpl("footer", **map)
@@ -1,4 +1,2 b''
1 Content-type: application/atom+xml; charset={encoding}
2
3 1 <?xml version="1.0" encoding="{encoding}"?>
4 2 <feed xmlns="http://www.w3.org/2005/Atom"> No newline at end of file
@@ -1,5 +1,6 b''
1 1 default = 'changelog'
2 2 feedupdated = '<updated>#date|rfc3339date#</updated>'
3 mimetype = 'application/atom+xml; charset={encoding}'
3 4 header = header.tmpl
4 5 changelog = changelog.tmpl
5 6 changelogentry = changelogentry.tmpl
@@ -1,5 +1,3 b''
1 Content-type: text/html; charset={encoding}
2
3 1 <?xml version="1.0" encoding="{encoding}"?>
4 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
@@ -1,4 +1,5 b''
1 1 default = 'summary'
2 mimetype = 'text/html; charset={encoding}'
2 3 header = header.tmpl
3 4 footer = footer.tmpl
4 5 search = search.tmpl
@@ -1,5 +1,3 b''
1 Content-type: text/html; charset={encoding}
2
3 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 2 <html>
5 3 <head>
@@ -1,4 +1,5 b''
1 1 default = 'shortlog'
2 mimetype = 'text/html; charset={encoding}'
2 3 header = header.tmpl
3 4 footer = footer.tmpl
4 5 search = search.tmpl
@@ -1,5 +1,3 b''
1 Content-type: text/html
2
3 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 2 <html>
5 3 <head>
@@ -1,4 +1,5 b''
1 1 default = 'changelog'
2 mimetype = 'text/html'
2 3 header = header.tmpl
3 4 footer = footer.tmpl
4 5 search = search.tmpl
@@ -1,4 +1,5 b''
1 header = header.tmpl
1 mimetype = 'text/plain; charset={encoding}'
2 header = ''
2 3 footer = ''
3 4 changeset = changeset.tmpl
4 5 difflineplus = '#line#'
@@ -1,5 +1,3 b''
1 Content-type: text/xml; charset={encoding}
2
3 1 <?xml version="1.0" encoding="{encoding}"?>
4 2 <rss version="2.0">
5 3 <channel>
@@ -1,4 +1,5 b''
1 1 default = 'changelog'
2 mimetype = 'text/xml; charset={encoding}'
2 3 header = header.tmpl
3 4 changelog = changelog.tmpl
4 5 changelogentry = changelogentry.tmpl
@@ -7,7 +7,7 b' summary: test'
7 7 ---- HEADERS
8 8 200 Script output follows
9 9 ---- DATA
10 [('content-type', 'application/atom+xml; charset=ascii')]
10 [('Content-type', 'application/atom+xml; charset=ascii')]
11 11 <?xml version="1.0" encoding="ascii"?>
12 12 <feed xmlns="http://www.w3.org/2005/Atom">
13 13 <!-- Changelog -->
@@ -41,7 +41,7 b' 200 Script output follows'
41 41 ---- HEADERS
42 42 200 Script output follows
43 43 ---- DATA
44 [('content-type', 'text/plain; charset=ascii')]
44 [('Content-type', 'text/plain; charset=ascii')]
45 45
46 46 -rw-r--r-- 4 bar
47 47
@@ -52,7 +52,7 b' 200 Script output follows'
52 52 ---- HEADERS
53 53 200 Script output follows
54 54 ---- DATA
55 [('content-type', 'text/plain; charset=ascii')]
55 [('Content-type', 'text/plain; charset=ascii')]
56 56
57 57 /repo/
58 58
@@ -62,7 +62,7 b' 200 Script output follows'
62 62 ---- HEADERS
63 63 200 Script output follows
64 64 ---- DATA
65 [('content-type', 'text/plain; charset=ascii')]
65 [('Content-type', 'text/plain; charset=ascii')]
66 66
67 67 -rw-r--r-- 4 bar
68 68
@@ -7,6 +7,6 b' summary: test'
7 7 ---- HEADERS
8 8 200 Script output follows
9 9 ---- DATA
10 [('content-type', 'text/html; charset=ascii')]
10 [('Content-type', 'text/html; charset=ascii')]
11 11 ---- ERRORS
12 12
1 NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now