Sun Nov 13 11:23:24 UTC 2011 pinterface * Add support for calling an external program to generate README markup diff -rN -u old-darcsweb/config.py.sample new-darcsweb/config.py.sample --- old-darcsweb/config.py.sample 2014-09-11 07:38:44.000000000 +0000 +++ new-darcsweb/config.py.sample 2014-09-11 07:38:44.000000000 +0000 @@ -84,6 +84,10 @@ # option. #disable_annotate = True + # If you'd like a wider range of README file types than darcsweb + # provides, set readme_converter to a program which takes a single + # argument--the name of the readme file--and outputs HTML. + #readme_converter = 'ruby -rubygems /var/lib/gems/1.8/gems/github-markup-0.5.3/bin/github-markup' # diff -rN -u old-darcsweb/darcsweb.cgi new-darcsweb/darcsweb.cgi --- old-darcsweb/darcsweb.cgi 2014-09-11 07:38:44.000000000 +0000 +++ new-darcsweb/darcsweb.cgi 2014-09-11 07:38:44.000000000 +0000 @@ -1091,6 +1091,29 @@ return parse_annotate(run_darcs(cmd)) +def get_readme(): + import glob + readmes = glob.glob("README*") + if len(readmes) == 0: return False, False + import re + for p in readmes: + file = os.path.basename(p) + if re.search('\.(md|markdown)$', p): + import codecs + import markdown + f = codecs.open(p, encoding=config.repoencoding[0]) + str = f.read() + html = markdown.markdown(str, ['extra', 'codehilite(css_class=page_body)']) + return file, fixu8(html) + elif re.search('README$', p): + f = open(p) + str = f.read() + return file, '
%s
' % fixu8(escape(str)) + # We can't handle this ourselves, try shelling out + if not config.readme_converter: return False, False + cmd = '%s "%s"' % (config.readme_converter, readmes[0]) + inf, outf = os.popen2(cmd, 't') + return os.path.basename(readmes[0]), fixu8(outf.read()) # @@ -1222,30 +1245,11 @@ print "" -# FIXME: shell out to github-markup to avoid duplicating that effort here? def print_readme(): - real = False - for p in ["README", "README.md", "README.markdown"]: - p = realpath(p) - if p and os.path.isfile(p): - real = p - break - if not real: return - - print '
%s
' % os.path.basename(real) - - import re - if re.search('\.(md|markdown)$', real): - import codecs - import markdown - f = codecs.open(real, encoding=config.repoencoding[0]) - str = f.read() - html = markdown.markdown(str, ['extra', 'codehilite(css_class=page_body)']) - print '
%s
' % fixu8(html) - else: - f = open(real) - str = f.read() - print '
%s
' % fixu8(escape(str)) + head, body = get_readme() + if not head: return False + print '
%s
' % head + print '
%s