Skip to content

Commit 923bfbe

Browse files
authored
Merge pull request #15 from QualiSystems/build-redirects
add redirect generation script and update deployment workflow
2 parents 7cebee4 + d253489 commit 923bfbe

File tree

6 files changed

+288
-148
lines changed

6 files changed

+288
-148
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ jobs:
2929
cp docusaurus-prod.config.js docusaurus.config.js
3030
- name: Build website
3131
run: npm run build
32+
33+
- name: Generate redirects
34+
run: |
35+
chmod +x ./build_redirects/generate_redirects.sh
36+
./build_redirects/generate_redirects.sh build ./build_redirects/redirects.txt ./build_redirects/redirects.ver
37+
3238
- name: Post build renames
3339
run: |
3440
find build/Online%20Help -type f -name "index.html" -execdir cp {} Default.htm \;
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
BUILD_DIR="${1:-build}"
5+
REDIRECTS_FILE="${2:-redirects.txt}"
6+
REDIRECTS_VER_FILE="${3:-redirects.ver}"
7+
8+
if [ ! -d "$BUILD_DIR" ]; then
9+
echo "Build dir '$BUILD_DIR' not found"
10+
exit 1
11+
fi
12+
if [ ! -f "$REDIRECTS_FILE" ]; then
13+
echo "Redirects file '$REDIRECTS_FILE' not found"
14+
exit 1
15+
fi
16+
if [ ! -f "$REDIRECTS_VER_FILE" ]; then
17+
echo "Redirects versions file '$REDIRECTS_VER_FILE' not found"
18+
exit 1
19+
fi
20+
21+
# load all versions
22+
versions=()
23+
while IFS= read -r line || [ -n "$line" ]; do
24+
versions+=("$line")
25+
done < "$REDIRECTS_VER_FILE"
26+
27+
28+
# HTML redirect template (defined once, outside the loop to avoid redefinition)
29+
redirect_html() {
30+
local url="$1"
31+
cat <<EOF
32+
<!DOCTYPE html>
33+
<html>
34+
<head>
35+
<meta charset="UTF-8">
36+
<meta http-equiv="refresh" content="0; url=${url}">
37+
<link rel="canonical" href="${url}" />
38+
</head>
39+
<body>
40+
<script>
41+
window.location.href = '${url}' + window.location.search + window.location.hash;
42+
</script>
43+
</body>
44+
</html>
45+
EOF
46+
}
47+
48+
while IFS='|' read -r from to || [ -n "$from" ]; do
49+
# skip empty or comment lines
50+
case "$from" in
51+
''|\#*) continue;;
52+
esac
53+
54+
if [[ "$from" == *"{version}"* ]]; then
55+
for version in "${versions[@]}"; do
56+
from_versioned="${from//\{version\}/$version}"
57+
58+
# normalize path: remove leading/trailing slash (root handled separately)
59+
if [ "$from_versioned" = "/" ] || [ -z "$from_versioned" ]; then
60+
target_dir="$BUILD_DIR"
61+
else
62+
from_versioned="${from_versioned#/}"
63+
from_versioned="${from_versioned%/}"
64+
target_dir="$BUILD_DIR/$from_versioned"
65+
fi
66+
67+
mkdir -p "$target_dir"
68+
redirect_html "$to" > "$target_dir/index.html"
69+
done
70+
else
71+
# normalize path: remove leading/trailing slash (root handled separately)
72+
if [ "$from" = "/" ] || [ -z "$from" ]; then
73+
target_dir="$BUILD_DIR"
74+
else
75+
from="${from#/}"
76+
from="${from%/}"
77+
target_dir="$BUILD_DIR/$from"
78+
fi
79+
80+
mkdir -p "$target_dir"
81+
redirect_html "$to" > "$target_dir/index.html"
82+
fi
83+
84+
done < "$REDIRECTS_FILE"

