#!/usr/bin/env python3 import asyncio import os import markdown async def main() -> int: open("/tmp/blog.md", "w").close() blog_title = input("Blog title: ") input( "Now this script will open your editor, enter the markdown you want in your blog there. press enter to continue" ) if os.getenv("EDITOR"): os.system(f"{os.getenv('EDITOR')} /tmp/blog.md") else: os.system(f"{input('What editor should I use?: ')} /tmp/blog.md") with open("/tmp/blog.md", "r") as f: blog_content = f.read() content = """# %s [back](..) | [home](/) | [git](//github.com/TruncatedDinosour/website)
%s""" % ( blog_title, blog_content, ) with open( f"./page/blog/blogs/{blog_title.replace(' ', '-').replace('/', '_')}.html", "w" ) as f: f.write(""" Ari::web -> blog
%s
""" % markdown.markdown(content)) with open("./page/blog/index.md", "a") as f: f.write( f"\n* [{blog_title}](/page/blog/blogs/{blog_title.replace(' ', '-').replace('/', '_')}.html)" ) with open("./page/blog/index.html", "w") as f: with open("./page/blog/index.md", "r") as md: f.write( """ Ari::web -> blog

My blogs

%s
""" % markdown.markdown(md.read()) ) return 0 if __name__ == "__main__": assert main.__annotations__.get("return") is int, "main() should return an integer" exit(asyncio.run(main()))