Skip to content

Commit 00c64c4

Browse files
committed
Add /go which redirects to the latest quickstart
Why: I want a permanent and snappy URL that redirects to the latest proxy quick start so that I can embed it in videos etc. This should be long lasting so I've added simple tests (invoked at the end of build.sh) to check that the page, target page and link are what we expect. Signed-off-by: Robert Young <[email protected]>
1 parent 0d50250 commit 00c64c4

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

_layouts/redirect.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!doctype html>
2-
{% assign absolute_target = page.target | absolute_url %}
2+
{% assign absolute_target = page.target | replace: '$$LATEST_RELEASE$$', site.data.kroxylicious.latestRelease | absolute_url %}
33
<html lang="en">
44
<head>
55
<meta charset="utf-8">

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ BUILD_COMMAND='eval "$(rbenv init -)" && cp -r /css/_sass/bootstrap /site/_sass/
3434
RUN_ARGS+=(bash -c "${BUILD_COMMAND}")
3535
echo "${RUN_ARGS[@]}"
3636
${CONTAINER_ENGINE} run "${RUN_ARGS[@]}"
37+
./test.sh

go.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
layout: redirect
3+
target: "/documentation/$$LATEST_RELEASE$$/html/proxy-quick-start/"
4+
delay: 1
5+
---

test.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
# Checks the output of build.sh (which is the production build deployed to pages)
3+
set -euo pipefail
4+
5+
LATEST_RELEASE=$(grep "latestRelease:" _data/kroxylicious.yml | awk '{print $2}')
6+
7+
LATEST_RELEASE_QUICKSTART="_site/documentation/${LATEST_RELEASE}/html/proxy-quick-start/index.html"
8+
PERMANENT_QUICKSTART_REDIRECT="_site/go.html"
9+
EXPECTED_REDIRECT_STRING="<meta http-equiv=\"refresh\" content=\"1; url=https://kroxylicious.io/documentation/${LATEST_RELEASE}/html/proxy-quick-start/\">"
10+
11+
check_file_exists() {
12+
local file_path="$1"
13+
local file_description="$2"
14+
if [ -f "${file_path}" ]; then
15+
echo "SUCCESS: ${file_description} file found at ${file_path}"
16+
else
17+
echo "ERROR: ${file_description} file not found at ${file_path}" >&2
18+
exit 1
19+
fi
20+
}
21+
22+
echo "Expect /go to HTML redirect to the latest quickstart"
23+
check_file_exists "${LATEST_RELEASE_QUICKSTART}" "Latest release quickstart"
24+
check_file_exists "${PERMANENT_QUICKSTART_REDIRECT}" "Permanent quickstart redirect"
25+
26+
if grep -qF "${EXPECTED_REDIRECT_STRING}" "${PERMANENT_QUICKSTART_REDIRECT}"; then
27+
echo "SUCCESS: Expected redirect string found in ${PERMANENT_QUICKSTART_REDIRECT}"
28+
else
29+
echo "ERROR: Expected redirect string '${EXPECTED_REDIRECT_STRING}' not found in ${PERMANENT_QUICKSTART_REDIRECT}"
30+
exit 1
31+
fi
32+
echo "All checks succeeded!"
33+
exit 0

0 commit comments

Comments
 (0)