[PATCH] Propagate the template map though recursively

Jeff Sipek jeffpc at optonline.net
Fri Aug 5 19:12:57 CDT 2005


This patch allows propagates the template map though recursively
though all the templates.

This allows for some hgweb template cleanup patches as well as it makes
writing new skins/themes for hgweb much much easier. (I'm planing to
write several basic ones.)

Josef "Jeff" Sipek


 hgweb.py |   36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)
  

diff -r 9c918287d10b -r 4a0d72ecfd47 mercurial/hgweb.py
--- a/mercurial/hgweb.py	Thu Aug  4 21:31:25 2005
+++ b/mercurial/hgweb.py	Fri Aug  5 23:57:43 2005
@@ -70,7 +70,7 @@
         if m:
             yield tmpl[:m.start(0)]
             v = map.get(m.group(1), "")
-            v = callable(v) and v() or v
+            v = callable(v) and v(**map) or v
 
             fl = m.group(2)
             if fl:
@@ -224,14 +224,8 @@
             tn = None
             yield diffblock(mdiff.unidiff(to, date1, tn, date2, f), f, tn)
 
-    def header(self):
-        yield self.t("header")
-
-    def footer(self):
-        yield self.t("footer")
-
     def changelog(self, pos):
-        def changenav():
+        def changenav(**map):
             def seq(factor = 1):
                 yield 1 * factor
                 yield 3 * factor
@@ -254,7 +248,7 @@
 
             yield self.t("naventry", label="tip")
 
-        def changelist():
+        def changelist(**map):
             parity = (start - end) & 1
             cl = self.repo.changelog
             l = [] # build a list in forward order for efficiency
@@ -295,7 +289,7 @@
 
     def search(self, query):
 
-        def changelist():
+        def changelist(**map):
             cl = self.repo.changelog
             count = 0
             qw = query.lower().split()
@@ -361,7 +355,7 @@
             files.append(self.t("filenodelink",
                                 filenode = hex(mf.get(f, nullid)), file = f))
 
-        def diff():
+        def diff(**map):
             yield self.diff(p1, n, None)
 
         yield self.t('changeset',
@@ -382,7 +376,7 @@
         fl = self.repo.file(f)
         count = fl.count()
 
-        def entries():
+        def entries(**map):
             l = []
             parity = (count - 1) & 1
 
@@ -457,7 +451,7 @@
         t = float(cs[2].split(' ')[0])
         mfn = cs[0]
 
-        def annotate():
+        def annotate(**map):
             parity = 1
             last = None
             for r, l in fl.annotate(n):
@@ -527,7 +521,7 @@
                 short = os.path.basename(remain)
                 files[short] = (f, n)
 
-        def filelist():
+        def filelist(**map):
             parity = 0
             fl = files.keys()
             fl.sort()
@@ -563,7 +557,7 @@
         i = self.repo.tagslist()
         i.reverse()
 
-        def entries():
+        def entries(**map):
             parity = 0
             for k,n in i:
                 yield self.t("tagentry",
@@ -583,7 +577,7 @@
         cs = cl.read(n)
         mf = self.repo.manifest.read(cs[0])
 
-        def diff():
+        def diff(**map):
             yield self.diff(p1, n, file)
 
         yield self.t("filediff",
@@ -600,6 +594,12 @@
     # find tag, changeset, file
 
     def run(self):
+        def header(**map):
+            yield self.t("header", **map)
+
+        def footer(**map):
+            yield self.t("footer", **map)
+
         self.refresh()
         args = cgi.parse()
 
@@ -618,8 +618,8 @@
         self.t = templater(m, self.filters,
                            {"url":url,
                             "repo":self.reponame,
-                            "header":self.header(),
-                            "footer":self.footer(),
+                            "header":header,
+                            "footer":footer,
                             })
 
         if not args.has_key('cmd') or args['cmd'][0] == 'changelog':
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.selenic.com/pipermail/mercurial/attachments/20050805/44548bf0/attachment-0001.pgp


More information about the Mercurial mailing list