# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 2012-12-23 00:11:51
# Node ID e4f17956f45ae333a7647a24e1f29a64c48eac6c
# Parent  52581d2b98ac5355c3b2ea304595f8cfee4cce59

hgwebdir: honor web.templates and web.static for static files (issue3734)

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
@@ -184,7 +184,13 @@ class hgwebdir(object):
                         fname = virtual[7:]
                     else:
                         fname = req.form['static'][0]
-                    static = templater.templatepath('static')
+                    static = self.ui.config("web", "static", None,
+                                            untrusted=False)
+                    if not static:
+                        tp = self.templatepath or templater.templatepath()
+                        if isinstance(tp, str):
+                            tp = [tp]
+                        static = [os.path.join(p, 'static') for p in tp]
                     return (staticfile(static, fname, req),)
 
                 # top-level index