build_redirects/redirects.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# add specific redirects or dynamic ones (using {version})
2+
# comments start with #
3+
# list of versions will be taken from redirects.ver
4+
# format of this file is: from/path|to/path
5+
6+
/help versions/All Versions Help/Content/Versions.htm|https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm
7+
/help%20versions/All%20Versions%20Help/Content/Versions.htm|https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm
8+
/{version}/ST/|https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm
9+
/{version}/RUN/|https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm
10+
/Online%20Help/{version}/Portal/|/
11+
12+
/{version}/Portal/Inventory|/portal/inventory/inventory-dashboard
13+
/{version}/Portal/EnvironmentWorkspace|/portal/sandboxes/sandbox-workspace
14+
/{version}/Portal/ReservationWorkspace|/portal/sandboxes/sandbox-workspace
15+
/{version}/Portal/EnvironmentsCatalog|/portal/blueprints/blueprint-catalog
16+
/{version}/Portal/ReservationsList|/portal/sandboxes/sandboxes-dashboard
17+
/{version}/Portal/ReservationsTimeline|/portal/sandboxes/sandboxes-dashboard
18+
/{version}/Portal/Scheduler|/portal/job-scheduling/job-scheduling-dashboard
19+
/{version}/Portal/Manage|/admin/cloudshell-manage-dashboard/manage-dashboard-overview
20+
/{version}/Portal/ManageApps|/admin/cloudshell-manage-dashboard/manage-app-templates
21+
/{version}/Portal/UsingApps|/intro/features/apps-overview
22+
/{version}/Portal/SaveSandbox|/portal/sandboxes/saved-sandboxes
23+
/{version}/Portal/SaveSandboxOverview|/portal/sandboxes/sandbox-save-and-restore-overview
24+
/{version}/RM|/admin/setting-up-cloudshell/cloudshell-resource-management-client
25+
/help%20versions/|https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm

build_redirects/redirects.ver

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
0.0
2+
2022.1
3+
2022.1.0.1858
4+
2022.2
5+
2022.2.0.1470
6+
2023.1
7+
2023.1.0.655
8+
2023.2
9+
2023.2.0.1763
10+
2023.3
11+
2023.3.0.979
12+
2024.1
13+
2024.1.0.2480
14+
2024.1.0.2508
15+
2024.1.0.2515
16+
2024.1.0.2534
17+
2024.1.0.2540
18+
2024.1.0.2596
19+
2024.1.0.2603
20+
2024.1.0.2624
21+
2024.1.0.2634
22+
2024.1.0.2650
23+
2024.1.0.2653
24+
2024.1.0.2669
25+
2024.1.0.2682

docusaurus-prod.config.js

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -104,83 +104,83 @@ const config = {
104104
}
105105
],
106106

