diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2019-10-24 10:27:46 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2019-12-19 11:34:19 +0300 |
commit | a4a5fed59443a43108f1e0001020ce7cbb03d3b2 (patch) | |
tree | 40acc3c7a066c6096aa9da08029a6a25fb357308 /scripts/normalize-links.sh | |
parent | 1711f3ef3d25ef5a921387217dc4156d0001d71a (diff) |
Make sure we also capture full URLs when converting the versioned URLs
In cross-product docs, we're referencing full URLs instead of relative
ones. For example, an Omnibus doc can have a doc reference to a Runner
doc URL. In that case, we use the full URL.
This change adds another find command that checks and replaces the
version for full URLs as well.
Diffstat (limited to 'scripts/normalize-links.sh')
-rwxr-xr-x | scripts/normalize-links.sh | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh index 3d83ce37..230f817f 100755 --- a/scripts/normalize-links.sh +++ b/scripts/normalize-links.sh @@ -20,19 +20,69 @@ if ! [ -d "$TARGET/$VER" ]; then exit 1 fi -# Fix relative links for archive +## +## In order for the version to be correct, we need to replace any occurrences +## of relative or full URLs with the respective version. +## +## +## Relative URLs +## +echo "Replace relative URLs in $TARGET/$VER for /ce/" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ce/#="/'"$VER"'/ce/#g' + +echo "Replace relative URLs in $TARGET/$VER for /ee/" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ee/#="/'"$VER"'/ee/#g' + +echo "Replace relative URLs in $TARGET/$VER for /runner/" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/runner/#="/'"$VER"'/runner/#g' + +echo "Replace relative URLs in $TARGET/$VER for /omnibus/" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/omnibus/#="/'"$VER"'/omnibus/#g' + +echo "Replace relative URLs in $TARGET/$VER for /charts/" +find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/charts/#="/'"$VER"'/charts/#g' + +echo "Replace relative URLs in $TARGET/$VER for /assets/" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/assets/#="/'"$VER"'/assets/#g' + +echo "Replace relative URLs in $TARGET/$VER for /" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#<a href="/">#<a href="/'"$VER"'/">#g' + +echo "Replace relative URLs in $TARGET/$VER for opensearch.xml" find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/opensearch.xml#="/'"$VER"'/opensearch.xml#g' + +## +## Full URLs +## +echo "Replace full URLs in $TARGET/$VER for /ce/" +find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/ce/#="/'"$VER"'/ce/#g' + +echo "Replace full URLs in $TARGET/$VER for /ce/" +find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/ee/#="/'"$VER"'/ee/#g' + +echo "Replace full URLs in $TARGET/$VER for /ce/" +find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/runner/#="/'"$VER"'/runner/#g' + +echo "Replace full URLs in $TARGET/$VER for /ce/" +find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/omnibus/#="/'"$VER"'/omnibus/#g' + +echo "Replace full URLs in $TARGET/$VER for /ce/" +find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="https://docs.gitlab.com/charts/#="/'"$VER"'/charts/#g' + +echo "Fix URLs inside the sitemap" find ${TARGET} -type f -name 'sitemap.xml' -print0 | xargs -0 sed -i 's#docs.gitlab.com/#docs.gitlab.com/'"$VER"'/#g' -# Symlink all README.html to index.html +## +## In order to have clean URLs, we symlink README.html to index.html. +## That way, visiting https://docs.gitlab.com/ee/ would be the same as +## visiting https://docs.gitlab.com/ee/{README.html,index.html} +## +echo "Symlink all README.html to index.html" for i in `find ${TARGET}/${VER} -name README.html`; do ln -sf README.html $(dirname $i)/index.html; done -# Remove CE dir and symlink EE to CE -# https://gitlab.com/gitlab-org/gitlab-docs/issues/418 +## +## Don't deploy the CE docs since they are identical to the EE ones. +## https://gitlab.com/gitlab-org/gitlab-docs/issues/418 +## +echo "Remove CE dir and symlink EE to CE" if [ -d "${TARGET}/${VER}/ce/" ]; then cd ${TARGET}/${VER} && rm -r ce && ln -s ee ce; fi |