From 314711b335574a39cbb5a528c04b86f585e4d58c Mon Sep 17 00:00:00 2001 From: Sean Colsen Date: Wed, 2 Oct 2024 10:09:21 -0400 Subject: [PATCH 1/8] Ignore built mkdocs site files --- docs/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/.gitignore diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000000..d97e100637 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +site \ No newline at end of file From 90c4beca462c19e7edf97d9144c0c5e02e76ae94 Mon Sep 17 00:00:00 2001 From: Sean Colsen Date: Wed, 2 Oct 2024 10:03:17 -0400 Subject: [PATCH 2/8] Enable mike within mkdocs --- docs/mkdocs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 58875327c4..9d569e569a 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -118,3 +118,6 @@ markdown_extensions: extra: mathesar_version: 0.1.7 + version: + provider: mike + alias: true From e7ca3c0416b203974ac941e8561a267c2872044a Mon Sep 17 00:00:00 2001 From: Sean Colsen Date: Thu, 3 Oct 2024 10:58:22 -0400 Subject: [PATCH 3/8] Make docs header more compact --- docs/docs/stylesheets/extra.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/docs/stylesheets/extra.css b/docs/docs/stylesheets/extra.css index fa915bb3c3..ded3c27abd 100644 --- a/docs/docs/stylesheets/extra.css +++ b/docs/docs/stylesheets/extra.css @@ -151,3 +151,17 @@ border-bottom: 2px solid var(--md-primary-fg-color--light); color: var(--md-primary-bg-color--lightest); } + +/* Make header title smaller */ +.md-header__title { font-size: 0.8rem; } +[dir="ltr"] .md-header__title { margin-left: 0; } + +/* Make header theme switcher smaller */ +.md-header__option .md-header__button { padding: 0.2rem; } +.md-header__option .md-header__button { padding: 0.2rem; } +.md-header__option .md-header__button svg { height: 1rem; width: 1rem; } + +/* Make version switcher smaller */ +.md-version { font-size: 0.7rem; font-weight: normal; } +[dir="ltr"] .md-version__current { margin-left: 0.6rem; } +.md-version__list { margin: 1.7rem 0 0 0; } From 5151bd89503c912d82a6b5036d5d83bbc032e15b Mon Sep 17 00:00:00 2001 From: Brent Moran Date: Tue, 20 Aug 2024 13:20:56 +0800 Subject: [PATCH 4/8] update mkdocs dependencies to get pipeline passing --- docs/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 489148efae..700485f293 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -3,5 +3,5 @@ mkdocs-material==8.5.11 mkdocs-redirects==1.2.0 mkdocs-macros-plugin==0.7.0 mkdocs-placeholder-plugin==0.3.1 -mkdocstrings==0.24.2 -mkdocstrings-python==1.9.2 +mkdocstrings==0.25.2 +mkdocstrings-python==1.10.8 From fbeefc3cce4ff7942164abbdbd23f5d1da32e560 Mon Sep 17 00:00:00 2001 From: Sean Colsen Date: Tue, 8 Oct 2024 10:45:39 -0400 Subject: [PATCH 5/8] Remove GH action to auto-deploy docs --- .github/workflows/deploy-docs.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/deploy-docs.yml diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml deleted file mode 100644 index c20fa7ad23..0000000000 --- a/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: deploy-docs -on: - push: - branches: - - master -permissions: - contents: write -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.11 - - run: pip install -r ./docs/requirements.txt - - working-directory: ./docs - run: mkdocs gh-deploy --strict --force From a5d318c35624ba5c9c788a04fd11922628b3b521 Mon Sep 17 00:00:00 2001 From: Sean Colsen Date: Wed, 9 Oct 2024 11:22:22 -0400 Subject: [PATCH 6/8] Add custom 404 page with redirection logic --- docs/mkdocs.yml | 1 + docs/overrides/404.html | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 docs/overrides/404.html diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 9d569e569a..2040e86f05 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -91,6 +91,7 @@ theme: toggle: icon: material/brightness-4 name: Switch to light mode + custom_dir: overrides extra_css: - stylesheets/extra.css diff --git a/docs/overrides/404.html b/docs/overrides/404.html new file mode 100644 index 0000000000..68ca7a6de8 --- /dev/null +++ b/docs/overrides/404.html @@ -0,0 +1,67 @@ +{% extends "base.html" %} + +{% block content %} +

