diff --git a/tools/article_utils.py b/tools/article_utils.py
index 9903852..f876153 100644
--- a/tools/article_utils.py
+++ b/tools/article_utils.py
@@ -31,11 +31,11 @@ def parse_metadata(filepath: str) -> {}:
delim = line.find(":")
key, val = (line[:delim].strip(), line[delim+1:].strip())
if key == "Date":
- result["date"] = time.gmtime(int(val))
+ result["Date"] = time.gmtime(int(val))
elif key == "Tags":
- result["tags"] = val.split(",")
+ result["Tags"] = val.split(",")
else:
- result[key.lower()] = val
- result["last_edit"] = time.gmtime(int(subprocess.getoutput(r"stat -c %Y " + filepath)))
+ result[key] = val
+ result["Last Edit"] = time.gmtime(int(subprocess.getoutput(r"stat -c %Y " + filepath)))
return result
diff --git a/tools/article_wrapper.py b/tools/article_wrapper.py
index e29544b..85ed8c3 100755
--- a/tools/article_wrapper.py
+++ b/tools/article_wrapper.py
@@ -6,6 +6,7 @@ from sys import argv, exit
import time
from article_utils import the_line_after_metadata, parse_metadata, MONTHS
+from page_shares import wrap_page
if len(argv) <= 1:
print("No file was supplied")
@@ -17,57 +18,28 @@ with open(argv[1], "r") as f:
metadata = parse_metadata(argv[1])
-HEAD_EMBED = """
-
+title = metadata.get("Title", "Oopsie, somebody forgot to name the article!")
+article_head = "\n# " + title + "\n---\n"
-
-
-## mjestečko ##
-
-
-
-
-
-
-"""
-
-TAIL_EMBED = """
-
-"""
-
-title = metadata.get("title", "Oopsie, somebody forgot to name the article!")
-article_head = "\n# " + title + "\n" if title else \
- "# Oopsie, somebody forgot to give it a title!\n"
-
-brief = metadata.get("brief")
+brief = metadata.get("Brief")
if not brief is None:
- article_head += f"""
-*{brief}*
-"""
+ article_head += f"*{brief}*\n\n"
-date = metadata.get("date")
+date = metadata.get("Date")
if not date is None:
- article_head += f"""
--- Date: *{MONTHS[date.tm_mon]} {date.tm_mday}, {date.tm_year}*
-"""
+ article_head += f"-- Created: *{MONTHS[date.tm_mon]} {date.tm_mday}, {date.tm_year}*\n\n"
-last_edit = metadata.get("last_edit")
+last_edit = metadata.get("Last Edit")
if not last_edit is None:
if date is None or last_edit.tm_mon != date.tm_mon or \
last_edit.tm_mday != date.tm_mday or last_edit.tm_year != date.tm_year:
- article_head += f"""
--- Edit: *{MONTHS[last_edit.tm_mon]} {last_edit.tm_mday}, {last_edit.tm_year}*
-"""
+ article_head += f"-- Edited: *{MONTHS[last_edit.tm_mon]} {last_edit.tm_mday}, {last_edit.tm_year}*\n\n"
# todo: Hyperlinks to appropriate tag pages.
-tags = metadata.get("tags")
+tags = metadata.get("Tags")
if tags:
- article_head += f"""
--- Tags: *{",".join(tags)}*
-"""
+ article_head += f"""-- Tags: *{",".join(tags)}*\n\n"""
-print(''.join(content[:i]) + HEAD_EMBED + article_head + ''.join(content[i:]) + TAIL_EMBED)
+article_head += "---\n\n"
+
+print(''.join(content[:i]) + wrap_page(article_head + ''.join(content[i:])))
diff --git a/tools/main_page_generator.py b/tools/main_page_generator.py
index cb5cdaf..5bd0ef3 100755
--- a/tools/main_page_generator.py
+++ b/tools/main_page_generator.py
@@ -2,22 +2,26 @@
from sys import argv, exit
from os import walk, path
+from random import choice
import time, urllib.parse
from article_utils import parse_metadata, MONTHS
+from page_shares import wrap_page
if len(argv) <= 1:
print("No directory was supplied")
exit(-1)
-page = """Title: mjestečko
+page_metadata = """Title: mjestečko
CSS: /style.css
-
+"""
-# mjestečko #
+adjectives = ["*wild*", "**wacky**", "very humble", "**most serious**"]
-Personal blog of one Veclav Talica.
+page = f"""Personal blog of one {choice(adjectives)} Veclav Talica.
+
+---
### Articles ###
@@ -28,17 +32,14 @@ for root, dirs, _ in walk(argv[1]):
for d in dirs:
metadata = parse_metadata(path.abspath(root + '/' + d + "/page.mmd"))
article = urllib.parse.quote(d)
- page += f"""#### [{metadata.get("title", "No title given! What a clusterfuck!")}](/articles/{article}.html) ####\n"""
- page += f"""{metadata.get("brief", "")}\n\n"""
- if "tags" in metadata:
- page += f"""*{','.join(metadata["tags"])}*\n\n"""
+ page += (
+ f"""[{metadata.get("Title", "No title given! What a clusterfuck!")}](/articles/{article}.html)\n\n"""
+ f""">{metadata.get("Brief", "")}\n\n"""
+ )
+ if "Tags" in metadata:
+ page += f""">*{','.join(metadata["Tags"])}*\n---\n"""
curtime = time.gmtime(int(time.time()))
+page += f"Last compiled: *{MONTHS[curtime.tm_mon]} {curtime.tm_mday}, {curtime.tm_year} {curtime.tm_hour}:{curtime.tm_min:2}*\n\n"
-page += f"""
-Last compiled: *{MONTHS[curtime.tm_mon]} {curtime.tm_mday}, {curtime.tm_year} {curtime.tm_hour}:{curtime.tm_min}*
-
-
-"""
-
-print(page)
+print(page_metadata + wrap_page(page))
diff --git a/tools/page_shares.py b/tools/page_shares.py
new file mode 100644
index 0000000..dbf5142
--- /dev/null
+++ b/tools/page_shares.py
@@ -0,0 +1,30 @@
+
+HEAD_EMBED = """
+
+
+
+
+## mjestečko ##
+
+
+
+
+
+
+
+"""
+
+TAIL_EMBED = """
+---
+*Remember, - all you see here is free for use for any purpose whatsoever.*
+
+
+
+"""
+
+def wrap_page(page: str) -> str:
+ return HEAD_EMBED + page + TAIL_EMBED