From d253489dee4ae61a7df42cabd3effadde0d06dfd Mon Sep 17 00:00:00 2001 From: Yaniv Kalsky Date: Tue, 2 Sep 2025 19:04:16 -0500 Subject: [PATCH] add redirect generation script and update deployment workflow --- .github/workflows/deploy.yml | 6 ++ build_redirects/generate_redirects.sh | 84 +++++++++++++++ build_redirects/redirects.txt | 25 +++++ build_redirects/redirects.ver | 25 +++++ docusaurus-prod.config.js | 148 +++++++++++++------------- docusaurus.config.js | 148 +++++++++++++------------- 6 files changed, 288 insertions(+), 148 deletions(-) create mode 100755 build_redirects/generate_redirects.sh create mode 100644 build_redirects/redirects.txt create mode 100644 build_redirects/redirects.ver diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 230154f616..a2635f9836 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,6 +29,12 @@ jobs: cp docusaurus-prod.config.js docusaurus.config.js - name: Build website run: npm run build + + - name: Generate redirects + run: | + chmod +x ./build_redirects/generate_redirects.sh + ./build_redirects/generate_redirects.sh build ./build_redirects/redirects.txt ./build_redirects/redirects.ver + - name: Post build renames run: | find build/Online%20Help -type f -name "index.html" -execdir cp {} Default.htm \; diff --git a/build_redirects/generate_redirects.sh b/build_redirects/generate_redirects.sh new file mode 100755 index 0000000000..cdd8bff879 --- /dev/null +++ b/build_redirects/generate_redirects.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -euo pipefail + +BUILD_DIR="${1:-build}" +REDIRECTS_FILE="${2:-redirects.txt}" +REDIRECTS_VER_FILE="${3:-redirects.ver}" + +if [ ! -d "$BUILD_DIR" ]; then + echo "Build dir '$BUILD_DIR' not found" + exit 1 +fi +if [ ! -f "$REDIRECTS_FILE" ]; then + echo "Redirects file '$REDIRECTS_FILE' not found" + exit 1 +fi +if [ ! -f "$REDIRECTS_VER_FILE" ]; then + echo "Redirects versions file '$REDIRECTS_VER_FILE' not found" + exit 1 +fi + +# load all versions +versions=() +while IFS= read -r line || [ -n "$line" ]; do + versions+=("$line") +done < "$REDIRECTS_VER_FILE" + + +# HTML redirect template (defined once, outside the loop to avoid redefinition) +redirect_html() { + local url="$1" + cat < + + + + + + + + + + +EOF +} + +while IFS='|' read -r from to || [ -n "$from" ]; do + # skip empty or comment lines + case "$from" in + ''|\#*) continue;; + esac + + if [[ "$from" == *"{version}"* ]]; then + for version in "${versions[@]}"; do + from_versioned="${from//\{version\}/$version}" + + # normalize path: remove leading/trailing slash (root handled separately) + if [ "$from_versioned" = "/" ] || [ -z "$from_versioned" ]; then + target_dir="$BUILD_DIR" + else + from_versioned="${from_versioned#/}" + from_versioned="${from_versioned%/}" + target_dir="$BUILD_DIR/$from_versioned" + fi + + mkdir -p "$target_dir" + redirect_html "$to" > "$target_dir/index.html" + done + else + # normalize path: remove leading/trailing slash (root handled separately) + if [ "$from" = "/" ] || [ -z "$from" ]; then + target_dir="$BUILD_DIR" + else + from="${from#/}" + from="${from%/}" + target_dir="$BUILD_DIR/$from" + fi + + mkdir -p "$target_dir" + redirect_html "$to" > "$target_dir/index.html" + fi + +done < "$REDIRECTS_FILE" \ No newline at end of file diff --git a/build_redirects/redirects.txt b/build_redirects/redirects.txt new file mode 100644 index 0000000000..54bcd7bdb1 --- /dev/null +++ b/build_redirects/redirects.txt @@ -0,0 +1,25 @@ +# add specific redirects or dynamic ones (using {version}) +# comments start with # +# list of versions will be taken from redirects.ver +# format of this file is: from/path|to/path + +/help versions/All Versions Help/Content/Versions.htm|https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm +/help%20versions/All%20Versions%20Help/Content/Versions.htm|https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm +/{version}/ST/|https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm +/{version}/RUN/|https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm +/Online%20Help/{version}/Portal/|/ + +/{version}/Portal/Inventory|/portal/inventory/inventory-dashboard +/{version}/Portal/EnvironmentWorkspace|/portal/sandboxes/sandbox-workspace +/{version}/Portal/ReservationWorkspace|/portal/sandboxes/sandbox-workspace +/{version}/Portal/EnvironmentsCatalog|/portal/blueprints/blueprint-catalog +/{version}/Portal/ReservationsList|/portal/sandboxes/sandboxes-dashboard +/{version}/Portal/ReservationsTimeline|/portal/sandboxes/sandboxes-dashboard +/{version}/Portal/Scheduler|/portal/job-scheduling/job-scheduling-dashboard +/{version}/Portal/Manage|/admin/cloudshell-manage-dashboard/manage-dashboard-overview +/{version}/Portal/ManageApps|/admin/cloudshell-manage-dashboard/manage-app-templates +/{version}/Portal/UsingApps|/intro/features/apps-overview +/{version}/Portal/SaveSandbox|/portal/sandboxes/saved-sandboxes +/{version}/Portal/SaveSandboxOverview|/portal/sandboxes/sandbox-save-and-restore-overview +/{version}/RM|/admin/setting-up-cloudshell/cloudshell-resource-management-client +/help%20versions/|https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm diff --git a/build_redirects/redirects.ver b/build_redirects/redirects.ver new file mode 100644 index 0000000000..5428726be8 --- /dev/null +++ b/build_redirects/redirects.ver @@ -0,0 +1,25 @@ +0.0 +2022.1 +2022.1.0.1858 +2022.2 +2022.2.0.1470 +2023.1 +2023.1.0.655 +2023.2 +2023.2.0.1763 +2023.3 +2023.3.0.979 +2024.1 +2024.1.0.2480 +2024.1.0.2508 +2024.1.0.2515 +2024.1.0.2534 +2024.1.0.2540 +2024.1.0.2596 +2024.1.0.2603 +2024.1.0.2624 +2024.1.0.2634 +2024.1.0.2650 +2024.1.0.2653 +2024.1.0.2669 +2024.1.0.2682 \ No newline at end of file diff --git a/docusaurus-prod.config.js b/docusaurus-prod.config.js index 31a8b53596..f7b1ba67dd 100644 --- a/docusaurus-prod.config.js +++ b/docusaurus-prod.config.js @@ -104,83 +104,83 @@ const config = { } ], - plugins: [ - [ - '@docusaurus/plugin-client-redirects', - { - redirects: [ - { - to: 'https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm', - from: ['/help versions/All Versions Help/Content/Versions.htm', '/help%20versions/All%20Versions%20Help/Content/Versions.htm'], - }, - { - to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm', - from: ['/2022.1.0.1858/ST/', '/2022.2.0.1470/ST/', '/2023.1.0.655/ST/', '/2023.2.0.1763/ST/', '/2023.3.0.979/ST/', '/2024.1.0.2480/ST/', '/2024.1.0.2508/ST/', '/2024.1.0.2515/ST/'], - }, - { - to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm', - from: ['/2022.1.0.1858/RUN/', '/2022.2.0.1470/RUN/', '/2023.1.0.655/RUN/', '/2023.2.0.1763/RUN/', '/2023.3.0.979/RUN/', '/2024.1.0.2480/RUN/', '/2024.1.0.2508/RUN/', '/2024.1.0.2515/RUN/'], - }, - { - to: '/', - from: [ - '/Online%20Help/2022.1.0.1858/Portal/', - '/Online%20Help/2022.2.0.1470/Portal/', - '/Online%20Help/2023.1.0.655/Portal/', - '/Online%20Help/2023.2.0.1763/Portal/', - '/Online%20Help/2023.3.0.979/Portal/', - '/Online%20Help/2024.1.0.2480/Portal/', - '/Online%20Help/2024.1.0.2508/Portal/', - '/Online%20Help/2024.1.0.2515/Portal/', - ], - }, - ], - createRedirects(existingPath) { - var versions = ["0.0", "2022.1", "2022.1.0.1858", "2022.2", "2022.2.0.1470", "2023.1", "2023.1.0.655", "2023.2", "2023.2.0.1763", "2023.3", "2023.3.0.979", "2024.1", "2024.1.0.2480", "2024.1.0.2508", "2024.1.0.2515"]; + // plugins: [ + // [ + // '@docusaurus/plugin-client-redirects', + // { + // redirects: [ + // { + // to: 'https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm', + // from: ['/help versions/All Versions Help/Content/Versions.htm', '/help%20versions/All%20Versions%20Help/Content/Versions.htm'], + // }, + // { + // to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm', + // from: ['/2022.1.0.1858/ST/', '/2022.2.0.1470/ST/', '/2023.1.0.655/ST/', '/2023.2.0.1763/ST/', '/2023.3.0.979/ST/', '/2024.1.0.2480/ST/', '/2024.1.0.2508/ST/', '/2024.1.0.2515/ST/'], + // }, + // { + // to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm', + // from: ['/2022.1.0.1858/RUN/', '/2022.2.0.1470/RUN/', '/2023.1.0.655/RUN/', '/2023.2.0.1763/RUN/', '/2023.3.0.979/RUN/', '/2024.1.0.2480/RUN/', '/2024.1.0.2508/RUN/', '/2024.1.0.2515/RUN/'], + // }, + // { + // to: '/', + // from: [ + // '/Online%20Help/2022.1.0.1858/Portal/', + // '/Online%20Help/2022.2.0.1470/Portal/', + // '/Online%20Help/2023.1.0.655/Portal/', + // '/Online%20Help/2023.2.0.1763/Portal/', + // '/Online%20Help/2023.3.0.979/Portal/', + // '/Online%20Help/2024.1.0.2480/Portal/', + // '/Online%20Help/2024.1.0.2508/Portal/', + // '/Online%20Help/2024.1.0.2515/Portal/', + // ], + // }, + // ], + // createRedirects(existingPath) { + // var versions = ["0.0", "2022.1", "2022.1.0.1858", "2022.2", "2022.2.0.1470", "2023.1", "2023.1.0.655", "2023.2", "2023.2.0.1763", "2023.3", "2023.3.0.979", "2024.1", "2024.1.0.2480", "2024.1.0.2508", "2024.1.0.2515"]; - if (existingPath.startsWith('/portal/inventory/inventory-dashboard')) { - return versions.map(version => `/${version}/Portal/Inventory`); - } - else if (existingPath.startsWith('/portal/sandboxes/sandbox-workspace')) { - return versions.flatMap(version => [`/${version}/Portal/EnvironmentWorkspace`, `/${version}/Portal/ReservationWorkspace`]); - } - else if (existingPath.startsWith('/portal/blueprints/blueprint-catalog')) { - return versions.map(version => `/${version}/Portal/EnvironmentsCatalog`); - } - else if (existingPath.startsWith('/portal/sandboxes/sandboxes-dashboard')) { - return versions.flatMap(version => [`/${version}/Portal/ReservationsList`, `/${version}/Portal/ReservationsTimeline`]); - } - else if (existingPath.startsWith('/portal/job-scheduling/job-scheduling-dashboard')) { - return versions.map(version => `/${version}/Portal/Scheduler`); - } - else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-dashboard-overview')) { - return versions.map(version => `/${version}/Portal/Manage`); - } - else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-app-templates')) { - return versions.map(version => `/${version}/Portal/ManageApps`); - } - else if (existingPath.startsWith('/intro/features/apps-overview')) { - return versions.map(version => `/${version}/Portal/UsingApps`); - } - else if (existingPath.startsWith('/portal/sandboxes/saved-sandboxes')) { - return versions.map(version => `/${version}/Portal/SaveSandbox`); - } - else if (existingPath.startsWith('/portal/sandboxes/sandbox-save-and-restore-overview')) { - return versions.map(version => `/${version}/Portal/SaveSandboxOverview`); - } - else if (existingPath.startsWith('/admin/setting-up-cloudshell/cloudshell-resource-management-client')) { - return versions.map(version => `/${version}/RM`); - } - else if (existingPath.startsWith('/help-versions-archive')) { - return "/help%20versions/" - } + // if (existingPath.startsWith('/portal/inventory/inventory-dashboard')) { + // return versions.map(version => `/${version}/Portal/Inventory`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/sandbox-workspace')) { + // return versions.flatMap(version => [`/${version}/Portal/EnvironmentWorkspace`, `/${version}/Portal/ReservationWorkspace`]); + // } + // else if (existingPath.startsWith('/portal/blueprints/blueprint-catalog')) { + // return versions.map(version => `/${version}/Portal/EnvironmentsCatalog`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/sandboxes-dashboard')) { + // return versions.flatMap(version => [`/${version}/Portal/ReservationsList`, `/${version}/Portal/ReservationsTimeline`]); + // } + // else if (existingPath.startsWith('/portal/job-scheduling/job-scheduling-dashboard')) { + // return versions.map(version => `/${version}/Portal/Scheduler`); + // } + // else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-dashboard-overview')) { + // return versions.map(version => `/${version}/Portal/Manage`); + // } + // else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-app-templates')) { + // return versions.map(version => `/${version}/Portal/ManageApps`); + // } + // else if (existingPath.startsWith('/intro/features/apps-overview')) { + // return versions.map(version => `/${version}/Portal/UsingApps`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/saved-sandboxes')) { + // return versions.map(version => `/${version}/Portal/SaveSandbox`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/sandbox-save-and-restore-overview')) { + // return versions.map(version => `/${version}/Portal/SaveSandboxOverview`); + // } + // else if (existingPath.startsWith('/admin/setting-up-cloudshell/cloudshell-resource-management-client')) { + // return versions.map(version => `/${version}/RM`); + // } + // else if (existingPath.startsWith('/help-versions-archive')) { + // return "/help%20versions/" + // } - return undefined; // Return a falsy value: no redirect created - }, - }, - ], - ], + // return undefined; // Return a falsy value: no redirect created + // }, + // }, + // ], + // ], themeConfig: /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ diff --git a/docusaurus.config.js b/docusaurus.config.js index 3150c96f7e..de87fcb991 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -106,83 +106,83 @@ const config = { // } // ], - plugins: [ - [ - '@docusaurus/plugin-client-redirects', - { - redirects: [ - { - to: 'https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm', - from: ['/help versions/All Versions Help/Content/Versions.htm', '/help%20versions/All%20Versions%20Help/Content/Versions.htm'], - }, - { - to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm', - from: ['/2022.1.0.1858/ST/', '/2022.2.0.1470/ST/', '/2023.1.0.655/ST/', '/2023.2.0.1763/ST/', '/2023.3.0.979/ST/', '/2024.1.0.2480/ST/', '/2024.1.0.2508/ST/', '/2024.1.0.2515/ST/'], - }, - { - to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm', - from: ['/2022.1.0.1858/RUN/', '/2022.2.0.1470/RUN/', '/2023.1.0.655/RUN/', '/2023.2.0.1763/RUN/', '/2023.3.0.979/RUN/', '/2024.1.0.2480/RUN/', '/2024.1.0.2508/RUN/', '/2024.1.0.2515/RUN/'], - }, - { - to: '/', - from: [ - '/Online%20Help/2022.1.0.1858/Portal/', - '/Online%20Help/2022.2.0.1470/Portal/', - '/Online%20Help/2023.1.0.655/Portal/', - '/Online%20Help/2023.2.0.1763/Portal/', - '/Online%20Help/2023.3.0.979/Portal/', - '/Online%20Help/2024.1.0.2480/Portal/', - '/Online%20Help/2024.1.0.2508/Portal/', - '/Online%20Help/2024.1.0.2515/Portal/', - ], - }, - ], - createRedirects(existingPath) { - var versions = ["0.0", "2022.1", "2022.1.0.1858", "2022.2", "2022.2.0.1470", "2023.1", "2023.1.0.655", "2023.2", "2023.2.0.1763", "2023.3", "2023.3.0.979", "2024.1", "2024.1.0.2480", "2024.1.0.2508", "2024.1.0.2515"]; + // plugins: [ + // [ + // '@docusaurus/plugin-client-redirects', + // { + // redirects: [ + // { + // to: 'https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm', + // from: ['/help versions/All Versions Help/Content/Versions.htm', '/help%20versions/All%20Versions%20Help/Content/Versions.htm'], + // }, + // { + // to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm', + // from: ['/2022.1.0.1858/ST/', '/2022.2.0.1470/ST/', '/2023.1.0.655/ST/', '/2023.2.0.1763/ST/', '/2023.3.0.979/ST/', '/2024.1.0.2480/ST/', '/2024.1.0.2508/ST/', '/2024.1.0.2515/ST/'], + // }, + // { + // to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm', + // from: ['/2022.1.0.1858/RUN/', '/2022.2.0.1470/RUN/', '/2023.1.0.655/RUN/', '/2023.2.0.1763/RUN/', '/2023.3.0.979/RUN/', '/2024.1.0.2480/RUN/', '/2024.1.0.2508/RUN/', '/2024.1.0.2515/RUN/'], + // }, + // { + // to: '/', + // from: [ + // '/Online%20Help/2022.1.0.1858/Portal/', + // '/Online%20Help/2022.2.0.1470/Portal/', + // '/Online%20Help/2023.1.0.655/Portal/', + // '/Online%20Help/2023.2.0.1763/Portal/', + // '/Online%20Help/2023.3.0.979/Portal/', + // '/Online%20Help/2024.1.0.2480/Portal/', + // '/Online%20Help/2024.1.0.2508/Portal/', + // '/Online%20Help/2024.1.0.2515/Portal/', + // ], + // }, + // ], + // createRedirects(existingPath) { + // var versions = ["0.0", "2022.1", "2022.1.0.1858", "2022.2", "2022.2.0.1470", "2023.1", "2023.1.0.655", "2023.2", "2023.2.0.1763", "2023.3", "2023.3.0.979", "2024.1", "2024.1.0.2480", "2024.1.0.2508", "2024.1.0.2515"]; - if (existingPath.startsWith('/portal/inventory/inventory-dashboard')) { - return versions.map(version => `/${version}/Portal/Inventory`); - } - else if (existingPath.startsWith('/portal/sandboxes/sandbox-workspace')) { - return versions.flatMap(version => [`/${version}/Portal/EnvironmentWorkspace`, `/${version}/Portal/ReservationWorkspace`]); - } - else if (existingPath.startsWith('/portal/blueprints/blueprint-catalog')) { - return versions.map(version => `/${version}/Portal/EnvironmentsCatalog`); - } - else if (existingPath.startsWith('/portal/sandboxes/sandboxes-dashboard')) { - return versions.flatMap(version => [`/${version}/Portal/ReservationsList`, `/${version}/Portal/ReservationsTimeline`]); - } - else if (existingPath.startsWith('/portal/job-scheduling/job-scheduling-dashboard')) { - return versions.map(version => `/${version}/Portal/Scheduler`); - } - else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-dashboard-overview')) { - return versions.map(version => `/${version}/Portal/Manage`); - } - else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-app-templates')) { - return versions.map(version => `/${version}/Portal/ManageApps`); - } - else if (existingPath.startsWith('/intro/features/apps-overview')) { - return versions.map(version => `/${version}/Portal/UsingApps`); - } - else if (existingPath.startsWith('/portal/sandboxes/saved-sandboxes')) { - return versions.map(version => `/${version}/Portal/SaveSandbox`); - } - else if (existingPath.startsWith('/portal/sandboxes/sandbox-save-and-restore-overview')) { - return versions.map(version => `/${version}/Portal/SaveSandboxOverview`); - } - else if (existingPath.startsWith('/admin/setting-up-cloudshell/cloudshell-resource-management-client')) { - return versions.map(version => `/${version}/RM`); - } - else if (existingPath.startsWith('/help-versions-archive')) { - return "/help%20versions/" - } + // if (existingPath.startsWith('/portal/inventory/inventory-dashboard')) { + // return versions.map(version => `/${version}/Portal/Inventory`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/sandbox-workspace')) { + // return versions.flatMap(version => [`/${version}/Portal/EnvironmentWorkspace`, `/${version}/Portal/ReservationWorkspace`]); + // } + // else if (existingPath.startsWith('/portal/blueprints/blueprint-catalog')) { + // return versions.map(version => `/${version}/Portal/EnvironmentsCatalog`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/sandboxes-dashboard')) { + // return versions.flatMap(version => [`/${version}/Portal/ReservationsList`, `/${version}/Portal/ReservationsTimeline`]); + // } + // else if (existingPath.startsWith('/portal/job-scheduling/job-scheduling-dashboard')) { + // return versions.map(version => `/${version}/Portal/Scheduler`); + // } + // else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-dashboard-overview')) { + // return versions.map(version => `/${version}/Portal/Manage`); + // } + // else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-app-templates')) { + // return versions.map(version => `/${version}/Portal/ManageApps`); + // } + // else if (existingPath.startsWith('/intro/features/apps-overview')) { + // return versions.map(version => `/${version}/Portal/UsingApps`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/saved-sandboxes')) { + // return versions.map(version => `/${version}/Portal/SaveSandbox`); + // } + // else if (existingPath.startsWith('/portal/sandboxes/sandbox-save-and-restore-overview')) { + // return versions.map(version => `/${version}/Portal/SaveSandboxOverview`); + // } + // else if (existingPath.startsWith('/admin/setting-up-cloudshell/cloudshell-resource-management-client')) { + // return versions.map(version => `/${version}/RM`); + // } + // else if (existingPath.startsWith('/help-versions-archive')) { + // return "/help%20versions/" + // } - return undefined; // Return a falsy value: no redirect created - }, - }, - ], - ], + // return undefined; // Return a falsy value: no redirect created + // }, + // }, + // ], + // ], themeConfig: /** @type {import('@docusaurus/preset-classic').ThemeConfig} */