From f4de85917253f882fb184dbab35b293fc966f526 Mon Sep 17 00:00:00 2001 From: Govindas Date: Mon, 7 Feb 2022 14:18:31 +0200 Subject: [PATCH] Finish dropdown in navbar --- example/More.page | 3 ++ example/navbar | 4 ++ example/resources/About/test.txt | 0 example/resources/style.css | 54 ++++++++++++++++++++++- gsitegen/generate.py | 74 +++++++++++++++++++------------- gsitegen/navbar | 5 +-- 6 files changed, 105 insertions(+), 35 deletions(-) create mode 100644 example/More.page delete mode 100644 example/resources/About/test.txt diff --git a/example/More.page b/example/More.page new file mode 100644 index 0000000..59e7219 --- /dev/null +++ b/example/More.page @@ -0,0 +1,3 @@ +> + +**This is More page.** diff --git a/example/navbar b/example/navbar index f13db9e..71baa1c 100644 --- a/example/navbar +++ b/example/navbar @@ -1,2 +1,6 @@ About;About.page Home;Home.page +More;More.page| + About;About.page + Site 2;https://duckduckgo.com + Site 3;https://duckduckgo.com diff --git a/example/resources/About/test.txt b/example/resources/About/test.txt deleted file mode 100644 index e69de29..0000000 diff --git a/example/resources/style.css b/example/resources/style.css index 6c88f2d..e549117 100644 --- a/example/resources/style.css +++ b/example/resources/style.css @@ -30,6 +30,58 @@ li a { font-size: 3.0vmax; } } -.active li a { +.active { background-color: #04AA6D; } +/* Dropdown button */ +.dropdown .dropbutton { + display: block; + border: none; + color: white; + text-align: center; + padding: 15px 35px; + text-decoration: none; + font-size: 3.0vmin; + background-color: inherit; +} +@media only screen and (max-width: 1000px) { + .dropdown .dropbutton { + border: none; + display: block; + color: white; + + text-align: center; + padding: 15px 35px; + text-decoration: none; + font-size: 3.0vmax; + background-color: inherit; + } +} +/* Dropdown content (hidden by default) */ +.dropdown-content { + display: none; + position: absolute; + background-color: #333; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); + z-index: 1; +} +/* Links inside the dropdown */ +.dropdown-content a { + float: none; + color: white; + padding: 12px 16px; + text-decoration: none; + display: block; + text-align: left; +} + +/* Add a grey background color to dropdown links on hover */ +.dropdown-content a:hover { + background-color: #ddd; +} + +/* Show the dropdown menu on hover */ +.dropdown:hover .dropdown-content { + display: block; +} diff --git a/gsitegen/generate.py b/gsitegen/generate.py index c6088b8..54777ae 100644 --- a/gsitegen/generate.py +++ b/gsitegen/generate.py @@ -4,7 +4,19 @@ import markdown import html from pathlib import Path -#TODO re-think navigation bar. Think of way to add option to display navigation bar entry differently if you're currently on that page. +def parseLink(link, pagetitle, homepage): + if link.strip() == pagetitle + ".page": + return "#" + elif link.strip() == homepage + ".page": + return "/" + else: + destination = link.replace(" ", "-").replace(".page", "").lower() + + #Start local links with / symbol + if link.strip().endswith(".page"): + return "/" + destination + return destination + def generateNavigationBar(lines, pagetitle): global navbar navbar = E @@ -19,49 +31,49 @@ def generateNavigationBar(lines, pagetitle): #parse navigation bar (custom format) if not rawhtml: if ";" in line: - - #experimental dropdown parsing, to be removed or used soon - #contents = [] - #if "|" in line: - # contents.append(line.split("|")) - #else: - # contents.append(line) - #for entry in contents: title, link = line.split(";", 1) if line.strip().endswith("|"): dropdown = True - line = line.strip()[-1] + link = link.strip()[:len(link.strip())-1] dphtml = E - dphtml = dphtml(HTML("