Mon Sep 19 06:20:23 UTC 2005 Alberto Bertogli <albertogli@telpin.com.ar>
* Fix some UTF8 handling in annotate, and add tooltips.
This patch fixes some of the UTF8 handling in different annotate parts.
Accidentally, it also includes a small modification to show for each line of
the annotate the last modification time, date and author as a tooltip. It'd be
nice to put this in a different patch.
diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi
--- old-darcsweb/darcsweb.cgi 2015-10-18 21:32:03.000000000 +0000
+++ new-darcsweb/darcsweb.cgi 2015-10-18 21:32:04.000000000 +0000
@@ -683,22 +683,27 @@
dom = xml.dom.minidom.parseString(s)
file = dom.getElementsByTagName("file")[0]
- annotate.fname = file.getAttribute("name")
+ annotate.fname = fixu8(file.getAttribute("name"))
createinfo = dom.getElementsByTagName("created_as")[0]
- annotate.created_as = createinfo.getAttribute("original_name")
+ annotate.created_as = fixu8(createinfo.getAttribute("original_name"))
creator = createinfo.getElementsByTagName("patch")[0]
- annotate.creator_hash = creator.getAttribute("hash")
+ annotate.creator_hash = fixu8(creator.getAttribute("hash"))
mod = dom.getElementsByTagName("modified")[0]
lastpatch = mod.getElementsByTagName("patch")[0]
- annotate.lastchange_hash = lastpatch.getAttribute("hash")
- annotate.lastchange_author = lastpatch.getAttribute("author")
+ annotate.lastchange_hash = fixu8(lastpatch.getAttribute("hash"))
+ annotate.lastchange_author = fixu8(lastpatch.getAttribute("author"))
lastname = lastpatch.getElementsByTagName("name")[0]
lastname = lastname.childNodes[0].wholeText
- annotate.lastchange_name = lastname
+ annotate.lastchange_name = fixu8(lastname)
+
+ lastdate = lastpatch.getAttribute("date")
+ lastdate = time.strptime(lastdate, "%Y%m%d%H%M%S")
+ lastdate = time.strftime("%Y-%m-%d %H:%M:%S", lastdate)
+ annotate.lastchange_date = fixu8(lastdate)
file = dom.getElementsByTagName("file")[0]
@@ -712,11 +717,15 @@
patch = l.getElementsByTagName("patch")[0]
phash = patch.getAttribute("hash")
pauthor = patch.getAttribute("author")
+ pdate = patch.getAttribute("date")
+ pdate = time.strptime(pdate, "%Y%m%d%H%M%S")
+ pdate = time.strftime("%Y-%m-%d %H:%M:%S", pdate)
else:
# added lines inherit the creation from the annotate
# patch
phash = annotate.lastchange_hash
pauthor = annotate.lastchange_author
+ pdate = annotate.lastchange_date
text = ""
for node in l.childNodes:
@@ -728,9 +737,10 @@
# in front of it
text = text.lstrip("\n")
- line.text = text
- line.phash = phash
- line.pauthor = pauthor
+ line.text = fixu8(text)
+ line.phash = fixu8(phash)
+ line.pauthor = fixu8(pauthor)
+ line.pdate = fixu8(pdate)
annotate.lines.append(line)
return annotate
@@ -954,8 +964,9 @@
count = 1
for l in ann.lines:
- text = fixu8(escape(l.text))
+ text = escape(l.text)
text = text.rstrip()
+ title = "%s by %s" % (l.pdate, escape(l.pauthor) )
link = "%(myrname)s;a=commit;h=%(hash)s" % {
'myrname': config.myreponame,
@@ -963,12 +974,13 @@
}
print """\
<div class="pre">\
-<a href="%(link)s" class="linenr">%(c)4d</a> \
-<a href="%(link)s" class="line">%(text)s</a>\
+<a href="%(link)s" title="%(title)s" class="linenr">%(c)4d</a> \
+<a href="%(link)s" title="%(title)s" class="line">%(text)s</a>\
</div>
""" % {
'c': count,
'text': text,
+ 'title': title,
'link': link
}
@@ -1443,7 +1455,6 @@
ann = get_annotate(fname, phash)
print_navbar(f = fname, h = ann.lastchange_hash)
-
print """
<div>
<a class="title" href="%(myreponame)s;a=commit;h=%(hash)s">%(name)s</a>
@@ -1454,8 +1465,8 @@
""" % {
'myreponame': config.myreponame,
'hash': ann.lastchange_hash,
- 'name': ann.lastchange_name,
- 'fname': fname,
+ 'name': escape(ann.lastchange_name),
+ 'fname': escape(fname),
}
print_annotate(ann)