# HG changeset patch # User Alexis S. L. Carvalho # Date 1171536692 7200 # Node ID 51e52db6b40d4d4f459d36e2aa3e92eae986c625 # Parent 33c369afec947c67f69ae56b980a45929d166976 hgweb: allow static files to be served directly by the HTTP server diff --git a/doc/hgrc.5.txt b/doc/hgrc.5.txt --- a/doc/hgrc.5.txt +++ b/doc/hgrc.5.txt @@ -507,6 +507,11 @@ web:: push_ssl;; Whether to require that inbound pushes be transported over SSL to prevent password sniffing. Default is true. + staticurl;; + Base URL to use for static files. If unset, static files (e.g. + the hgicon.png favicon) will be served by the CGI script itself. + Use this setting to serve them directly with the HTTP server. + Example: "http://hgserver/static/" stripes;; How many lines a "zebra stripe" should span in multiline output. Default is 1; set to 0 to disable. diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -772,6 +772,9 @@ class hgweb(object): port = req.env["SERVER_PORT"] port = port != "80" and (":" + port) or "" urlbase = 'http://%s%s' % (req.env['SERVER_NAME'], port) + staticurl = self.config("web", "staticurl") or req.url + 'static/' + if not staticurl.endswith('/'): + staticurl += '/' if not self.reponame: self.reponame = (self.config("web", "name") @@ -780,6 +783,7 @@ class hgweb(object): self.t = templater.templater(mapfile, templater.common_filters, defaults={"url": req.url, + "staticurl": staticurl, "urlbase": urlbase, "repo": self.reponame, "header": header, diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -88,6 +88,10 @@ class hgwebdir(object): if not url.endswith('/'): url += '/' + staticurl = config('web', 'staticurl') or url + 'static/' + if not staticurl.endswith('/'): + staticurl += '/' + style = self.style if style is None: style = config('web', 'style', '') @@ -98,7 +102,8 @@ class hgwebdir(object): defaults={"header": header, "footer": footer, "motd": motd, - "url": url}) + "url": url, + "staticurl": staticurl}) def archivelist(ui, nodeid, url): allowed = ui.configlist("web", "allow_archive", untrusted=True) diff --git a/templates/gitweb/header.tmpl b/templates/gitweb/header.tmpl --- a/templates/gitweb/header.tmpl +++ b/templates/gitweb/header.tmpl @@ -4,7 +4,7 @@ Content-type: text/html; charset={encodi - + - + diff --git a/templates/header.tmpl b/templates/header.tmpl --- a/templates/header.tmpl +++ b/templates/header.tmpl @@ -3,6 +3,6 @@ Content-type: text/html; charset={encodi - + - +