Show More
@@ -110,6 +110,24 b' ui::' | |||||
110 | verbose;; |
|
110 | verbose;; | |
111 | Increase the amount of output printed. True or False. Default is False. |
|
111 | Increase the amount of output printed. True or False. Default is False. | |
112 |
|
112 | |||
|
113 | web:: | |||
|
114 | Web interface configuration. | |||
|
115 | name;; | |||
|
116 | Repository name to use in the web interface. Default is current | |||
|
117 | working directory. | |||
|
118 | address;; | |||
|
119 | Interface address to bind to. Default is all. | |||
|
120 | port;; | |||
|
121 | Port to listen on. Default is 8000. | |||
|
122 | ipv6;; | |||
|
123 | Whether to use IPv6. Default is false. | |||
|
124 | accesslog;; | |||
|
125 | Where to output the access log. Default is stdout. | |||
|
126 | errorlog;; | |||
|
127 | Where to output the error log. Default is stderr. | |||
|
128 | templates;; | |||
|
129 | Where to find the HTML templates. Default is install path. | |||
|
130 | ||||
113 | AUTHOR |
|
131 | AUTHOR | |
114 | ------ |
|
132 | ------ | |
115 | Bryan O'Sullivan <bos@serpentine.com>. |
|
133 | Bryan O'Sullivan <bos@serpentine.com>. |
@@ -1087,16 +1087,9 b' def serve(ui, repo, **opts):' | |||||
1087 | r = repo.addchangegroup(fin) |
|
1087 | r = repo.addchangegroup(fin) | |
1088 | respond("") |
|
1088 | respond("") | |
1089 |
|
1089 | |||
1090 | def openlog(opt, default): |
|
|||
1091 | if opts[opt] and opts[opt] != '-': |
|
|||
1092 | return open(opts[opt], 'w') |
|
|||
1093 | else: |
|
|||
1094 | return default |
|
|||
1095 |
|
||||
1096 | httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"], |
|
1090 | httpd = hgweb.create_server(repo.root, opts["name"], opts["templates"], | |
1097 | opts["address"], opts["port"], opts["ipv6"], |
|
1091 | opts["address"], opts["port"], opts["ipv6"], | |
1098 |
op |
|
1092 | opts['accesslog'], opts['errorlog']) | |
1099 | openlog('errorlog', sys.stderr)) |
|
|||
1100 | if ui.verbose: |
|
1093 | if ui.verbose: | |
1101 | addr, port = httpd.socket.getsockname() |
|
1094 | addr, port = httpd.socket.getsockname() | |
1102 | if addr == '0.0.0.0': |
|
1095 | if addr == '0.0.0.0': | |
@@ -1368,9 +1361,9 b' table = {' | |||||
1368 | (serve, |
|
1361 | (serve, | |
1369 | [('A', 'accesslog', '', 'access log file'), |
|
1362 | [('A', 'accesslog', '', 'access log file'), | |
1370 | ('E', 'errorlog', '', 'error log file'), |
|
1363 | ('E', 'errorlog', '', 'error log file'), | |
1371 |
('p', 'port', |
|
1364 | ('p', 'port', 0, 'listen port'), | |
1372 | ('a', 'address', '', 'interface address'), |
|
1365 | ('a', 'address', '', 'interface address'), | |
1373 |
('n', 'name', |
|
1366 | ('n', 'name', "", 'repository name'), | |
1374 | ('', 'stdio', None, 'for remote clients'), |
|
1367 | ('', 'stdio', None, 'for remote clients'), | |
1375 | ('t', 'templates', "", 'template map'), |
|
1368 | ('t', 'templates', "", 'template map'), | |
1376 | ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')], |
|
1369 | ('6', 'ipv6', None, 'use IPv6 in addition to IPv4')], |
@@ -119,7 +119,7 b' class hgweb:' | |||||
119 | maxfiles = 10 |
|
119 | maxfiles = 10 | |
120 |
|
120 | |||
121 | def __init__(self, path, name, templates = ""): |
|
121 | def __init__(self, path, name, templates = ""): | |
122 |
self.templates = templates |
|
122 | self.templates = templates | |
123 | self.reponame = name |
|
123 | self.reponame = name | |
124 | self.path = path |
|
124 | self.path = path | |
125 | self.mtime = -1 |
|
125 | self.mtime = -1 | |
@@ -603,7 +603,9 b' class hgweb:' | |||||
603 | self.refresh() |
|
603 | self.refresh() | |
604 | args = cgi.parse() |
|
604 | args = cgi.parse() | |
605 |
|
605 | |||
606 | m = os.path.join(self.templates, "map") |
|
606 | t = self.templates or self.repo.ui.config("web", "templates", | |
|
607 | templatepath()) | |||
|
608 | m = os.path.join(t, "map") | |||
607 | if args.has_key('style'): |
|
609 | if args.has_key('style'): | |
608 | b = os.path.basename("map-" + args['style'][0]) |
|
610 | b = os.path.basename("map-" + args['style'][0]) | |
609 | p = os.path.join(self.templates, b) |
|
611 | p = os.path.join(self.templates, b) | |
@@ -615,9 +617,11 b' class hgweb:' | |||||
615 | if "?" in uri: uri = uri.split("?")[0] |
|
617 | if "?" in uri: uri = uri.split("?")[0] | |
616 | url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri) |
|
618 | url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri) | |
617 |
|
619 | |||
|
620 | name = self.reponame or self.repo.ui.config("web", "name", os.getcwd()) | |||
|
621 | ||||
618 | self.t = templater(m, self.filters, |
|
622 | self.t = templater(m, self.filters, | |
619 | {"url":url, |
|
623 | {"url":url, | |
620 |
"repo": |
|
624 | "repo":name, | |
621 | "header":header, |
|
625 | "header":header, | |
622 | "footer":footer, |
|
626 | "footer":footer, | |
623 | }) |
|
627 | }) | |
@@ -705,6 +709,26 b' class hgweb:' | |||||
705 | def create_server(path, name, templates, address, port, use_ipv6 = False, |
|
709 | def create_server(path, name, templates, address, port, use_ipv6 = False, | |
706 | accesslog = sys.stdout, errorlog = sys.stderr): |
|
710 | accesslog = sys.stdout, errorlog = sys.stderr): | |
707 |
|
711 | |||
|
712 | def openlog(opt, default): | |||
|
713 | if opt and opt != '-': | |||
|
714 | return open(opt, 'w') | |||
|
715 | return default | |||
|
716 | ||||
|
717 | u = ui() | |||
|
718 | repo = repository(u, path) | |||
|
719 | if not address: | |||
|
720 | address = u.config("web", "address", "") | |||
|
721 | if not port: | |||
|
722 | print port | |||
|
723 | port = int(u.config("web", "port", 8000)) | |||
|
724 | if not use_ipv6: | |||
|
725 | use_ipv6 = u.configbool("web", "ipv6") | |||
|
726 | ||||
|
727 | accesslog = openlog(accesslog or u.config("web", "accesslog", "-"), | |||
|
728 | sys.stdout) | |||
|
729 | errorlog = openlog(errorlog or u.config("web", "errorlog", "-"), | |||
|
730 | sys.stderr) | |||
|
731 | ||||
708 | import BaseHTTPServer |
|
732 | import BaseHTTPServer | |
709 |
|
733 | |||
710 | class IPv6HTTPServer(BaseHTTPServer.HTTPServer): |
|
734 | class IPv6HTTPServer(BaseHTTPServer.HTTPServer): |
General Comments 0
You need to be logged in to leave comments.
Login now