# HG changeset patch # User Vadim Gelfer # Date 1140988166 28800 # Node ID 58b6784cf9f14e22f0d12568363cfa61d2b0ebfa # Parent f8f818a04f5bb16ca727b16bac6f838344b477a9 move hgweb.templatepath into templater diff -r f8f818a04f5b -r 58b6784cf9f1 mercurial/hgweb.py --- a/mercurial/hgweb.py Sun Feb 26 12:59:28 2006 -0800 +++ b/mercurial/hgweb.py Sun Feb 26 13:09:26 2006 -0800 @@ -15,12 +15,6 @@ from node import * from i18n import gettext as _ -def templatepath(): - for f in "templates", "../templates": - p = os.path.join(os.path.dirname(__file__), f) - if os.path.isdir(p): - return os.path.normpath(p) - def up(p): if p[0] != "/": p = "/" + p @@ -783,7 +777,7 @@ expand_form(req.form) - t = self.repo.ui.config("web", "templates", templatepath()) + t = self.repo.ui.config("web", "templates", templater.templatepath()) static = self.repo.ui.config("web", "static", os.path.join(t,"static")) m = os.path.join(t, "map") style = self.repo.ui.config("web", "style", "") @@ -1027,7 +1021,7 @@ def footer(**map): yield tmpl("footer", **map) - m = os.path.join(templatepath(), "map") + m = os.path.join(templater.templatepath(), "map") tmpl = templater(m, common_filters, {"header": header, "footer": footer}) @@ -1075,7 +1069,7 @@ req.write(tmpl("notfound", repo=virtual)) else: if req.form.has_key('static'): - static = os.path.join(templatepath(), "static") + static = os.path.join(templater.templatepath(), "static") fname = req.form['static'][0] req.write(staticfile(static, fname) or tmpl("error", error="%r not found" % fname)) diff -r f8f818a04f5b -r 58b6784cf9f1 mercurial/templater.py --- a/mercurial/templater.py Sun Feb 26 12:59:28 2006 -0800 +++ b/mercurial/templater.py Sun Feb 26 13:09:26 2006 -0800 @@ -105,3 +105,9 @@ "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), } + +def templatepath(): + for f in "templates", "../templates": + p = os.path.join(os.path.dirname(__file__), f) + if os.path.isdir(p): + return os.path.normpath(p)