mercurial/hgweb.py
changeset 157 2653740d8118
parent 156 32ce2c5d4d25
child 158 be7103467d2e
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):