comparison mercurial/hgweb.py @ 157:2653740d8118

Install the templates where they can be found by hgweb.py This ought to use package_data but that doesn't exist in Python 2.3. So we do a hack of install_data and use glob. This also adds templatepath() to hgweb.py which finds the templates relative to hgweb.py's location.
author mpm@selenic.com
date Wed, 25 May 2005 16:21:06 -0800
parents 32ce2c5d4d25
children be7103467d2e
comparison
equal deleted inserted replaced
156:32ce2c5d4d25 157:2653740d8118
10 import cgitb 10 import cgitb
11 cgitb.enable() 11 cgitb.enable()
12 12
13 import os, cgi, time, re, difflib, sys, zlib 13 import os, cgi, time, re, difflib, sys, zlib
14 from mercurial.hg import * 14 from mercurial.hg import *
15
16 def templatepath():
17 for f in "templates/map", "../templates/map":
18 p = os.path.join(os.path.dirname(__file__), f)
19 if os.path.isfile(p): return p
15 20
16 def age(t): 21 def age(t):
17 def plural(t, c): 22 def plural(t, c):
18 if c == 1: return t 23 if c == 1: return t
19 return t + "s" 24 return t + "s"
100 105
101 class hgweb: 106 class hgweb:
102 maxchanges = 20 107 maxchanges = 20
103 maxfiles = 10 108 maxfiles = 10
104 109
105 def __init__(self, path, name, templatemap): 110 def __init__(self, path, name, templatemap = ""):
111 templatemap = templatemap or templatepath()
112
106 self.reponame = name 113 self.reponame = name
107 self.repo = repository(ui(), path) 114 self.repo = repository(ui(), path)
108 self.t = templater(templatemap) 115 self.t = templater(templatemap)
109 116
110 def date(self, cs): 117 def date(self, cs):