Add jump to top links & tooltips
This commit is contained in:
parent
bcd897f4e1
commit
a60f072900
|
@ -407,6 +407,14 @@ def write_block(out, block):
|
|||
for child in block.children:
|
||||
write_block(out, child)
|
||||
|
||||
def anchor_toc(out):
|
||||
with out.pair_tag("a", href="#table-of-contents", clazz="permalink small", title="Jump to top"):
|
||||
out.empty_pair_tag("i", clazz="bi bi-list-ul")
|
||||
|
||||
def permalink(out, link):
|
||||
with out.pair_tag("a", href=link, clazz="permalink small", title="Permalink"):
|
||||
out.empty_pair_tag("i", clazz="bi bi-link-45deg")
|
||||
|
||||
# TODO modularize
|
||||
def write_page(out, pageid, page):
|
||||
if "anchor" in page:
|
||||
|
@ -418,8 +426,7 @@ def write_page(out, pageid, page):
|
|||
with out.pair_tag("h4"):
|
||||
out.text(page.get("header", page.get("title", None)))
|
||||
if anchor_id:
|
||||
with out.pair_tag("a", href="#" + anchor_id, clazz="permalink small"):
|
||||
out.empty_pair_tag("i", clazz="bi bi-link-45deg")
|
||||
permalink(out, "#" + anchor_id)
|
||||
|
||||
ty = page["type"]
|
||||
if ty == "patchouli:text":
|
||||
|
@ -475,8 +482,7 @@ def write_page(out, pageid, page):
|
|||
suffix = f" ({pipe})" if inp or oup else ""
|
||||
out.text(f"{page['name']}{suffix}")
|
||||
if anchor_id:
|
||||
with out.pair_tag("a", href="#" + anchor_id, clazz="permalink small"):
|
||||
out.empty_pair_tag("i", clazz="bi bi-link-45deg")
|
||||
permalink(out, "#" + anchor_id)
|
||||
with out.pair_tag("details", clazz="spell-collapsible"):
|
||||
out.empty_pair_tag("summary", clazz="collapse-spell")
|
||||
for string, start_angle, per_world in page["op"]:
|
||||
|
@ -495,8 +501,8 @@ def write_entry(out, book, entry):
|
|||
with out.pair_tag_if(entry_spoilered(book, entry), "div", clazz="spoilered"):
|
||||
with out.pair_tag("h3", clazz="entry-title page-header"):
|
||||
write_block(out, entry["name"])
|
||||
with out.pair_tag("a", href="#" + entry["id"], clazz="permalink small"):
|
||||
out.empty_pair_tag("i", clazz="bi bi-link-45deg")
|
||||
permalink(out, "#" + entry["id"])
|
||||
anchor_toc(out)
|
||||
for page in entry["pages"]:
|
||||
write_page(out, entry["id"], page)
|
||||
|
||||
|
@ -505,8 +511,8 @@ def write_category(out, book, category):
|
|||
with out.pair_tag_if(category_spoilered(book, category), "div", clazz="spoilered"):
|
||||
with out.pair_tag("h2", clazz="category-title page-header"):
|
||||
write_block(out, category["name"])
|
||||
with out.pair_tag("a", href="#" + category["id"], clazz="permalink small"):
|
||||
out.empty_pair_tag("i", clazz="bi bi-link-45deg")
|
||||
permalink(out, "#" + category["id"])
|
||||
anchor_toc(out)
|
||||
write_block(out, category["description"])
|
||||
for entry in category["entries"]:
|
||||
if entry["id"] not in book["blacklist"]:
|
||||
|
@ -517,8 +523,7 @@ def write_toc(out, book):
|
|||
out.text("Table of Contents")
|
||||
with out.pair_tag("a", href="javascript:void(0)", clazz="toggle-link small", data_target="toc-category"):
|
||||
out.text("(toggle all)")
|
||||
with out.pair_tag("a", href="#table-of-contents", clazz="permalink small"):
|
||||
out.empty_pair_tag("i", clazz="bi bi-link-45deg")
|
||||
permalink(out, "#table-of-contents")
|
||||
for category in book["categories"]:
|
||||
with out.pair_tag("details", clazz="toc-category"):
|
||||
with out.pair_tag("summary"):
|
||||
|
|
Loading…
Reference in a new issue