From 459fa8f48a8d91fe2ed7eb15b093c3346d17d129 Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 27 Aug 2021 03:08:43 +0100 Subject: new article, added background --- build.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) (limited to 'build.py') diff --git a/build.py b/build.py index 5e9a0c3..815a759 100644 --- a/build.py +++ b/build.py @@ -11,6 +11,21 @@ def getTemplateHTML(name): html = file.read(); return html +def lowerHeadings(html): + # This is a dumb lol + return html.replace("
", "

")\ + .replace("

", "

")\ + .replace("
", "
")\ + .replace("
", "")\ + .replace("

", "

")\ + .replace("
", "")\ + .replace("

", "

")\ + .replace("

", "")\ + .replace("

", "

")\ + .replace("

", "")\ + .replace("

", "

")\ + .replace("

", "")\ + def listPages(): return [ (lambda path: @@ -19,7 +34,8 @@ def listPages(): (lambda name: { "source_file" : path, "source_content" : content, - "html" : markdown.markdown(content), + "html" : markdown.markdown("\n".join(content.split("\n...\n"))), + "summary" : lowerHeadings(markdown.markdown(content.split("\n...\n")[0])), "timestamp" : timestamp, "date": time.strftime(date_format, time.localtime(timestamp)), "name" : name, @@ -30,6 +46,7 @@ def listPages(): )(os.path.join(source, p)) for p in os.listdir(source) ] + def formatEntry(content, page): return content.replace("%date%", page["date"])\ .replace("%name%", page["name"])\ @@ -52,16 +69,16 @@ def make(): summary_templ = getTemplateHTML("summary.html") - summariesHTML = "\n".join( - [ - formatEntry(summary_templ, page) - .replace( - "%content%", - "\n".join(page["html"].split("\n")[:summary_max]) - ) + summariesHTML = getTemplateHTML("about.html") + "\n
\n"+ "\n
\n".join( + [ + formatEntry(summary_templ, page) + .replace( + "%content%", + page["summary"] + (f"read more..." if len(page["source_content"].split("\n...\n")) > 1 else "") + ) - for page in pages - ] + for page in pages + ][: : -1] ) entry_templ = getTemplateHTML("page.html") @@ -78,11 +95,11 @@ def make(): - index_templ = getTemplateHTML("index.html") + index_templ = getTemplateHTML("page.html") with open(os.path.join(dist, "index.html"), "w") as index: index.write( - index_templ.replace("%entries%", summariesHTML) + index_templ.replace("%content%", summariesHTML) ) -- cgit v1.2.1