# By Jordan Perr, 2010, http://jperr.com/
# You are free to use this code as you please,
# but please keep this comment chunk intact.
# List all repositories to be indexed.
# ["full URL to repository", "title (blue link)", "subtitle", "long description"],
_repositories = [
["http://svn.example.com/example", "/example", "My Example Project", ""],
["http://svn.example.com/another", "/ANoThER", "Another example project", ""],
]
# Path of file to write static HTML. Python must have write permissions.
# File will be overwritten.
_path_to_html = "/home/www/index.html"
# Number of revisions of commit log to show
_default_num_revisions = 3
# Format of timestamp to be inserted at %(timestamp)s in templates
_timestamp_format = "Generated on %m/%d/%Y at %I:%M:%S %p (%Z)"
# HTML code for the page. Use keyword %(timestamp)s for timestamp
# Use keyword %(entries)s for generated
structure of repositories
# Note: literal "%" must be escaped as "%%"
_page = """
Repositories
example's svn repositories:
"""
# HTML code for each entry in the repository list. Keywords are:
# %(link)s, %(lname)s, %(title)s, %(desc)s, %(numrevs)s, and %(svnlog)s
_entry = """
%(lname)s -- %(title)s
%(desc)s
last %(numrevs)s revisions:
%(svnlog)s
"""
#####################################################################
### DON'T EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE DOING ###
#####################################################################
import time
import commands
entries = ""
for repo in _repositories:
log = commands.getoutput("svn log -l %d %s"%(_default_num_revisions, repo[0]))
log = log.replace('\n', "
")
entries = entries + _entry%{
'link':repo[0],
'lname':repo[1],
'title':repo[2],
'desc':repo[3],
'numrevs':_default_num_revisions,
'svnlog':log }
out = _page%{'timestamp':time.strftime(_timestamp_format), 'entries':entries}
f = open(_path_to_html, 'w')
f.write(out)
f.close()