Page Not Found

+ +

+ If you followed a link here, we'd appreciate it if you would open a + + GitHub issue + + describing how you got here so we can fix the link. +

+ +

+ You can also ask the Mathesar team for help by reaching out on + Matrix. +

+{% endblock %} + +{% block scripts %} + {{ super() }} + +{% endblock %} \ No newline at end of file From 0eb6611cc97357255b01bdadcf78d1efde9fd49c Mon Sep 17 00:00:00 2001 From: Sean Colsen Date: Wed, 9 Oct 2024 14:49:32 -0400 Subject: [PATCH 7/8] Handle loading state in 404 page --- docs/overrides/404.html | 64 ++++++++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/docs/overrides/404.html b/docs/overrides/404.html index 68ca7a6de8..6a3bbee7e0 100644 --- a/docs/overrides/404.html +++ b/docs/overrides/404.html @@ -1,20 +1,21 @@ {% extends "base.html" %} {% block content %} -

Page Not Found

+

Loading...

-

- If you followed a link here, we'd appreciate it if you would open a - - GitHub issue - - describing how you got here so we can fix the link. -

- -

- You can also ask the Mathesar team for help by reaching out on - Matrix. -

+ {% endblock %} {% block scripts %} @@ -33,11 +34,12 @@

Page Not Found

*/ const pathPartsBeforeVersion = []; const versionPositionInPath = pathPartsBeforeVersion.length; - - async function handleMissingVersion() { + + /** @returns {Promise} */ + async function getRedirectionTarget() { try { const response = await fetch('/versions.json'); - if (!response.ok) return; + if (!response.ok) return undefined; /** @type {({ version: string; title: string; aliases: string[]; })[]} */ const versionBlobs = await response.json(); @@ -47,9 +49,9 @@

Page Not Found

const pathParts = url.pathname.split('/').filter(Boolean); const firstPathPart = pathParts[versionPositionInPath]; - if (versionLikeStrings.includes(firstPathPart)) return; + if (versionLikeStrings.includes(firstPathPart)) return undefined; - window.location.href = [ + return [ '', ...pathPartsBeforeVersion, defaultVersionAlias, @@ -58,10 +60,32 @@

Page Not Found

].join('/'); } catch (e) { - // Ignore errors + return undefined; + } + } + + function setupErrorPageContent() { + const h1 = document.querySelector('h1'); + if (h1) { + h1.textContent = 'Page Not Found'; + } + + /** @type {HTMLElement | null} */ + const help404 = document.querySelector('.help-404'); + if (help404) { + help404.style.display = 'block'; + } + } + + async function init() { + const redirectionTarget = await getRedirectionTarget(); + if (redirectionTarget) { + window.location.href = redirectionTarget; + } else { + setupErrorPageContent(); } } - handleMissingVersion(); + init(); {% endblock %} \ No newline at end of file From 91a84afdb050edd12c9c20663584fd421f2df488 Mon Sep 17 00:00:00 2001 From: Sean Colsen Date: Tue, 8 Oct 2024 10:45:39 -0400 Subject: [PATCH 8/8] Remove GH action to auto-deploy docs --- .github/workflows/deploy-docs.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/deploy-docs.yml diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml deleted file mode 100644 index c20fa7ad23..0000000000 --- a/.github/workflows/deploy-docs.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: deploy-docs -on: - push: - branches: - - master -permissions: - contents: write -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: 3.11 - - run: pip install -r ./docs/requirements.txt - - working-directory: ./docs - run: mkdocs gh-deploy --strict --force