Mercurial > hg-stable
changeset 3781:713e35dcc321
hgweb: report detected character set
Add comments on overriding charset to CGI scripts
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 03 Dec 2006 18:47:05 -0600 |
parents | d0a48313b0f6 |
children | a8725ae15c7c |
files | hgweb.cgi hgwebdir.cgi mercurial/hgweb/hgweb_mod.py templates/gitweb/header.tmpl templates/header.tmpl templates/raw/header.tmpl |
diffstat | 6 files changed, 21 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/hgweb.cgi Sun Dec 03 17:28:58 2006 -0600 +++ b/hgweb.cgi Sun Dec 03 18:47:05 2006 -0600 @@ -10,6 +10,13 @@ from mercurial.hgweb.request import wsgiapplication import mercurial.hgweb.wsgicgi as wsgicgi +# If you'd like to serve pages with UTF-8 instead of your default +# locale charset, you can do so by uncommenting the following lines. +# Note that this will cause your .hgrc files to be interpreted in +# UTF-8 and all your repo files to be displayed using UTF-8. +# +# os.environ["HGENCODING"] = "UTF-8" + def make_web_app(): return hgweb("/path/to/repo", "repository name")
--- a/hgwebdir.cgi Sun Dec 03 17:28:58 2006 -0600 +++ b/hgwebdir.cgi Sun Dec 03 18:47:05 2006 -0600 @@ -29,6 +29,13 @@ # Alternatively you can pass a list of ('virtual/path', '/real/path') tuples # or use a dictionary with entries like 'virtual/path': '/real/path' +# If you'd like to serve pages with UTF-8 instead of your default +# locale charset, you can do so by uncommenting the following lines. +# Note that this will cause your .hgrc files to be interpreted in +# UTF-8 and all your repo files to be displayed using UTF-8. +# +# os.environ["HGENCODING"] = "UTF-8" + def make_web_app(): return hgwebdir("hgweb.config")
--- a/mercurial/hgweb/hgweb_mod.py Sun Dec 03 17:28:58 2006 -0600 +++ b/mercurial/hgweb/hgweb_mod.py Sun Dec 03 18:47:05 2006 -0600 @@ -654,7 +654,8 @@ def run_wsgi(self, req): def header(**map): - header_file = cStringIO.StringIO(''.join(self.t("header", **map))) + header_file = cStringIO.StringIO( + ''.join(self.t("header", encoding = util._encoding, **map))) msg = mimetools.Message(header_file, 0) req.header(msg.items()) yield header_file.read()
--- a/templates/gitweb/header.tmpl Sun Dec 03 17:28:58 2006 -0600 +++ b/templates/gitweb/header.tmpl Sun Dec 03 18:47:05 2006 -0600 @@ -1,11 +1,10 @@ -Content-type: text/html +Content-type: text/html; charset={encoding} -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="{encoding}"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <link rel="icon" href="{url}static/hgicon.png" type="image/png"> -<meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta name="robots" content="index, nofollow"/> <link rel="stylesheet" href="{url}static/style-gitweb.css" type="text/css" />