Wed Sep 21 18:24:58 UTC 2005 Alberto Bertogli <albertogli@telpin.com.ar>
* Shade and zebra styles for annotate.
This patch adds two more annotate styles: zebra and shade.
Zebra alternates the line background colour according to the patch, just like
most CVS viewers do.
Shade is a lot more fun: it gives each patch a shade of a colour, the newer
the brighter, so newer patches (which are often the ones you're intrested in)
are easier to spot. It could use a little tuning on some constants to make it
look better, but it's pretty usable as is, and it can be done later if needed.
Thanks to Max Battcher for the idea.
{
hunk ./darcsweb.cgi 361
- elif f and h and action == "annotate":
+
+ elif f and h and action.startswith("annotate"):
hunk ./darcsweb.cgi 365
-<a href="%(myreponame)s;a=annotate_plain;f=%(fname)s;h=%(hash)s">plain</a>
+<a href="%(myreponame)s;a=annotate;f=%(fname)s;h=%(hash)s">normal</a>
+| <a href="%(myreponame)s;a=annotate_plain;f=%(fname)s;h=%(hash)s">plain</a>
+| <a href="%(myreponame)s;a=annotate_shade;f=%(fname)s;h=%(hash)s">shade</a>
+| <a href="%(myreponame)s;a=annotate_zebra;f=%(fname)s;h=%(hash)s">zebra</a>
hunk ./darcsweb.cgi 986
-def print_annotate(ann):
+def print_annotate(ann, style):
hunk ./darcsweb.cgi 995
+ if style == 'shade':
+ # here's the idea: we will assign to each patch a shade of
+ # color from its date (newer gets darker)
+ max = 0xff
+ min = max - 80
+
+ # to do that, we need to get a list of the patch hashes
+ # ordered by their dates
+ l = [ (date, hash) for (hash, date) in ann.patches.items() ]
+ l.sort()
+ l = [ hash for (date, hash) in l ]
+
+ # now we have to map each element to a number in the range
+ # min-max, with max being close to l[0] and min l[len(l) - 1]
+ lenn = max - min
+ lenl = len(l)
+ shadetable = {}
+ for i in range(0, lenl):
+ hash = l[i]
+ n = float(i * lenn) / lenl
+ n = max - int(round(n))
+ shadetable[hash] = n
+ elif style == "zebra":
+ lineclass = 'dark'
+
hunk ./darcsweb.cgi 1034
+ if style == "shade":
+ linestyle = 'style="background-color:#ffff%.2x"' % \
+ shadetable[l.phash]
+ lineclass = ''
+ elif style == "zebra":
+ linestyle = ''
+ if l.phash != prevhash:
+ if lineclass == 'dark':
+ lineclass = 'light'
+ else:
+ lineclass = 'dark'
+ else:
+ linestyle = ''
+ lineclass = ''
+
hunk ./darcsweb.cgi 1069
-<div class="pre">\
+<div class="pre %(class)s" %(style)s>\
hunk ./darcsweb.cgi 1075
+ 'class': lineclass,
+ 'style': linestyle,
hunk ./darcsweb.cgi 1551
-def do_annotate(fname, phash):
+def do_annotate(fname, phash, style):
hunk ./darcsweb.cgi 1570
- print_annotate(ann)
+ print_annotate(ann, style)
hunk ./darcsweb.cgi 1883
- do_annotate(fname, phash)
+ do_annotate(fname, phash, "normal")
hunk ./darcsweb.cgi 1891
+elif action == "annotate_zebra":
+ fname = filter_file(form["f"].value)
+ if form.has_key("h"):
+ phash = filter_hash(form["h"].value)
+ else:
+ phash = None
+ do_annotate(fname, phash, "zebra")
+elif action == "annotate_shade":
+ fname = filter_file(form["f"].value)
+ if form.has_key("h"):
+ phash = filter_hash(form["h"].value)
+ else:
+ phash = None
+ do_annotate(fname, phash, "shade")
hunk ./style.css 148
-tr.light:hover {
+.light:hover {
hunk ./style.css 152
-tr.dark {
+.dark {
hunk ./style.css 156
-tr.dark:hover {
+.dark:hover {
}