git ssb

0+

cel / ssb-invitation-cards



Commit 99632759931138b75a0c377236b80bbe2042a18d

Support multiple config files for generating pages

cel committed on 9/27/2019, 7:51:52 PM
Parent: 4820fa19862722663667a28a0fb741b17c440cc5

Files changed

geninvitecodepage.shchanged
geninvitecodepages.shchanged
geninvitecodepaths.shchanged
geninvitecodepage.shView
@@ -1,11 +1,17 @@
11 #!/bin/sh
22 invite_code=${1?invite_code}
3 +config_file=${2:-config.ps}
4 +if [ ! -s "$config_file" ]; then
5 + printf "missing config file %s\n" "$config_file" >&2
6 + exit 1
7 +fi
8 +
39 invite_code="$(printf "%s" "$invite_code" | sed 's/\//\\\//g')"
4-op_name="$(grep op_name config.ps | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')"
5-op_id="$(grep op_id config.ps | grep -o @.*ed25519 | sed 's/\//\\\//g')"
6-pub_name="$(grep pub_name config.ps | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')"
7-pub_id="$(grep pub_id config.ps | grep -o @.*ed25519 | sed 's/\//\\\//g')"
10 +op_name="$(grep op_name "$config_file" | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')"
11 +op_id="$(grep op_id "$config_file" | grep -o @.*ed25519 | sed 's/\//\\\//g')"
12 +pub_name="$(grep pub_name "$config_file" | sed 's/.*\?(//; s/).*\?//; s/\//\\\//g')"
13 +pub_id="$(grep pub_id "$config_file" | grep -o @.*ed25519 | sed 's/\//\\\//g')"
814 exec sed -e "s/{{invite_code}}/$invite_code/g" \
915 -e "s/{{op_name}}/$op_name/g" \
1016 -e "s/{{op_id}}/$op_id/g" \
1117 -e "s/{{pub_name}}/$pub_name/g" \
geninvitecodepages.shView
@@ -3,10 +3,10 @@
33 base=${2?base}
44 mkdir -p "$dir"
55 cd "$(dirname "$0")"
66 test -s "$dir"/invite-letterhead.jpg || cp invite-letterhead.jpg "$dir"/
7-while read -r path invite
7 +while read -r path invite name
88 do
99 mkdir -p "$(dirname "$dir/$path")"
10- ./geninvitecodepage.sh "$invite" > "$dir/$path"
10 + ./geninvitecodepage.sh "$invite" "config${name:+-}$name.ps" > "$dir/$path"
1111 echo "$base/$path"
1212 done
geninvitecodepaths.shView
@@ -1,7 +1,13 @@
11 #!/bin/sh
22 count=${1?count}
3-pwgen -sAB 6 "$count" | sed "s/\(.\)\(.....\)/\1\/\2\.html/" | while read -r path
3 +size=${2:-6}
4 +name=$3
5 +case "$size" in
6 + 6) pwgen -sAB 6 "$count" | sed "s/\(.\)\(.....\)/\1\/\2\.html/" ;;
7 + 10) pwgen -sAB 10 "$count" | sed "s/\(.\)\(.........\)/\1\/\2\.html/" ;;
8 + *) echo 'invalid length' >&2; exit 1;;
9 +esac | while read -r path
410 do
511 invite="$(./geninvitecode.sh)" || exit 1
6- printf "%s\t%s\n" "$path" "$invite"
12 + printf "%s\t%s\t%s\n" "$path" "$invite" "$name"
713 done

Built with git-ssb-web