From f46588afc371c98167e42d783b6377cf536eade5 Mon Sep 17 00:00:00 2001 From: Govindas Date: Mon, 31 Jan 2022 12:11:51 +0200 Subject: [PATCH] Experimental footer, identical to navbar --- gsitegen/footer | 1 + gsitegen/generate.py | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 gsitegen/footer diff --git a/gsitegen/footer b/gsitegen/footer new file mode 100644 index 0000000..8b8564c --- /dev/null +++ b/gsitegen/footer @@ -0,0 +1 @@ +[Privacy Policy](/privacy-policy) diff --git a/gsitegen/generate.py b/gsitegen/generate.py index f496835..c21d076 100644 --- a/gsitegen/generate.py +++ b/gsitegen/generate.py @@ -19,6 +19,20 @@ def generateNavigationBar(lines): if not rawhtml: navbar = navbar.li(HTML(parseMarkdown(navbar, line))) +def generateFooter(lines): + global footer + footer = E + rawhtml = False + htmlstring = "" + for id, line in enumerate(lines): + + #parse raw HTML + rawhtml, footer, htmlstring = parseRawHTML(footer, line, htmlstring, rawhtml, id, len(lines)) + + #parse markdown + if not rawhtml: + footer = footer.li(HTML(parseMarkdown(footer, line))) + def parseRawHTML(doc, line, htmlstring, rawhtml, id, maxlines): #raw html start @@ -68,16 +82,21 @@ def generateLines(title, lines): def generatePage(title, doc): global pages global titles - if 'pages' not in globals(): pages = [] if 'titles' not in globals(): titles = [] if 'navbar' in globals(): - pages.append(str(E.ul(navbar)) + str(doc)) + if 'footer' in globals(): + pages.append(str(E.ul(navbar)) + str(doc) + str(E.ul(footer))) + else: + pages.append(str(E.ul(navbar)) + str(doc)) else: - pages.append(str(doc)) + if 'footer' in globals(): + pages.append(str(doc) + str(E.ul(footer))) + else: + pages.append(str(doc)) titles.append(title) def writePages(homepage): @@ -126,6 +145,14 @@ def main(): else: print("No 'navbar' file found, there will be no navigation bar.") + footerfile = Path(__file__).parent.joinpath('footer') + + if footerfile.exists(): + with footerfile.open('r') as footerfile: + generateFooter(footerfile.readlines()) + else: + print("No 'footer' file found, there will be no footer.") + pagescount = 0 for file in Path(__file__).parent.iterdir():