--- a/mercurial/hgweb.py Wed Aug 17 16:37:04 2005 -0800
+++ b/mercurial/hgweb.py Wed Aug 17 17:57:37 2005 -0800
@@ -119,7 +119,7 @@
maxfiles = 10
def __init__(self, path, name, templates = ""):
- self.templates = templates or templatepath()
+ self.templates = templates
self.reponame = name
self.path = path
self.mtime = -1
@@ -603,7 +603,9 @@
self.refresh()
args = cgi.parse()
- m = os.path.join(self.templates, "map")
+ t = self.templates or self.repo.ui.config("web", "templates",
+ templatepath())
+ m = os.path.join(t, "map")
if args.has_key('style'):
b = os.path.basename("map-" + args['style'][0])
p = os.path.join(self.templates, b)
@@ -615,9 +617,11 @@
if "?" in uri: uri = uri.split("?")[0]
url = "http://%s%s%s" % (os.environ["SERVER_NAME"], port, uri)
+ name = self.reponame or self.repo.ui.config("web", "name", os.getcwd())
+
self.t = templater(m, self.filters,
{"url":url,
- "repo":self.reponame,
+ "repo":name,
"header":header,
"footer":footer,
})
@@ -705,6 +709,26 @@
def create_server(path, name, templates, address, port, use_ipv6 = False,
accesslog = sys.stdout, errorlog = sys.stderr):
+ def openlog(opt, default):
+ if opt and opt != '-':
+ return open(opt, 'w')
+ return default
+
+ u = ui()
+ repo = repository(u, path)
+ if not address:
+ address = u.config("web", "address", "")
+ if not port:
+ print port
+ port = int(u.config("web", "port", 8000))
+ if not use_ipv6:
+ use_ipv6 = u.configbool("web", "ipv6")
+
+ accesslog = openlog(accesslog or u.config("web", "accesslog", "-"),
+ sys.stdout)
+ errorlog = openlog(errorlog or u.config("web", "errorlog", "-"),
+ sys.stderr)
+
import BaseHTTPServer
class IPv6HTTPServer(BaseHTTPServer.HTTPServer):