diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | README | 13 | ||||
-rw-r--r-- | blog/1.rst | 1 | ||||
-rw-r--r-- | blog/empty.rst | 0 | ||||
-rwxr-xr-x | strike.py | 29 |
5 files changed, 40 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..53752db --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +output diff --git a/README b/README index b6f2c67..d6a2041 100644 --- a/README +++ b/README @@ -15,13 +15,18 @@ Strike has simple goals: 3. Add boilerplate (head, header, footer, etc) 4. Save to output folder -One slight gotcha: - * May need to fill out several different locations in the template (e.g. page title and page content) - And some stretch goals to turn it into a blog generator: * Create an extra page listing all generated pages in order of creation date (newest first) * Add links to next & previous generated pages * Turn the extra page into a flexible component that can be added into any other page -reStructuredText fulfills most of our desires for markup: https://docutils.sourceforge.io/rst.html +Markup: +reStructuredText fulfills most of our desires: https://docutils.sourceforge.io/rst.html It generates <section>s and has specific markup for page titles. + +Templating: +Complicated templating isn't necessary, just pre-content and post-content boilerplate for now. +The slight gotcha is that the page title may need updated as well, but we'll cross that bridge if we have to. + +Front matter: +None for now. diff --git a/blog/1.rst b/blog/1.rst new file mode 100644 index 0000000..9e10db3 --- /dev/null +++ b/blog/1.rst @@ -0,0 +1 @@ +this is our first file alsfdgjl diff --git a/blog/empty.rst b/blog/empty.rst new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/blog/empty.rst diff --git a/strike.py b/strike.py new file mode 100755 index 0000000..3ca1e19 --- /dev/null +++ b/strike.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +from os import listdir, mkdir +from sys import exit +from inspect import cleandoc + +def get_output(content): + return cleandoc(f''' + i am a template + with some stuff, + {content}, + and some more stuff + ''') + +def main(): + src = 'blog' + dest = 'output' + + try: mkdir(dest) + except FileExistsError: pass + + for file in listdir(src): + with open(src + '/' + file, 'r') as fin: + file_contents = fin.read() + output = get_output(file_contents) + with open(dest + '/' + file, 'w') as fout: + fout.write(output) + +if __name__ == '__main__': + exit(main()) |