docs: Move binaries to bin/

This commit is contained in:
Elian Doran
2024-07-20 13:14:35 +03:00
parent 46c193dd9f
commit 05776d178e
7 changed files with 2 additions and 5 deletions

1
bin/docs/.env.example Normal file
View File

@@ -0,0 +1 @@
SHARE_URL=https://notes.example.com/share/4yYHqKbLovVY

2
bin/docs/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
output
.env

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=./{{ROOT_NOTE_ID}}.html" />
</head>
<body>
</body>
</html>

34
bin/docs/prepare.sh Executable file
View File

@@ -0,0 +1,34 @@
#!/usr/bin/env bash
if [ ! -f .env ]; then
echo "Missing .env file, cannot proceed."
exit 1
fi
script_dir=$(realpath $(dirname $0))
output_dir="$script_dir/../docs"
mkdir -p "$output_dir"
rm -f "$output_dir"/*
rm -rf "$output_dir"/{assets,share}
source ./.env
# Download everything in output/notes.example.com/share/...
share_url="$SHARE_PROTOCOL://$SHARE_HOST/share/$ROOT_NOTE_ID"
wget -rpEk -e robots=off "$share_url" -P "$output_dir"
# Get rid of the domain in the output folder
mv "$output_dir/$SHARE_HOST"/* "$output_dir/"
rmdir "$output_dir/$SHARE_HOST"
# Create home page with redirect
index_dest_path="$output_dir/index.html"
cp index.template.html "$index_dest_path"
sed -i "s/{{ROOT_NOTE_ID}}/$ROOT_NOTE_ID/g" "$index_dest_path"
# Rewrite links to get rid of the share folder
sed -i "s/<link href=\"\\.\\./<link href=\"\\./g" "$output_dir/share"/*.html
sed -i "s/<script src=\"\\.\\./<script src=\"\\./g" "$output_dir/share"/*.html
sed -i "s/rel=\"shortcut icon\" href=\"\\.\\./rel=\"shortcut icon\" href=\"\\./g" "$output_dir/share"/*.html
mv "$output_dir/share"/* "$output_dir"
rmdir "$output_dir/share"

5
bin/docs/preview.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env bash
script_dir=$(realpath $(dirname $0))
output_dir="$script_dir/../docs"
httpd -fv -p 127.0.0.1:8089 -h "$output_dir"