(Arne Babenhauserheide)
2011-10-06: actually add the readme. actually add the readme.
diff --git a/static.py b/static.py --- a/static.py +++ b/static.py @@ -33,7 +33,7 @@ without the interactivity). """ import os -from os.path import join, isdir, isfile +from os.path import join, isdir, isfile, basename import shutil import mercurial.cmdutil from mercurial import commands @@ -50,6 +50,7 @@ templates = { <title>REPO_NAME</title> </head> <body> +<h1>REPO_NAME</h1> """, "foot": "</body></html>", "screenstyle": """ """, @@ -76,6 +77,11 @@ def parsesite(ui, repo, target, **opts): with open(idfile, "w") as i: i.write("") + if opts["name"]: + name = opts["name"] + elif target: name = target + else: name = basename(repo.root) + # first the stylesheets screenstyle = opts["screenstyle"] if screenstyle: @@ -92,18 +98,18 @@ def parsesite(ui, repo, target, **opts): # then the overview overview = open(join(target, "index.html"), "w") - overview.write(templates["head"]) + overview.write(templates["head"].replace("REPO_NAME", name)) # add a readme, if it exists # TODO: Parse different types of readme files - for f in os.listdir(target): + for f in os.listdir(repo.root): if f.lower().startswith("readme"): overview.write(parsereadme(f)) # now add the 5 most recent log entries # divert all following ui output to a string, so we can just use standard functions - #ui.pushbuffer() + ui.pushbuffer() commands.log(ui, repo, template="""<div style='float: right; padding-left: 0.5em'><em>({author|person})</em></div> -g<p><strong> {date|shortdate}: <a href='commits/{node}.html'>{desc|strip|fill68|firstline}</a> <span style='font-size: xx-small'>{branches} {tags}</span></p><p>{desc|escape}</p>""", date="") - #overview.write(ui.popbuffer()) +<p><strong> {date|shortdate}: <a href='commits/{node}.html'>{desc|strip|fill68|firstline}</a> <span style='font-size: xx-small'>{branches} {tags}</span></p><p>{desc|escape}</p>""", date="", rev="0:0", user=ui.username()) + overview.write(ui.popbuffer()) # finish the overview overview.write(templates["foot"])