Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb.py @ 938:54b2a42e501e
hgweb: add [web] section to hgrc
This makes almost all of the hgweb settings available in hgrc.
author | mpm@selenic.com |
---|---|
date | Wed, 17 Aug 2005 17:57:37 -0800 |
parents | e4f1b76831b2 |
children | 6b735e0ddd81 aedb47764f29 |
comparison
equal
deleted
inserted
replaced
937:e4f1b76831b2 | 938:54b2a42e501e |
---|---|
117 class hgweb: | 117 class hgweb: |
118 maxchanges = 10 | 118 maxchanges = 10 |
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 or templatepath() | 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 |
126 self.viewonly = 0 | 126 self.viewonly = 0 |
127 | 127 |
601 yield self.t("footer", **map) | 601 yield self.t("footer", **map) |
602 | 602 |
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) |
610 if os.path.isfile(p): m = p | 612 if os.path.isfile(p): m = p |
611 | 613 |
613 port = port != "80" and (":" + port) or "" | 615 port = port != "80" and (":" + port) or "" |
614 uri = os.environ["REQUEST_URI"] | 616 uri = os.environ["REQUEST_URI"] |
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":self.reponame, | 624 "repo":name, |
621 "header":header, | 625 "header":header, |
622 "footer":footer, | 626 "footer":footer, |
623 }) | 627 }) |
624 | 628 |
625 if not args.has_key('cmd'): | 629 if not args.has_key('cmd'): |
702 else: | 706 else: |
703 write(self.t("error")) | 707 write(self.t("error")) |
704 | 708 |
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): |
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) | |
707 | 731 |
708 import BaseHTTPServer | 732 import BaseHTTPServer |
709 | 733 |
710 class IPv6HTTPServer(BaseHTTPServer.HTTPServer): | 734 class IPv6HTTPServer(BaseHTTPServer.HTTPServer): |
711 address_family = getattr(socket, 'AF_INET6', None) | 735 address_family = getattr(socket, 'AF_INET6', None) |