From 18246236444978f84fb36d4b8b44356fc87fcfbb Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Fri, 3 Jan 2025 11:54:13 +0000 Subject: [PATCH] feat(404): use better absolute url scheme `/..` makes it relative to the URL without us having to specify the domain name. --- .github/workflows/publish.yml | 7 +++++-- build-helper.sh | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cd7f8849..b1e0f12a 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -41,8 +41,11 @@ jobs: jupyter-book build ./source - name: Update locations in 404 page run: | - sed -i 's|href="_static|href="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html - sed -i 's|src="_static|src="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html + sed -i 's|src="\([[:alnum:]_]\)|src="/\1|g' ./source/_build/html/404.html + sed -i 's|href="\([[:alnum:]_]\)|href="/\1|g' ./source/_build/html/404.html + # if we also replaced "http.." with "/http..", undo that + sed -i 's|href="/http|href="http|g' ./source/_build/html/404.html + sed -i 's|src="/http|src="http|g' ./source/_build/html/404.html - name: Import to GitHub pages run: | ghp-import -c "docs.neuroml.org" -n -p -f ./source/_build/html diff --git a/build-helper.sh b/build-helper.sh index 69d5449b..ce19629c 100755 --- a/build-helper.sh +++ b/build-helper.sh @@ -75,12 +75,17 @@ function build_book() { enable_virtenv echo "Building book." jupyter-book build ./source - sed -i 's|href="_static|href="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html - sed -i 's|src="_static|src="https://docs.neuroml.org/_static|g' ./source/_build/html/404.html } function publish_book() { enable_virtenv + echo "Updating URLs for 404.html" + sed -i 's|src="\([[:alnum:]_]\)|src="/\1|g' ./source/_build/html/404.html + sed -i 's|href="\([[:alnum:]_]\)|href="/\1|g' ./source/_build/html/404.html + # if we also replaced "http.." with "/http..", undo that + sed -i 's|href="/http|href="http|g' ./source/_build/html/404.html + sed -i 's|src="/http|src="http|g' ./source/_build/html/404.html + echo "Publishing book." ghp-import -c "docs.neuroml.org" -n -p -f ./source/_build/html }