hello world
[wrigit.git] / wrigit.cgi
blob94c00d36eafcbdb82eba9c752fc7c918ae1dc117
1 #!/usr/bin/env python
2 # -*- mode: python -*-
4 from glob import glob
5 from docutils import core
8 def rst2html(rst_path):
9 """
10 Convert the file `rst_path` to embedable html string
11 (containing no <body> tags)
12 """
13 parts = core.publish_parts(
14 source=open(rst_path).read(),
15 source_path=rst_path, writer_name='html')
16 return parts['title'], parts['html_body']
19 if __name__ == '__main__':
20 FILES = 'example/blog/*.rst'
21 for f in glob(FILES):
22 title, body = rst2html(f)
23 print '>', f
24 open(f+'.html', 'w').write(r'''
25 <html>
26 <title>%(title)s</title>
27 <body>
28 <div style="float: right; background-color: gray; border: 1px solid;">
29 Sidebar here
30 </div>
31 %(body)s
32 <div style="text-align: center; color: gray; font-size: 10pt; margin-top: 1px dotted;">Copyright (c) Foo Bar</div>
33 </body>
34 ''' % locals())