summaryrefslogtreecommitdiffstats
path: root/indieweb-micro/make-follow.sh
blob: b72fc9d17e1b1d267d3a869f5d6604b96cce741f (plain) (blame)
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
#!/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 <url>"
    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\" >}}"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage