Mercurial > hg
annotate hgweb.cgi @ 5846:02884e56c217
New extension to support problematic MBCS on Windows.
The aim of this extension is to clear the problem related to having
0x5c in 2nd byte of encoded bytes. So this extension is usefull for:
* Japanese Windows user shift_jis encoding.
* Chinese Windows user using big5 encoding.
To use this extension, simply enable it without any customization.
Note that some important python built-in functions and mercurial
functions are altered for this extension to convert argument if need
to handle MBCS.
author | Shun-ichi GOTO <shunichi.goto@gmail.com> |
---|---|
date | Wed, 09 Jan 2008 22:41:30 +0900 |
parents | d74fc8dec2b4 |
children | b913d3aacddc |
rev | line source |
---|---|
202 | 1 #!/usr/bin/env python |
159 | 2 # |
3 # An example CGI script to use hgweb, edit as necessary | |
4 | |
5244
79279b5583c6
cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5197
diff
changeset
|
5 # adjust python path if not a system-wide install: |
79279b5583c6
cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5197
diff
changeset
|
6 #import sys |
79279b5583c6
cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5197
diff
changeset
|
7 #sys.path.insert(0, "/path/to/python/lib") |
79279b5583c6
cgi: sys.path.insert should be before importing mercurial
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
5197
diff
changeset
|
8 |
5197
55860a45bbf2
Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3868
diff
changeset
|
9 # enable importing on demand to reduce startup time |
55860a45bbf2
Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3868
diff
changeset
|
10 from mercurial import demandimport; demandimport.enable() |
55860a45bbf2
Enable demandimport only in scripts, not in importable modules (issue605)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3868
diff
changeset
|
11 |
3868
6033d9f28052
hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3781
diff
changeset
|
12 # send python tracebacks to the browser if an error occurs: |
6033d9f28052
hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3781
diff
changeset
|
13 import cgitb |
391
5f65a108a559
hgweb: pull cgitb into CGI script example, where it can easily be disabled
mpm@selenic.com
parents:
202
diff
changeset
|
14 cgitb.enable() |
5f65a108a559
hgweb: pull cgitb into CGI script example, where it can easily be disabled
mpm@selenic.com
parents:
202
diff
changeset
|
15 |
3781
713e35dcc321
hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents:
2506
diff
changeset
|
16 # If you'd like to serve pages with UTF-8 instead of your default |
713e35dcc321
hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents:
2506
diff
changeset
|
17 # locale charset, you can do so by uncommenting the following lines. |
713e35dcc321
hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents:
2506
diff
changeset
|
18 # Note that this will cause your .hgrc files to be interpreted in |
713e35dcc321
hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents:
2506
diff
changeset
|
19 # UTF-8 and all your repo files to be displayed using UTF-8. |
713e35dcc321
hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents:
2506
diff
changeset
|
20 # |
3868
6033d9f28052
hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3781
diff
changeset
|
21 #import os |
6033d9f28052
hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3781
diff
changeset
|
22 #os.environ["HGENCODING"] = "UTF-8" |
6033d9f28052
hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3781
diff
changeset
|
23 |
6033d9f28052
hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3781
diff
changeset
|
24 from mercurial.hgweb.hgweb_mod import hgweb |
6033d9f28052
hgweb.cgi and hgwebdir.cgi fixes/cleanups for user configurable parts:
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3781
diff
changeset
|
25 import mercurial.hgweb.wsgicgi as wsgicgi |
3781
713e35dcc321
hgweb: report detected character set
Matt Mackall <mpm@selenic.com>
parents:
2506
diff
changeset
|
26 |
5566
d74fc8dec2b4
Less indirection in the WSGI web interface. This simplifies some code, and makes it more compliant with WSGI.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5244
diff
changeset
|
27 application = hgweb("/path/to/repo", "repository name") |
d74fc8dec2b4
Less indirection in the WSGI web interface. This simplifies some code, and makes it more compliant with WSGI.
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
5244
diff
changeset
|
28 wsgicgi.launch(application) |