From ba8327c1618d92d54eb49043a31d46125cfbf5e5 Mon Sep 17 00:00:00 2001 From: veclav talica Date: Thu, 25 May 2023 21:58:10 +0500 Subject: [PATCH] opengraph article integration --- compile.sh | 2 +- tools/article_wrapper.py | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/compile.sh b/compile.sh index 1e11eb8..b53baf8 100755 --- a/compile.sh +++ b/compile.sh @@ -15,7 +15,7 @@ for d in ./articles/*/; do mkdir -p "./html/articles/$(basename -- $d)" cp -r "$d/.dynamic/." "./html/articles/$(basename -- $d)/" fi - ./tools/article_wrapper.py "$d/page.mmd" | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html" + ./tools/article_wrapper.py "$d/page.mmd" https://mjestecko.neocities.org/ | ./tools/mmd/build/multimarkdown > "./html/articles/$(basename -- $d).html" fi done diff --git a/tools/article_wrapper.py b/tools/article_wrapper.py index 2522a9a..3b7050f 100755 --- a/tools/article_wrapper.py +++ b/tools/article_wrapper.py @@ -3,7 +3,7 @@ # todo: Show related git history of a file? from sys import argv, exit -import time +import time, urllib.parse from article_utils import the_line_after_metadata, parse_metadata from page_shares import wrap_page, MONTHS @@ -12,6 +12,10 @@ if len(argv) <= 1: print("No file was supplied") exit(-1) +if len(argv) <= 2: + print("No address was supplied") + exit(-1) + with open(argv[1], "r") as f: content = f.readlines() i = the_line_after_metadata(content) @@ -42,4 +46,12 @@ if tags: article_head += "---\n\n" -print(''.join(content[:i]) + wrap_page(article_head + ''.join(content[i:]))) +# todo: Article namespace with related metadata. +header = f"""HTML header: + + +""" +if not brief is None: + header += f"""\n""" + +print(header + ''.join(content[:i]) + wrap_page(article_head + ''.join(content[i:])))