Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axilleas@axilleas.me>2017-09-08 18:04:03 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2018-02-15 15:00:19 +0300
commitf8501806242e4425b531e97e67f842ebb351a8f6 (patch)
treee18f4f7062a8f024478ed6d06d76a0458853895d /scripts
parent785008677aaa61a1db50540d800dd4fd306f6877 (diff)
Add Dockerfiles that will help build a versioned website
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/normalize-links.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/normalize-links.sh b/scripts/normalize-links.sh
new file mode 100755
index 00000000..c31e37a1
--- /dev/null
+++ b/scripts/normalize-links.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+TARGET="$1"
+VER="$2"
+
+if [ -z "$TARGET" ]; then
+ echo "Usage: $0 <target> <version>"
+ echo "No target provided. Exiting."
+ exit 1
+fi
+
+if [ -z "$VER" ]; then
+ echo "Usage: $0 <target> <version>"
+ echo "No version provided. Exiting."
+ exit 1
+fi
+
+if ! [ -d "$TARGET/$VER" ]; then
+ echo "Target directory $TARGET/$VER does not exist. Exiting."
+ exit 1
+fi
+
+# Fix relative links for archive
+find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ce/#/'"$VER"'/ce/#g'
+find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/ee/#/'"$VER"'/ee/#g'
+find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/runner/#/'"$VER"'/runner/#g'
+find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/omnibus/#/'"$VER"'/omnibus/#g'
+find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#="/assets/#/'"$VER"'/assets/#g'
+find ${TARGET} -type f -name '*.html' -print0 | xargs -0 sed -i 's#<a href="/">#<a href="/'"$VER"'/">#g'
+
+# 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