Improve navbar, unfinished dropdown support
This commit is contained in:
parent
aef5528bb0
commit
6c06865726
@ -10,6 +10,7 @@ def generateNavigationBar(lines, pagetitle):
|
|||||||
navbar = E
|
navbar = E
|
||||||
rawhtml = False
|
rawhtml = False
|
||||||
htmlstring = ""
|
htmlstring = ""
|
||||||
|
dropdown = False
|
||||||
for id, line in enumerate(lines):
|
for id, line in enumerate(lines):
|
||||||
|
|
||||||
#parse raw HTML
|
#parse raw HTML
|
||||||
@ -25,27 +26,38 @@ def generateNavigationBar(lines, pagetitle):
|
|||||||
# contents.append(line.split("|"))
|
# contents.append(line.split("|"))
|
||||||
#else:
|
#else:
|
||||||
# contents.append(line)
|
# contents.append(line)
|
||||||
|
|
||||||
#for entry in contents:
|
#for entry in contents:
|
||||||
title, link = line.split(";", 1)
|
title, link = line.split(";", 1)
|
||||||
|
|
||||||
|
if line.strip().endswith("|"):
|
||||||
|
dropdown = True
|
||||||
|
line = line.strip()[-1]
|
||||||
|
dphtml = E
|
||||||
|
dphtml = dphtml(HTML("<div class='dropdown'><button class 'dropbutton'>Test more</button><div class='dropdown-content'>"))
|
||||||
|
elif dropdown:
|
||||||
|
if line.startswith(" "):
|
||||||
|
print("todo")
|
||||||
|
dphtml = dphtml(HTML("<a href='" + link.strip() + "'>" + title + "</a>"))
|
||||||
|
#TODO if this is the last line, detect it by getting the future of lines[id + 1]
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
dphtml = dphtml(HTML("</div></div>"))
|
||||||
|
navbar = navbar.li(dphtml)
|
||||||
|
dropdown = False
|
||||||
#mark currently open tab as active when it is open
|
#mark currently open tab as active when it is open
|
||||||
if link.strip() == pagetitle + ".page":
|
if link.strip() == pagetitle + ".page":
|
||||||
navbar = navbar(HTML("<div class='" + "active" + "'>"))
|
|
||||||
link = "#"
|
link = "#"
|
||||||
elif link.strip() == homepage + ".page":
|
elif link.strip() == homepage + ".page":
|
||||||
link = "/"
|
link = "/"
|
||||||
else:
|
else:
|
||||||
link = link.replace(" ", "-").replace(".page", "").lower()
|
link = link.replace(" ", "-").replace(".page", "").lower()
|
||||||
|
|
||||||
#div class for styling
|
#currently open tab in navbar
|
||||||
navbar = navbar(HTML("<div class='" + title.replace(" ", "-").lower() + "'>"))
|
|
||||||
|
|
||||||
#link and end of div
|
|
||||||
if link == "#":
|
if link == "#":
|
||||||
navbar = navbar.li(HTML("<a href='" + link.strip() + "'>" + title + "</a></div></div>"))
|
navbar = navbar.li(HTML("<div class='active'>" + "<a href='" + link.strip() + "'>" + title + "</a></div>"))
|
||||||
else:
|
else:
|
||||||
navbar = navbar.li(HTML("<a href='" + link.strip() + "'>" + title + "</a></div>"))
|
navbar = navbar.li(HTML("<a href='" + link.strip() + "'>" + title + "</a>"))
|
||||||
|
print(navbar)
|
||||||
else:
|
else:
|
||||||
print("Error: invalid navbar entry, line " + str(id + 1) + " content: " + line)
|
print("Error: invalid navbar entry, line " + str(id + 1) + " content: " + line)
|
||||||
exit()
|
exit()
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
About;About.page
|
About;About.page
|
||||||
Home;Home.page
|
Home;Home.page
|
||||||
|
More;#|
|
||||||
|
Site 1;https://duckduckgo.com
|
||||||
|
Site 2;https://duckduckgo.com
|
||||||
|
Site 3;https://duckduckgo.com
|
||||||
|
Test;/test
|
||||||
|
Loading…
Reference in New Issue
Block a user