107-
plugins: [
108-
[
109-
'@docusaurus/plugin-client-redirects',
110-
{
111-
redirects: [
112-
{
113-
to: 'https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm',
114-
from: ['/help versions/All Versions Help/Content/Versions.htm', '/help%20versions/All%20Versions%20Help/Content/Versions.htm'],
115-
},
116-
{
117-
to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm',
118-
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/'],
119-
},
120-
{
121-
to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm',
122-
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/'],
123-
},
124-
{
125-
to: '/',
126-
from: [
127-
'/Online%20Help/2022.1.0.1858/Portal/',
128-
'/Online%20Help/2022.2.0.1470/Portal/',
129-
'/Online%20Help/2023.1.0.655/Portal/',
130-
'/Online%20Help/2023.2.0.1763/Portal/',
131-
'/Online%20Help/2023.3.0.979/Portal/',
132-
'/Online%20Help/2024.1.0.2480/Portal/',
133-
'/Online%20Help/2024.1.0.2508/Portal/',
134-
'/Online%20Help/2024.1.0.2515/Portal/',
135-
],
136-
},
137-
],
138-
createRedirects(existingPath) {
139-
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"];
107+
// plugins: [
108+
// [
109+
// '@docusaurus/plugin-client-redirects',
110+
// {
111+
// redirects: [
112+
// {
113+
// to: 'https://help-archive.quali.com/help versions/All Versions Help/Content/Versions.htm',
114+
// from: ['/help versions/All Versions Help/Content/Versions.htm', '/help%20versions/All%20Versions%20Help/Content/Versions.htm'],
115+
// },
116+
// {
117+
// to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSS/TSS.htm',
118+
// 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/'],
119+
// },
120+
// {
121+
// to: 'https://help-archive.quali.com/Online Help/0.0/TestShell/Content/TSR/Tst-Run.htm',
122+
// 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/'],
123+
// },
124+
// {
125+
// to: '/',
126+
// from: [
127+
// '/Online%20Help/2022.1.0.1858/Portal/',
128+
// '/Online%20Help/2022.2.0.1470/Portal/',
129+
// '/Online%20Help/2023.1.0.655/Portal/',
130+
// '/Online%20Help/2023.2.0.1763/Portal/',
131+
// '/Online%20Help/2023.3.0.979/Portal/',
132+
// '/Online%20Help/2024.1.0.2480/Portal/',
133+
// '/Online%20Help/2024.1.0.2508/Portal/',
134+
// '/Online%20Help/2024.1.0.2515/Portal/',
135+
// ],
136+
// },
137+
// ],
138+
// createRedirects(existingPath) {
139+
// 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"];
140140

141-
if (existingPath.startsWith('/portal/inventory/inventory-dashboard')) {
142-
return versions.map(version => `/${version}/Portal/Inventory`);
143-
}
144-
else if (existingPath.startsWith('/portal/sandboxes/sandbox-workspace')) {
145-
return versions.flatMap(version => [`/${version}/Portal/EnvironmentWorkspace`, `/${version}/Portal/ReservationWorkspace`]);
146-
}
147-
else if (existingPath.startsWith('/portal/blueprints/blueprint-catalog')) {
148-
return versions.map(version => `/${version}/Portal/EnvironmentsCatalog`);
149-
}
150-
else if (existingPath.startsWith('/portal/sandboxes/sandboxes-dashboard')) {
151-
return versions.flatMap(version => [`/${version}/Portal/ReservationsList`, `/${version}/Portal/ReservationsTimeline`]);
152-
}
153-
else if (existingPath.startsWith('/portal/job-scheduling/job-scheduling-dashboard')) {
154-
return versions.map(version => `/${version}/Portal/Scheduler`);
155-
}
156-
else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-dashboard-overview')) {
157-
return versions.map(version => `/${version}/Portal/Manage`);
158-
}
159-
else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-app-templates')) {
160-
return versions.map(version => `/${version}/Portal/ManageApps`);
161-
}
162-
else if (existingPath.startsWith('/intro/features/apps-overview')) {
163-
return versions.map(version => `/${version}/Portal/UsingApps`);
164-
}
165-
else if (existingPath.startsWith('/portal/sandboxes/saved-sandboxes')) {
166-
return versions.map(version => `/${version}/Portal/SaveSandbox`);
167-
}
168-
else if (existingPath.startsWith('/portal/sandboxes/sandbox-save-and-restore-overview')) {
169-
return versions.map(version => `/${version}/Portal/SaveSandboxOverview`);
170-
}
171-
else if (existingPath.startsWith('/admin/setting-up-cloudshell/cloudshell-resource-management-client')) {
172-
return versions.map(version => `/${version}/RM`);
173-
}
174-
else if (existingPath.startsWith('/help-versions-archive')) {
175-
return "/help%20versions/"
176-
}
141+
// if (existingPath.startsWith('/portal/inventory/inventory-dashboard')) {
142+
// return versions.map(version => `/${version}/Portal/Inventory`);
143+
// }
144+
// else if (existingPath.startsWith('/portal/sandboxes/sandbox-workspace')) {
145+
// return versions.flatMap(version => [`/${version}/Portal/EnvironmentWorkspace`, `/${version}/Portal/ReservationWorkspace`]);
146+
// }
147+
// else if (existingPath.startsWith('/portal/blueprints/blueprint-catalog')) {
148+
// return versions.map(version => `/${version}/Portal/EnvironmentsCatalog`);
149+
// }
150+
// else if (existingPath.startsWith('/portal/sandboxes/sandboxes-dashboard')) {
151+
// return versions.flatMap(version => [`/${version}/Portal/ReservationsList`, `/${version}/Portal/ReservationsTimeline`]);
152+
// }
153+
// else if (existingPath.startsWith('/portal/job-scheduling/job-scheduling-dashboard')) {
154+
// return versions.map(version => `/${version}/Portal/Scheduler`);
155+
// }
156+
// else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-dashboard-overview')) {
157+
// return versions.map(version => `/${version}/Portal/Manage`);
158+
// }
159+
// else if (existingPath.startsWith('/admin/cloudshell-manage-dashboard/manage-app-templates')) {
160+
// return versions.map(version => `/${version}/Portal/ManageApps`);
161+
// }
162+
// else if (existingPath.startsWith('/intro/features/apps-overview')) {
163+
// return versions.map(version => `/${version}/Portal/UsingApps`);
164+
// }
165+
// else if (existingPath.startsWith('/portal/sandboxes/saved-sandboxes')) {
166+
// return versions.map(version => `/${version}/Portal/SaveSandbox`);
167+
// }
168+
// else if (existingPath.startsWith('/portal/sandboxes/sandbox-save-and-restore-overview')) {
169+
// return versions.map(version => `/${version}/Portal/SaveSandboxOverview`);
170+
// }
171+
// else if (existingPath.startsWith('/admin/setting-up-cloudshell/cloudshell-resource-management-client')) {
172+
// return versions.map(version => `/${version}/RM`);
173+
// }
174+
// else if (existingPath.startsWith('/help-versions-archive')) {
175+
// return "/help%20versions/"
176+
// }
177177

178178

179-
return undefined; // Return a falsy value: no redirect created
180-
},
181-
},
182-
],
183-
],
179+
// return undefined; // Return a falsy value: no redirect created
180+
// },
181+
// },
182+
// ],
183+
// ],
184184

185185
themeConfig:
186186
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */

0 commit comments

Comments
 (0)