Mercurial > hg
changeset 1897:58b6784cf9f1
move hgweb.templatepath into templater
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Sun, 26 Feb 2006 13:09:26 -0800 |
parents | f8f818a04f5b |
children | e517189f168d |
files | mercurial/hgweb.py mercurial/templater.py |
diffstat | 2 files changed, 9 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- 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))
--- 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)