Mercurial > hg
changeset 2666:ebf033bc8eb2
hgweb: Configurable zebra stripes
With this change, you can set
[web]
stripes=3
to get stripes every three lines (a-la fanfold paper), instead of every
line on source and directory listings. The default behaviour is stripes=1
which generates output similar to current, and you can also turn stripes
off by setting it to 0.
author | Frank Kingswood <frank@kingswood-consulting.co.uk> |
---|---|
date | Mon, 24 Jul 2006 23:06:05 -0700 |
parents | 2efcd2b4c9fe |
children | 92ba858ed640 |
files | doc/hgrc.5.txt mercurial/hgweb/hgweb_mod.py |
diffstat | 2 files changed, 23 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/hgrc.5.txt Tue Jul 25 01:23:31 2006 +0200 +++ b/doc/hgrc.5.txt Mon Jul 24 23:06:05 2006 -0700 @@ -440,6 +440,9 @@ push_ssl;; Whether to require that inbound pushes be transported over SSL to prevent password sniffing. Default is true. + stripes;; + How many lines a "zebra stripe" should span in multiline output. + Default is 1; set to 0 to disable. style;; Which template map style to use. templates;;
--- a/mercurial/hgweb/hgweb_mod.py Tue Jul 25 01:23:31 2006 +0200 +++ b/mercurial/hgweb/hgweb_mod.py Mon Jul 24 23:06:05 2006 -0700 @@ -37,6 +37,7 @@ self.mtime = -1 self.reponame = name self.archives = 'zip', 'gz', 'bz2' + self.stripecount = 1 self.templatepath = self.repo.ui.config("web", "templates", templater.templatepath()) @@ -46,6 +47,7 @@ self.mtime = mtime self.repo = hg.repository(self.repo.ui, self.repo.root) self.maxchanges = int(self.repo.ui.config("web", "maxchanges", 10)) + self.stripecount = int(self.repo.ui.config("web", "stripes", 1)) self.maxfiles = int(self.repo.ui.config("web", "maxfiles", 10)) self.allowpull = self.repo.ui.configbool("web", "allowpull", True) @@ -265,7 +267,7 @@ hn = hex(n) yield self.t('searchentry', - parity=count & 1, + parity=self.stripes(count), author=changes[1], parent=self.siblings(cl.parents(n), cl.rev), child=self.siblings(cl.children(n), cl.rev), @@ -376,7 +378,7 @@ for l, t in enumerate(text.splitlines(1)): yield {"line": t, "linenumber": "% 6d" % (l + 1), - "parity": l & 1} + "parity": self.stripes(l)} yield self.t("filerevision", file=f, @@ -409,7 +411,7 @@ mfn = cs[0] def annotate(**map): - parity = 1 + parity = 0 last = None for r, l in fl.annotate(n): try: @@ -489,10 +491,10 @@ yield {"file": full, "manifest": mnode, "filenode": hex(fnode), - "parity": parity, + "parity": self.stripes(parity), "basename": f, "permissions": mff[full]} - parity = 1 - parity + parity += 1 def dirlist(**map): parity = 0 @@ -503,11 +505,11 @@ if fnode: continue - yield {"parity": parity, + yield {"parity": self.stripes(parity), "path": os.path.join(path, f), "manifest": mnode, "basename": f[:-1]} - parity = 1 - parity + parity += 1 yield self.t("manifest", manifest=mnode, @@ -530,12 +532,12 @@ parity = 0 for k,n in i: if notip and k == "tip": continue - yield {"parity": parity, + yield {"parity": self.stripes(parity), "tag": k, "tagmanifest": hex(cl.read(n)[0]), "date": cl.read(n)[2], "node": hex(n)} - parity = 1 - parity + parity += 1 yield self.t("tags", manifest=hex(mf), @@ -565,12 +567,12 @@ t = c[2] yield self.t("tagentry", - parity = parity, + parity = self.stripes(parity), tag = k, node = hex(n), date = t, tagmanifest = hex(m)) - parity = 1 - parity + parity += 1 def changelist(**map): parity = 0 @@ -752,6 +754,13 @@ else: req.write(self.t("error")) + def stripes(self, parity): + "make horizontal stripes for easier reading" + if self.stripecount: + return (1 + parity / self.stripecount) & 1 + else: + return 0 + def do_changelog(self, req): hi = self.repo.changelog.count() - 1 if req.form.has_key('rev'):