about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2021-10-21 19:57:02 -0500
committerStarfall <us@starfall.systems>2023-12-05 10:00:06 -0600
commit98f2902f6e880c756eff5046c0ee9bfaf889c102 (patch)
treefb48fb7d028d4edb267f9a905f4b94ba7df1c346
parente1cefc4d17cd0f1983e7f5106f4003fb6b2a9591 (diff)
strike: simple example of fstring template
-rw-r--r--.gitignore1
-rw-r--r--README13
-rw-r--r--blog/1.rst1
-rw-r--r--blog/empty.rst0
-rwxr-xr-xstrike.py29
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())