Show More
@@ -2256,7 +2256,7 b' def debuginstall(ui):' | |||
|
2256 | 2256 | |
|
2257 | 2257 | # templates |
|
2258 | 2258 | import templater |
|
2259 | p = templater.templatepath() | |
|
2259 | p = templater.templatepaths() | |
|
2260 | 2260 | ui.status(_("checking templates (%s)...\n") % ' '.join(p)) |
|
2261 | 2261 | if p: |
|
2262 | 2262 | m = templater.templatepath("map-cmdline.default") |
@@ -193,7 +193,7 b' class hgwebdir(object):' | |||
|
193 | 193 | static = self.ui.config("web", "static", None, |
|
194 | 194 | untrusted=False) |
|
195 | 195 | if not static: |
|
196 | tp = self.templatepath or templater.templatepath() | |
|
196 | tp = self.templatepath or templater.templatepaths() | |
|
197 | 197 | if isinstance(tp, str): |
|
198 | 198 | tp = [tp] |
|
199 | 199 | static = [os.path.join(p, 'static') for p in tp] |
@@ -933,7 +933,7 b' def static(web, req, tmpl):' | |||
|
933 | 933 | # readable by the user running the CGI script |
|
934 | 934 | static = web.config("web", "static", None, untrusted=False) |
|
935 | 935 | if not static: |
|
936 | tp = web.templatepath or templater.templatepath() | |
|
936 | tp = web.templatepath or templater.templatepaths() | |
|
937 | 937 | if isinstance(tp, str): |
|
938 | 938 | tp = [tp] |
|
939 | 939 | static = [os.path.join(p, 'static') for p in tp] |
@@ -625,7 +625,7 b' class engine(object):' | |||
|
625 | 625 | engines = {'default': engine} |
|
626 | 626 | |
|
627 | 627 | def stylelist(): |
|
628 | paths = templatepath() | |
|
628 | paths = templatepaths() | |
|
629 | 629 | if not paths: |
|
630 | 630 | return _('no templates found, try `hg debuginstall` for more info') |
|
631 | 631 | dirlist = os.listdir(paths[0]) |
@@ -710,25 +710,26 b' class templater(object):' | |||
|
710 | 710 | max=self.maxchunk) |
|
711 | 711 | return stream |
|
712 | 712 | |
|
713 |
def templatepath( |
|
|
714 |
'''return location |
|
|
715 | returns None if not found.''' | |
|
713 | def templatepaths(): | |
|
714 | '''return locations used for template files.''' | |
|
716 | 715 | normpaths = [] |
|
717 | ||
|
718 | 716 | for f in path: |
|
719 | 717 | if f.startswith('/'): |
|
720 | 718 | p = f |
|
721 | 719 | else: |
|
722 | 720 | fl = f.split('/') |
|
723 | 721 | p = os.path.join(util.datapath, *fl) |
|
724 | if name: | |
|
725 | p = os.path.join(p, name) | |
|
726 | if name and os.path.exists(p): | |
|
727 | return os.path.normpath(p) | |
|
728 | elif os.path.isdir(p): | |
|
722 | if os.path.isdir(p): | |
|
729 | 723 | normpaths.append(os.path.normpath(p)) |
|
724 | return normpaths | |
|
730 | 725 | |
|
731 | return normpaths | |
|
726 | def templatepath(name): | |
|
727 | '''return location of template file. returns None if not found.''' | |
|
728 | for p in templatepaths(): | |
|
729 | f = os.path.join(p, name) | |
|
730 | if os.path.exists(f): | |
|
731 | return f | |
|
732 | return None | |
|
732 | 733 | |
|
733 | 734 | def stylemap(styles, paths=None): |
|
734 | 735 | """Return path to mapfile for a given style. |
@@ -740,7 +741,7 b' def stylemap(styles, paths=None):' | |||
|
740 | 741 | """ |
|
741 | 742 | |
|
742 | 743 | if paths is None: |
|
743 | paths = templatepath() | |
|
744 | paths = templatepaths() | |
|
744 | 745 | elif isinstance(paths, str): |
|
745 | 746 | paths = [paths] |
|
746 | 747 |
General Comments 0
You need to be logged in to leave comments.
Login now