Repository navigation
Expand file tree
/
Copy pathmake-redirects.sh
More file actions
executable file
·50 lines (50 loc) · 2.85 KB
/
Copy pathmake-redirects.sh
File metadata and controls
executable file
·50 lines (50 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# Generates GitHub Pages shortcut redirects (meta-refresh; GH Pages has no server 301s).
# Usage: edit the map below, run ./make-redirects.sh, commit.
#
# Every /<path> redirect that ships in this repo must have an entry here.
# This script is the only source of truth for these pages — do not hand-edit
# a redirect's index.html afterwards, or the next run of this script will
# silently discard the hand edit.
set -euo pipefail
declare -A MAP=(
[tv]="https://youtube.com/@hivecommons|the Hive Commons YouTube channel"
[youtube]="https://youtube.com/@hivecommons|the Hive Commons YouTube channel"
[discord]="https://discord.gg/kQbCKGySvp|the Hive Commons Discord"
[doc]="https://docs.hivecommons.dev|the Hive Commons docs"
[docs]="https://docs.hivecommons.dev|the Hive Commons docs"
[code]="https://github.com/hivecommons|the Hive Commons GitHub org"
[github]="https://github.com/hivecommons|the Hive Commons GitHub org"
[joinus]="https://groups.google.com/g/hivecommons-dev|the hivecommons-dev Google Group"
[join_us]="https://groups.google.com/g/hivecommons-dev|the hivecommons-dev Google Group"
[join]="https://groups.google.com/g/hivecommons-dev|the hivecommons-dev Google Group"
[agenda]="https://docs.google.com/document/d/1eVJnPR4zua5ZhOqg-vVT-ndBpwXbPOdXar7AZqlqky0/edit?usp=sharing|the meeting agenda & notes"
[calendar]="https://calendar.google.com/calendar/embed?src=b43dc28a888d316aa1fe4a47bf3038cd1bca7bbb2b5cdbf5e7ecb9cc10672a95%40group.calendar.google.com|the community calendar"
[meet]="https://calendar.google.com/calendar/event?action=TEMPLATE&tmeid=MGU0cmRlbjZvbXZpZTljZTRqZWg5ZTJlbmMgYjQzZGMyOGE4ODhkMzE2YWExZmU0YTQ3YmYzMDM4Y2QxYmNhN2JiYjJiNWNkYmY1ZTdlY2I5Y2MxMDY3MmE5NUBn&tmsrc=b43dc28a888d316aa1fe4a47bf3038cd1bca7bbb2b5cdbf5e7ecb9cc10672a95%40group.calendar.google.com&scp=ALL|the meeting invite"
)
html_escape() {
local s="$1"
s="${s//&/&}"
s="${s//</"<"}"
s="${s//>/">"}"
s="${s//\"/"""}"
printf '%s' "$s"
}
for path in "${!MAP[@]}"; do
entry="${MAP[$path]}"
url="${entry%%|*}"
label="$(html_escape "${entry#*|}")"
url="$(html_escape "$url")"
mkdir -p "$path"
cat > "$path/index.html" <<HTML
<!doctype html><html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; base-uri 'none'; form-action 'none'">
<meta http-equiv="refresh" content="0; url=$url">
<meta name="robots" content="noindex">
<link rel="canonical" href="$url"><title>Hive Commons — $label</title>
<style>body{font-family:system-ui;background:#14110b;color:#efe7d7;display:grid;place-items:center;height:100vh;margin:0}a{color:#e0a33a}</style>
</head><body><p>Redirecting to <a href="$url">$label</a>…</p></body></html>
HTML
echo "/$path -> ${entry%%|*}"
done