2018-04-07 04:17:49 +02:00
|
|
|
#!/home/subnixr/.virtualenvs/ciclostile/bin/python3
|
2017-10-30 20:58:15 +01:00
|
|
|
import os
|
2018-02-22 16:43:12 +01:00
|
|
|
import ciclostile
|
2017-10-30 20:58:15 +01:00
|
|
|
|
|
|
|
|
2018-02-22 16:43:12 +01:00
|
|
|
working_dir = os.getcwd()
|
2017-10-30 20:58:15 +01:00
|
|
|
|
2018-02-22 16:43:12 +01:00
|
|
|
target_path, template_path, markdown_path = [
|
|
|
|
os.path.join(working_dir, folder_name)
|
|
|
|
for folder_name in ['target', 'templates', 'markdown']
|
|
|
|
]
|
2017-10-30 20:58:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
def valid_md(md_file):
|
2018-02-22 16:43:12 +01:00
|
|
|
full_name = os.path.join(markdown_path, md_file)
|
2017-10-30 20:58:15 +01:00
|
|
|
return os.path.isfile(full_name) and full_name.endswith('.md')
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2018-02-22 16:43:12 +01:00
|
|
|
for md_file in os.listdir(markdown_path):
|
2017-10-30 20:58:15 +01:00
|
|
|
if valid_md(md_file):
|
2018-02-22 16:43:12 +01:00
|
|
|
page_name = os.path.splitext(md_file)[0]
|
|
|
|
page = ciclostile.render(page_name, markdown_path, template_path)
|
|
|
|
|
|
|
|
out_path = os.path.join(target_path, page_name + '.html')
|
|
|
|
with open(out_path, 'w') as f:
|
|
|
|
f.write(page)
|
2017-10-30 20:58:15 +01:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|