Show More
@@ -15,12 +15,6 b' demandload(globals(), "mimetypes templat' | |||||
15 | from node import * |
|
15 | from node import * | |
16 | from i18n import gettext as _ |
|
16 | from i18n import gettext as _ | |
17 |
|
17 | |||
18 | def templatepath(): |
|
|||
19 | for f in "templates", "../templates": |
|
|||
20 | p = os.path.join(os.path.dirname(__file__), f) |
|
|||
21 | if os.path.isdir(p): |
|
|||
22 | return os.path.normpath(p) |
|
|||
23 |
|
||||
24 | def up(p): |
|
18 | def up(p): | |
25 | if p[0] != "/": |
|
19 | if p[0] != "/": | |
26 | p = "/" + p |
|
20 | p = "/" + p | |
@@ -783,7 +777,7 b' class hgweb(object):' | |||||
783 |
|
777 | |||
784 | expand_form(req.form) |
|
778 | expand_form(req.form) | |
785 |
|
779 | |||
786 | t = self.repo.ui.config("web", "templates", templatepath()) |
|
780 | t = self.repo.ui.config("web", "templates", templater.templatepath()) | |
787 | static = self.repo.ui.config("web", "static", os.path.join(t,"static")) |
|
781 | static = self.repo.ui.config("web", "static", os.path.join(t,"static")) | |
788 | m = os.path.join(t, "map") |
|
782 | m = os.path.join(t, "map") | |
789 | style = self.repo.ui.config("web", "style", "") |
|
783 | style = self.repo.ui.config("web", "style", "") | |
@@ -1027,7 +1021,7 b' class hgwebdir(object):' | |||||
1027 | def footer(**map): |
|
1021 | def footer(**map): | |
1028 | yield tmpl("footer", **map) |
|
1022 | yield tmpl("footer", **map) | |
1029 |
|
1023 | |||
1030 | m = os.path.join(templatepath(), "map") |
|
1024 | m = os.path.join(templater.templatepath(), "map") | |
1031 | tmpl = templater(m, common_filters, |
|
1025 | tmpl = templater(m, common_filters, | |
1032 | {"header": header, "footer": footer}) |
|
1026 | {"header": header, "footer": footer}) | |
1033 |
|
1027 | |||
@@ -1075,7 +1069,7 b' class hgwebdir(object):' | |||||
1075 | req.write(tmpl("notfound", repo=virtual)) |
|
1069 | req.write(tmpl("notfound", repo=virtual)) | |
1076 | else: |
|
1070 | else: | |
1077 | if req.form.has_key('static'): |
|
1071 | if req.form.has_key('static'): | |
1078 | static = os.path.join(templatepath(), "static") |
|
1072 | static = os.path.join(templater.templatepath(), "static") | |
1079 | fname = req.form['static'][0] |
|
1073 | fname = req.form['static'][0] | |
1080 | req.write(staticfile(static, fname) |
|
1074 | req.write(staticfile(static, fname) | |
1081 | or tmpl("error", error="%r not found" % fname)) |
|
1075 | or tmpl("error", error="%r not found" % fname)) |
@@ -105,3 +105,9 b' common_filters = {' | |||||
105 | "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), |
|
105 | "permissions": (lambda x: x and "-rwxr-xr-x" or "-rw-r--r--"), | |
106 | "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), |
|
106 | "rfc822date": lambda x: util.datestr(x, "%a, %d %b %Y %H:%M:%S"), | |
107 | } |
|
107 | } | |
|
108 | ||||
|
109 | def templatepath(): | |||
|
110 | for f in "templates", "../templates": | |||
|
111 | p = os.path.join(os.path.dirname(__file__), f) | |||
|
112 | if os.path.isdir(p): | |||
|
113 | return os.path.normpath(p) |
General Comments 0
You need to be logged in to leave comments.
Login now