(Arne Babenhauserheide)
2012-10-30: merge bug list creation. merge bug list creation.
diff --git a/staticsite.py b/staticsite.py
--- a/staticsite.py
+++ b/staticsite.py
@@ -122,11 +122,11 @@ def splitbugline(line):
description = "".join(line.split("-")[1:]).lstrip()
return bugid, description
-def getbugdetails(ui, bugid):
+def getbugdetails(ui, repo, bugid):
"""Get the details for a bug."""
# first get the details
ui.pushbuffer()
- req = dispatch.request(["b", "details", bugid], ui=ui)
+ req = dispatch.request(["b", "details", bugid], ui=ui, repo=repo)
dispatch.dispatch(req)
return ui.popbuffer()
@@ -141,15 +141,15 @@ def getbugfullid(details, bugid):
class BBug(object):
"""A b-extension bug."""
- def __init__(self, bugid, description, state, details=""):
- self.bugid, self.description, self.state, self.details = bugid, description, state, details
+ def __init__(self, shortid, fullid, description, state, details=""):
+ self.shortid, self.fullid, self.description, self.state, self.details = shortid, fullid, description, state, details
-def getbuginfo(ui, bugline):
+def getbuginfo(ui, repo, bugline):
"""Get information about a bug from its bugline."""
- bugid, description = splitbugline(bugline)
- details = getbugdetails(ui, bugid)
- bugid = getbugfullid(details, bugid)
- return bugid, description, details
+ shortid, description = splitbugline(bugline)
+ details = getbugdetails(ui, repo, shortid)
+ fullid = getbugfullid(details, shortid)
+ return shortid, fullid, description, details
def getbugs(ui, repo):
"""Get all bugs."""
@@ -168,12 +168,12 @@ def getbugs(ui, repo):
# now turn them into a list of bugs
openbugs = []
for bugline in openbuglines:
- bugid, description, details = getbuginfo(ui, bugline)
- openbugs.append(BBug(bugid, description, "open", details))
+ bugid, fullid, description, details = getbuginfo(ui, repo, bugline)
+ openbugs.append(BBug(bugid, fullid, description, "open", details))
resolvedbugs = []
for bugline in resolvedbuglines:
- bugid, description, details = getbuginfo(ui, bugline)
- resolvedbugs.append(BBug(bugid, description, "resolved", details))
+ bugid, fullid, description, details = getbuginfo(ui, repo, bugline)
+ resolvedbugs.append(BBug(bugid, fullid, description, "resolved", details))
return openbugs, resolvedbugs
def parsereadme(filepath, truncated=False):
@@ -216,7 +216,7 @@ def writeoverview(ui, repo, target, name
# and the bugs
openbugs, resolvedbugs = getbugs(ui, repo)
if openbugs or resolvedbugs:
- overview += " | " + _("bugs")
+ overview += " | <a href=\"bugs\">" + _("bugs") + "</a>"
if openbugs:
overview += " <span class=\"bugnumbers\">(<span class=\"openbugnumber\">" + str(len(openbugs)) + "!</span> "
else:
@@ -551,6 +551,55 @@ def writecommits(ui, repo, target, name,
cf.write("<pre>"+ui.popbuffer().replace("<", "<")+"</pre>")
cf.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>"))
+#: html escape codes thanks to http://wiki.python.org/moin/EscapingHtml
+htmlescapetable = {
+ "&": "&",
+ '"': """,
+ "'": "'",
+ ">": ">",
+ "<": "<",
+ }
+
+def htmlescape(text):
+ """Produce entities within text."""
+ return "".join(htmlescapetable.get(c,c) for c in text)
+
+def writebugs(ui, repo, target, name):
+ """Write bug information, a listing and the details for each bug."""
+ bugdir = os.path.join(target, "bugs")
+
+ # create the bugs folder
+ if not os.path.isdir(bugdir):
+ os.makedirs(bugdir)
+
+ # get all bugs
+ openbugs, resolvedbugs = getbugs(ui, repo)
+ # write the bugs list
+ bugslist = os.path.join(bugdir, "index.html")
+ content = "<h2 id=\"open\">Open Bugs</h2>\n<ul>"
+ for bug in openbugs:
+ content += "<li><a href=\"" + bug.fullid + ".html\">" + bug.shortid + "</a> - " + htmlescape(bug.description) + "</li>\n"
+ content += "</ul>\n"
+ content += "<h2 id=\"resolved\">Resolved Bugs</h2>\n<ul>"
+ for bug in resolvedbugs:
+ content += "<li><a href=\"" + bug.fullid + ".html\">" + bug.shortid + "</a> - " + htmlescape(bug.description) + "</li>\n"
+ content += "</ul>\n"
+ with open(bugslist, "w") as f:
+ f.write(templates["head"].replace("{reponame}", "<a href='../'>"+name+"</a>").replace("{title}", name))
+ f.write(content)
+ f.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>"))
+ # write all bug details
+ for bug in openbugs + resolvedbugs:
+ bugsfile = bugslist = os.path.join(bugdir, bug.fullid + ".html")
+ content = "<h2>" + bug.description + "</h2>\n"
+ content += "<pre>" + bug.details + "</pre>\n"
+ content += "<hr>"
+ content += "- <a href=\"index.html\">" + _("all bugs") + "</a> -"
+ with open(bugsfile, "w") as bf:
+ bf.write(templates["head"].replace("{reponame}", "<a href='../'>"+name+"</a>").replace("{title}", name))
+ bf.write(content)
+ bf.write(templates["foot"].replace("{reponame}", "<a href='../'>"+name+"</a>"))
+
def escapename(filename):
"""escape index.html as .index.html and .ind… as ..ind… and so fort."""
if _indexregexp.match(filename) is not None:
@@ -704,6 +753,9 @@ def parsesite(ui, repo, target, **opts):
# and all forks
writeforks(ui, repo, target, name)
+
+ # and all bugs
+ writebugs(ui, repo, target, name)
def addrepo(ui, repo, target, bookmarks, force):
"""Add the repo to the target and make sure it is up to date."""