From ef0e2cfb699e9630d8caaa4cf61eb72c66be3b85 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Wed, 3 Dec 2025 02:55:23 -0800 Subject: add make-follow script --- indieweb-micro/make-follow.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 indieweb-micro/make-follow.sh (limited to 'indieweb-micro/make-follow.sh') diff --git a/indieweb-micro/make-follow.sh b/indieweb-micro/make-follow.sh new file mode 100755 index 0000000..b72fc9d --- /dev/null +++ b/indieweb-micro/make-follow.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Get today's date in the required format +today=$(date '+%Y-%m-%d') + +# Check if URL is provided as argument +if [ $# -eq 0 ]; then + echo "Usage: $0 " + echo "Example: $0 https://sakurajima.moe/@sakurajima" + exit 1 +fi + +url="$1" + +# Append https if not present +if [[ ! $url =~ ^https?:// ]]; then + url="https://$url" +fi + +# Check if URL matches the pattern https://domain/@user@remote.domain +if [[ $url =~ ^https://[^/]+/@[^@]+@([^/]+)$ ]]; then + # Extract the username and remote domain + username=$(echo "$url" | sed 's/.*\/@\([^@]*\)@.*/\1/') + remote_domain="${BASH_REMATCH[1]}" + # Remap to https://remote.domain/@username + url="https://$remote_domain/@$username" +fi + +# Generate the follow shortcode +echo "{{< follow \"$url\" \"$today\" >}}" -- cgit v1.2.3