(Arne Babenhauserheide)
2011-10-07: added a log writer which writes at most 100 intries per page. added a log writer which writes at most 100 intries per page.
diff --git a/static.py b/static.py --- a/static.py +++ b/static.py @@ -48,10 +48,10 @@ templates = { <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!--duplicate for older browsers--> <link rel="stylesheet" href="style.css" type="text/css" media="screen" /> <link rel="stylesheet" href="print.css" type="text/css" media="print" /> - <title>REPO_NAME</title> + <title>{reponame}</title> </head> <body> -<h1>REPO_NAME</h1> +<h1>{reponame}</h1> """, "foot": "</body></html>", "screenstyle": """ """, @@ -68,7 +68,7 @@ def parsereadme(filepath): def writeoverview(ui, repo, target, name): """Create the overview page""" overview = open(join(target, "index.html"), "w") - overview.write(templates["head"].replace("REPO_NAME", name)) + overview.write(templates["head"].replace("{reponame}", name)) # add a short identifier from the first line of the readme, if it # exists # TODO: Parse different types of readme files readme = name @@ -82,7 +82,7 @@ def writeoverview(ui, repo, target, name overview.write("<h2>Changes</h2>") ui.pushbuffer() t = cmdutil.changeset_templater(ui, repo, patch=False, diffopts=None, mapfile=None, buffered=False) - t.use_template("""<div style='float: right; padding-left: 0.5em'><em>({author|person})</em></div><strong> {date|shortdate}: <a href='commits/{node}.html'>{desc|strip|fill68|firstline}</a> <span style='font-size: xx-small'>{branches} {tags}</span><p>{desc|escape}</p>""") + t.use_template("""<div style='float: right; padding-left: 0.5em'><em>({author|person})</em></div><strong> {date|shortdate}: <a href='commit/{node}.html'>{desc|strip|fill68|firstline}</a> <span style='font-size: xx-small'>{branches} {tags}</span><p>{desc|escape}</p>""") for c in range(1, min(len(repo.changelog), 5)): ctx = repo.changectx(str(-c)) t.show(ctx) @@ -95,6 +95,47 @@ def writeoverview(ui, repo, target, name # finish the overview overview.write(templates["foot"]) +def writelog(ui, repo, target, name): + """Write the full changelog, in steps of 100.""" + commits = join(target, "commits") + if not isdir(commits): + os.makedirs(commits) + for i in range(len(repo.changelog)/100): + d = commits+"-"+str(i+1)+"00" + if not isdir(d): + os.makedirs(d) + + t = cmdutil.changeset_templater(ui, repo, patch=False, diffopts=None, mapfile=None, buffered=False) + t.use_template("""<div style='float: right; padding-left: 0.5em'><em>({author|person})</em></div><strong> {date|shortdate}: <a href='../commit/{node}.html'>{desc|strip|fill68|firstline}</a> <span style='font-size: xx-small'>{branches} {tags}</span><p>{desc|escape}</p>""") + logs = [] + for ck in range(0, len(repo.changelog)/100+1): + ui.pushbuffer() + if ck: + dd = d + di = str(ck)+"00" + d = commits+"-"+di + logs[-1].write("<p><a href=\"../commits-"+di+"\">earlier</a></p>") + if ck>2: + # the older log gets a reference to the newer one + logs[-1].write("<p><a href=\"../commits-"+str(ck-2)+"00"+"\">later</a></p>") + elif ck>1: + logs[-1].write("<p><a href=\"../commits\">later</a></p>") + logs.append(open(join(d, "index.html"), "w")) + else: + d = commits + logs.append(open(join(d, "index.html"), "w")) + + logs[-1].write(templates["head"].replace("{reponame}", name)) + for c in range(ck*100+1, min(len(repo.changelog), (ck+1)*100)): + ctx = repo.changectx(str(-c)) + t.show(ctx) + logs[-1].write(ui.popbuffer()) + + for l in logs: + l.write(templates["foot"].replace("{reponame}", name)) + l.close() + + def parsesite(ui, repo, target, **opts): """Create the static folder.""" idfile = join(target, _staticidentifier) @@ -130,6 +171,9 @@ def parsesite(ui, repo, target, **opts): # then the overview writeoverview(ui, repo, target, name) + # and the log + writelog(ui, repo, target, name) + def addrepo(ui, repo, target): """Add the repo to the target and make sure it is up to date.""" try: