Setup file browsing
This commit is contained in:
parent
04e73e4d10
commit
3bbbd8e23e
17
generate.py
17
generate.py
|
@ -27,10 +27,13 @@ for root, dirs, files in os.walk(input_, topdown=True):
|
||||||
|
|
||||||
shutil.copy(templates + '/stylesheet.css', outroot + '/stylesheet.css')
|
shutil.copy(templates + '/stylesheet.css', outroot + '/stylesheet.css')
|
||||||
|
|
||||||
|
outfiles = []
|
||||||
|
|
||||||
for file in files:
|
for file in files:
|
||||||
if file.endswith('.md'):
|
if file.endswith('.md'):
|
||||||
basename = file[:-3]
|
basename = file[:-3]
|
||||||
outfile = outroot + '/' + basename + '.html'
|
outfile = outroot + '/' + basename + '.html'
|
||||||
|
outfiles.append(basename + '.html')
|
||||||
infile = root + '/' + file
|
infile = root + '/' + file
|
||||||
|
|
||||||
with open(infile, 'r') as f:
|
with open(infile, 'r') as f:
|
||||||
|
@ -43,3 +46,17 @@ for root, dirs, files in os.walk(input_, topdown=True):
|
||||||
content=content)
|
content=content)
|
||||||
|
|
||||||
f.write(new_file)
|
f.write(new_file)
|
||||||
|
|
||||||
|
index_html = '<ul>'
|
||||||
|
|
||||||
|
for directory in dirs:
|
||||||
|
index_html += '<li><a href="%s">%s</a></li>' % (directory + '/index.html', directory.replace('_', ' '))
|
||||||
|
|
||||||
|
for file in outfiles:
|
||||||
|
index_html += '<li><a href="%s">%s</a></li>' % (file, file.removesuffix('.html').replace('_', ' '))
|
||||||
|
|
||||||
|
index_html += '</ul>'
|
||||||
|
|
||||||
|
with open(outroot + '/index.html', 'w') as f:
|
||||||
|
f.write(render_template(title=outroot,
|
||||||
|
content=index_html))
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
body {
|
body {
|
||||||
background-color: blue
|
background-color: yellow
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue