##// 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 # 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, mimetools, cStringIO
9 import os, mimetypes, re
10 from mercurial.node import *
10 from mercurial.node import *
11 from mercurial import mdiff, ui, hg, util, archival, patch, hook
11 from mercurial import mdiff, ui, hg, util, archival, patch, hook
12 from mercurial import revlog, templater
12 from mercurial import revlog, templater
@@ -253,11 +253,9 b' class hgweb(object):'
253 # some functions for the templater
253 # some functions for the templater
254
254
255 def header(**map):
255 def header(**map):
256 header_file = cStringIO.StringIO(
256 ctype = tmpl('mimetype', encoding=self.encoding)
257 ''.join(tmpl("header", encoding=self.encoding, **map)))
257 req.httphdr(templater.stringify(ctype))
258 msg = mimetools.Message(header_file, 0)
258 yield tmpl('header', encoding=self.encoding, **map)
259 req.header(msg.items())
260 yield header_file.read()
261
259
262 def footer(**map):
260 def footer(**map):
263 yield tmpl("footer", **map)
261 yield tmpl("footer", **map)
@@ -6,7 +6,7 b''
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, \
@@ -226,6 +226,7 b' class hgwebdir(object):'
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)))
@@ -233,11 +234,9 b' class hgwebdir(object):'
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)
@@ -1,4 +1,2 b''
1 Content-type: application/atom+xml; charset={encoding}
2
3 <?xml version="1.0" encoding="{encoding}"?>
1 <?xml version="1.0" encoding="{encoding}"?>
4 <feed xmlns="http://www.w3.org/2005/Atom"> No newline at end of file
2 <feed xmlns="http://www.w3.org/2005/Atom">
@@ -1,5 +1,6 b''
1 default = 'changelog'
1 default = 'changelog'
2 feedupdated = '<updated>#date|rfc3339date#</updated>'
2 feedupdated = '<updated>#date|rfc3339date#</updated>'
3 mimetype = 'application/atom+xml; charset={encoding}'
3 header = header.tmpl
4 header = header.tmpl
4 changelog = changelog.tmpl
5 changelog = changelog.tmpl
5 changelogentry = changelogentry.tmpl
6 changelogentry = changelogentry.tmpl
@@ -1,5 +1,3 b''
1 Content-type: text/html; charset={encoding}
2
3 <?xml version="1.0" encoding="{encoding}"?>
1 <?xml version="1.0" encoding="{encoding}"?>
4 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
@@ -1,4 +1,5 b''
1 default = 'summary'
1 default = 'summary'
2 mimetype = 'text/html; charset={encoding}'
2 header = header.tmpl
3 header = header.tmpl
3 footer = footer.tmpl
4 footer = footer.tmpl
4 search = search.tmpl
5 search = search.tmpl
@@ -1,5 +1,3 b''
1 Content-type: text/html; charset={encoding}
2
3 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html>
2 <html>
5 <head>
3 <head>
@@ -1,4 +1,5 b''
1 default = 'shortlog'
1 default = 'shortlog'
2 mimetype = 'text/html; charset={encoding}'
2 header = header.tmpl
3 header = header.tmpl
3 footer = footer.tmpl
4 footer = footer.tmpl
4 search = search.tmpl
5 search = search.tmpl
@@ -1,5 +1,3 b''
1 Content-type: text/html
2
3 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <html>
2 <html>
5 <head>
3 <head>
@@ -1,4 +1,5 b''
1 default = 'changelog'
1 default = 'changelog'
2 mimetype = 'text/html'
2 header = header.tmpl
3 header = header.tmpl
3 footer = footer.tmpl
4 footer = footer.tmpl
4 search = search.tmpl
5 search = search.tmpl
@@ -1,4 +1,5 b''
1 header = header.tmpl
1 mimetype = 'text/plain; charset={encoding}'
2 header = ''
2 footer = ''
3 footer = ''
3 changeset = changeset.tmpl
4 changeset = changeset.tmpl
4 difflineplus = '#line#'
5 difflineplus = '#line#'
@@ -1,5 +1,3 b''
1 Content-type: text/xml; charset={encoding}
2
3 <?xml version="1.0" encoding="{encoding}"?>
1 <?xml version="1.0" encoding="{encoding}"?>
4 <rss version="2.0">
2 <rss version="2.0">
5 <channel>
3 <channel>
@@ -1,4 +1,5 b''
1 default = 'changelog'
1 default = 'changelog'
2 mimetype = 'text/xml; charset={encoding}'
2 header = header.tmpl
3 header = header.tmpl
3 changelog = changelog.tmpl
4 changelog = changelog.tmpl
4 changelogentry = changelogentry.tmpl
5 changelogentry = changelogentry.tmpl
@@ -7,7 +7,7 b' summary: test'
7 ---- HEADERS
7 ---- HEADERS
8 200 Script output follows
8 200 Script output follows
9 ---- DATA
9 ---- DATA
10 [('content-type', 'application/atom+xml; charset=ascii')]
10 [('Content-type', 'application/atom+xml; charset=ascii')]
11 <?xml version="1.0" encoding="ascii"?>
11 <?xml version="1.0" encoding="ascii"?>
12 <feed xmlns="http://www.w3.org/2005/Atom">
12 <feed xmlns="http://www.w3.org/2005/Atom">
13 <!-- Changelog -->
13 <!-- Changelog -->
@@ -41,7 +41,7 b' 200 Script output follows'
41 ---- HEADERS
41 ---- HEADERS
42 200 Script output follows
42 200 Script output follows
43 ---- DATA
43 ---- DATA
44 [('content-type', 'text/plain; charset=ascii')]
44 [('Content-type', 'text/plain; charset=ascii')]
45
45
46 -rw-r--r-- 4 bar
46 -rw-r--r-- 4 bar
47
47
@@ -52,7 +52,7 b' 200 Script output follows'
52 ---- HEADERS
52 ---- HEADERS
53 200 Script output follows
53 200 Script output follows
54 ---- DATA
54 ---- DATA
55 [('content-type', 'text/plain; charset=ascii')]
55 [('Content-type', 'text/plain; charset=ascii')]
56
56
57 /repo/
57 /repo/
58
58
@@ -62,7 +62,7 b' 200 Script output follows'
62 ---- HEADERS
62 ---- HEADERS
63 200 Script output follows
63 200 Script output follows
64 ---- DATA
64 ---- DATA
65 [('content-type', 'text/plain; charset=ascii')]
65 [('Content-type', 'text/plain; charset=ascii')]
66
66
67 -rw-r--r-- 4 bar
67 -rw-r--r-- 4 bar
68
68
@@ -7,6 +7,6 b' summary: test'
7 ---- HEADERS
7 ---- HEADERS
8 200 Script output follows
8 200 Script output follows
9 ---- DATA
9 ---- DATA
10 [('content-type', 'text/html; charset=ascii')]
10 [('Content-type', 'text/html; charset=ascii')]
11 ---- ERRORS
11 ---- ERRORS
12
12
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now