45 lines
1.0 KiB
Python
45 lines
1.0 KiB
Python
|
#!/usr/bin/python3
|
||
|
|
||
|
from sys import argv, exit
|
||
|
from os import walk, path
|
||
|
import time, urllib.parse
|
||
|
|
||
|
from article_utils import parse_metadata, MONTHS
|
||
|
|
||
|
if len(argv) <= 1:
|
||
|
print("No directory was supplied")
|
||
|
exit(-1)
|
||
|
|
||
|
page = """Title: mjestečko
|
||
|
CSS: /style.css
|
||
|
|
||
|
<div class="container">
|
||
|
|
||
|
# mjestečko #
|
||
|
|
||
|
Personal blog of one Veclav Talica.
|
||
|
|
||
|
### Articles ###
|
||
|
|
||
|
"""
|
||
|
|
||
|
# todo: Sort by date first.
|
||
|
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"""
|
||
|
|
||
|
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}*
|
||
|
|
||
|
</div>
|
||
|
"""
|
||
|
|
||
|
print(page)
|