diff options
Diffstat (limited to 'src/pyssg/file_structure.py')
-rw-r--r-- | src/pyssg/file_structure.py | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/pyssg/file_structure.py b/src/pyssg/file_structure.py new file mode 100644 index 0000000..f349fed --- /dev/null +++ b/src/pyssg/file_structure.py @@ -0,0 +1,76 @@ +import os + + +def create_structure(directory: str): + # get initial working directory + iwd = os.getcwd() + + # create main dir + os.mkdir(directory) + os.chdir(directory) + + # create templates dir + os.mkdir('templates') + os.chdir('templates') + + # create article (blog) barebones template + os.mkdir('article') + with open('article/header.html', 'w+') as f: + f.write('<!DOCTYPE html>\n') + f.write('<html lang=$$LANG>\n') + f.write('<head>\n') + f.write('<meta charset="utf-8">\n') + f.write('<title>$$TITLE</title>\n') + f.write('$$EXTRAHEAD\n') + f.write('</head>\n') + f.write('<body>\n') + + with open('article/footer.html', 'w+') as f: + f.write('</body>\n') + f.write('</html>\n') + + with open('article/index_header.html', 'w+') as f: + f.write('') + + with open('article/tag_list_header.html', 'w+') as f: + f.write('<p>Tags:') + + with open('article/tag_entry.html', 'w+') as f: + f.write('<a href="$$URL">$$NAME</a>') + + with open('article/tag_separator.html', 'w+') as f: + f.write(', ') + + with open('article/tag_list_footer.html', 'w+') as f: + f.write('</p>\n') + + with open('article/article_list_header.html', 'w+') as f: + f.write('<h2>Articles</h2>\n') + f.write('<ul>\n') + + with open('article/article_entry.html', 'w+') as f: + f.write('<li><a href="$$URL">$$DATE $$TITLE</a></li>\n') + + with open('article/article_separator.html', 'w+') as f: + f.write('') + + with open('article/article_list_footer.html', 'w+') as f: + f.write('</ul>\n') + + with open('article/index_footer.html', 'w+') as f: + f.write('') + + with open('article/tag_index_header.html', 'w+') as f: + f.write('') + + with open('article/tag_index_footer.html', 'w+') as f: + f.write('') + + with open('article/article_header.html', 'w+') as f: + f.write('<h1>$$TITLE</h1>') + + with open('article/article_footer.html', 'w+') as f: + f.write('') + + # return to initial working directory + os.chdir(iwd) |