From d8e6925f31554677e0f918b38eaaf37e3dc39a01 Mon Sep 17 00:00:00 2001 From: Score_Under Date: Wed, 7 Apr 2021 19:11:56 +0100 Subject: [PATCH] Add navigation consistency checking script --- public/gdb/biochemical-dysphoria.md | 1 + public/gdb/causes.md | 1 + public/gdb/chromosomes.md | 1 + public/gdb/conclusion.md | 1 + public/gdb/diagnoses.md | 1 + public/gdb/euphoria.md | 1 + public/gdb/historical-dysphoria.md | 1 + public/gdb/history.md | 1 + public/gdb/hormones.md | 1 + public/gdb/impostor-syndrome.md | 1 + public/gdb/managed-dysphoria.md | 1 + public/gdb/physical-dysphoria.md | 1 + public/gdb/presentational-dysphoria.md | 1 + public/gdb/sexual-dysphoria.md | 1 + public/gdb/social-dysphoria.md | 1 + public/gdb/societal-dysphoria.md | 1 + tools/navigation.py | 73 ++++++++++++++++++++++++++ 17 files changed, 89 insertions(+) create mode 100755 tools/navigation.py diff --git a/public/gdb/biochemical-dysphoria.md b/public/gdb/biochemical-dysphoria.md index 22900b1..006bed5 100644 --- a/public/gdb/biochemical-dysphoria.md +++ b/public/gdb/biochemical-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Biochemical Dysphoria" +linkTitle: "Biochemical Dysphoria" description: "The very real and biological factors of Gender Dysphoria that cause mental disturbance." preBody: '_disclaimer' classes: diff --git a/public/gdb/causes.md b/public/gdb/causes.md index a9ff34c..0da3ac7 100644 --- a/public/gdb/causes.md +++ b/public/gdb/causes.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "What is the Cause of Gender Incongruence" +linkTitle: "Causes of Gender Dysphoria" description: "It's the hormones, baby." preBody: '_disclaimer' classes: diff --git a/public/gdb/chromosomes.md b/public/gdb/chromosomes.md index 571fa23..37ff3b4 100644 --- a/public/gdb/chromosomes.md +++ b/public/gdb/chromosomes.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "Disorders of Sex Development: Gender is not Chromosomal" +linkTitle: "Chromosomes" description: "DNA is more what you'd call guidelines, than actual rules." preBody: '_disclaimer' classes: diff --git a/public/gdb/conclusion.md b/public/gdb/conclusion.md index 628bb8a..417bcfe 100644 --- a/public/gdb/conclusion.md +++ b/public/gdb/conclusion.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "In Conclusion" +linkTitle: "Conclusion" description: "Enough with the gatekeeping already." siblings: prev: /gdb/second-puberty-fem diff --git a/public/gdb/diagnoses.md b/public/gdb/diagnoses.md index 99426fd..5b59a14 100644 --- a/public/gdb/diagnoses.md +++ b/public/gdb/diagnoses.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "Diagnosing Gender Dysphoria" +linkTitle: "Clinical Diagnoses" description: "It's clinical." preBody: '_disclaimer' classes: diff --git a/public/gdb/euphoria.md b/public/gdb/euphoria.md index ee09781..d8619b4 100644 --- a/public/gdb/euphoria.md +++ b/public/gdb/euphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Euphoria" +linkTitle: "Gender Euphoria" description: "In order for there to be shadow there must be light." preBody: '_disclaimer' siblings: diff --git a/public/gdb/historical-dysphoria.md b/public/gdb/historical-dysphoria.md index dc4cee0..f297869 100644 --- a/public/gdb/historical-dysphoria.md +++ b/public/gdb/historical-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Existential Dysphoria" +linkTitle: "Existential Dysphoria" description: "I don't regret the things I have done, I regret the things I didn't do when I had the chance." classes: - gdb diff --git a/public/gdb/history.md b/public/gdb/history.md index a0cde98..63168e9 100644 --- a/public/gdb/history.md +++ b/public/gdb/history.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "A Brief History of Gender Dysphoria" +linkTitle: "The History of Gender Dysphoria" description: "The origins of Gender Dysphoria and the current meaning today." classes: - gdb diff --git a/public/gdb/hormones.md b/public/gdb/hormones.md index 7c91a8d..94094df 100644 --- a/public/gdb/hormones.md +++ b/public/gdb/hormones.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "Hormones: How do they work" +linkTitle: "How Hormones Work" description: "It's nothing like magnets." preBody: '_disclaimer' siblings: diff --git a/public/gdb/impostor-syndrome.md b/public/gdb/impostor-syndrome.md index 7dbc862..0de6a13 100644 --- a/public/gdb/impostor-syndrome.md +++ b/public/gdb/impostor-syndrome.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "Impostor Syndrome, but make it Trans" +linkTitle: "Impostor Syndrome" description: "Am I really trans?" preBody: '_disclaimer' siblings: diff --git a/public/gdb/managed-dysphoria.md b/public/gdb/managed-dysphoria.md index 5c05770..fe71dec 100644 --- a/public/gdb/managed-dysphoria.md +++ b/public/gdb/managed-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "Managed Dysphoria: Gender in Disguise" +linkTitle: "Managed Dysphoria" description: "I don't regret the things I have done, I regret the things I didn't do when I had the chance." preBody: '_disclaimer' siblings: diff --git a/public/gdb/physical-dysphoria.md b/public/gdb/physical-dysphoria.md index 71d9e72..3a095ba 100644 --- a/public/gdb/physical-dysphoria.md +++ b/public/gdb/physical-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Physical Dysphoria" +linkTitle: "Physical Dysphoria" description: "Body discomfort is only one of the many ways Gender Dysphoria manifests." preBody: '_disclaimer' siblings: diff --git a/public/gdb/presentational-dysphoria.md b/public/gdb/presentational-dysphoria.md index 9630576..99369d0 100644 --- a/public/gdb/presentational-dysphoria.md +++ b/public/gdb/presentational-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Presentational Dysphoria" +linkTitle: "Presentational Dysphoria" description: "Hoodies and sweatpants never go out of style." preBody: '_disclaimer' siblings: diff --git a/public/gdb/sexual-dysphoria.md b/public/gdb/sexual-dysphoria.md index 6b03a68..2344afc 100644 --- a/public/gdb/sexual-dysphoria.md +++ b/public/gdb/sexual-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Sexual Dysphoria" +linkTitle: "Sexual Dysphoria" description: "Sometimes a Cigar doesn't want to be smoked." preBody: '_disclaimer' siblings: diff --git a/public/gdb/social-dysphoria.md b/public/gdb/social-dysphoria.md index 3fb7986..102ff56 100644 --- a/public/gdb/social-dysphoria.md +++ b/public/gdb/social-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Social Dysphoria" +linkTitle: "Social Dysphoria" description: "Pronouns and Deadnames and Gendering, oh my." preBody: '_disclaimer' siblings: diff --git a/public/gdb/societal-dysphoria.md b/public/gdb/societal-dysphoria.md index f516488..0ea2379 100644 --- a/public/gdb/societal-dysphoria.md +++ b/public/gdb/societal-dysphoria.md @@ -1,6 +1,7 @@ --- date: "2020-01-26T20:41:55.827Z" title: "How Gender Dysphoria Manifests: Societal Dysphoria" +linkTitle: "Societal Dysphoria" description: "Because a Role is a Role, and a Toll is a Toll, and it's a heavy toll to live the wrong role." preBody: '_disclaimer' siblings: diff --git a/tools/navigation.py b/tools/navigation.py new file mode 100755 index 0000000..6985bff --- /dev/null +++ b/tools/navigation.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 +import os +import glob +import yaml + + +def get_all_pages(): + return [file for file in glob.glob("gdb/*.md") + if not file.endswith("/index.md")] + + +def fix_web_path(page): + return '/' + page[:-3] + + +def parse_page_data(page): + with open(page) as fd: + return next(yaml.safe_load_all(fd)) + + +def most_appropriate_title(data): + return data.get("linkTitle") or data['title'] + + +def traverse_siblings(pages, start, sibling='next'): + page = start + while page in pages: + yield page + page = pages[page]['siblings'].get(sibling) + + +def create_intro_toc(pages, start, offset=2): + for num, page in enumerate(traverse_siblings(pages, start)): + data = pages[page] + title = most_appropriate_title(data) + print(f"{num + offset}. [{title}]({page})\n") + + +def create_navbar(pages, start): + longest_link = max(map(len, traverse_siblings(pages, start))) + 2 + + for page in traverse_siblings(pages, start): + data = pages[page] + title = most_appropriate_title(data) + linksq = f"'{page}'" + linkdq = f'"{page}"' + print(f' {title}') + + +def check_nav_consistency(pages, first): + for page in traverse_siblings(pages, first): + siblings = pages[page]['siblings'] + for sibling in 'prev', 'next': + sibling_data = pages.get(siblings.get(sibling)) + if sibling_data: + sibling_title = most_appropriate_title(sibling_data) + link_title = siblings[sibling + 'Caption'] + if sibling_title != link_title: + print(f"{page}: caption mismatch for {sibling}: expected {sibling_title!r}, got {link_title!r}") + + +def main(): + os.chdir("../public") + pages = {fix_web_path(file): parse_page_data(file) for file in get_all_pages()} + *_, first = traverse_siblings(pages, next(iter(pages)), sibling="prev") + create_intro_toc(pages, first) + create_navbar(pages, first) + check_nav_consistency(pages, first) + return 0 + + +if __name__ == '__main__': + main()