summaryrefslogtreecommitdiffstats
path: root/indieweb-micro
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-12-03 12:36:38 -0800
committerPinapelz <yukais@pinapelz.com>2025-12-03 13:24:50 -0800
commitdb7b14453bfc141eafe6b433147135f057e89868 (patch)
treea5ef6eb91b6b235ee94bb7123dfd857b64da24e5 /indieweb-micro
parent449001b2ef4d971168cd71d921ab29b31d691f6a (diff)
follow script automation
Diffstat (limited to 'indieweb-micro')
-rw-r--r--indieweb-micro/content/indie/follows.md8
-rwxr-xr-xindieweb-micro/make-follow.sh64
2 files changed, 63 insertions, 9 deletions
diff --git a/indieweb-micro/content/indie/follows.md b/indieweb-micro/content/indie/follows.md
index 37af2c4..5a2727a 100644
--- a/indieweb-micro/content/indie/follows.md
+++ b/indieweb-micro/content/indie/follows.md
@@ -9,19 +9,13 @@ This is mostly here for pages that can receive [Webmentions](https://indieweb.or
## Fediverse
{{< follow "https://sakurajima.moe/@Mofumatic" "2025-12-03" >}}
-{{< follow "https://sakurajima.moe/@anianimalsmoe" "2025-12-03" >}}
{{< follow "https://mathstodon.xyz/@tao" "2025-12-03" >}}
{{< follow "https://sakurajima.moe/@chikorita157" "2025-12-03" >}}
-{{< follow "https://misskey.io/@CAP_Tw" "2025-12-03" >}}
-{{< follow "https://misskey.io/@meeeeeeco" "2025-12-03" >}}
{{< follow "https://sakurajima.moe/@sakurajima" "2025-12-03" >}}
-{{< follow "https://mi.shiromaru.work/@ovoip" "2025-12-03" >}}
{{< follow "https://floss.social/@kde" "2025-12-03" >}}
-{{< follow "https://misskey.io/@sateralate723" "2025-12-03" >}}
-{{< follow "https:///mstdn.social/@BrodieOnLinux" "2025-12-03" >}}
+{{< follow "https://mastodon.social/@gamingonlinux" "2025-12-03" >}}
## Bluesky
-{{< follow "https://bsky.app/profile/mofu.run" "2025-12-03" >}}
{{< follow "https://bsky.app/profile/anew.social" "2025-12-03" >}}
> Learn more about the [Indieweb](https://indieweb.org)
diff --git a/indieweb-micro/make-follow.sh b/indieweb-micro/make-follow.sh
index b72fc9d..b7acb2c 100755
--- a/indieweb-micro/make-follow.sh
+++ b/indieweb-micro/make-follow.sh
@@ -5,12 +5,21 @@ today=$(date '+%Y-%m-%d')
# Check if URL is provided as argument
if [ $# -eq 0 ]; then
- echo "Usage: $0 <url>"
+ echo "Usage: $0 <url> [markdown_file]"
echo "Example: $0 https://sakurajima.moe/@sakurajima"
+ echo "Example: $0 @user@site.com content/indie/follows.md"
exit 1
fi
url="$1"
+markdown_file="${2:-content/indie/follows.md}"
+
+# Handle @user@site.com format by remapping to https://site.com/@user
+if [[ $url =~ ^@([^@]+)@(.+)$ ]]; then
+ username="${BASH_REMATCH[1]}"
+ domain="${BASH_REMATCH[2]}"
+ url="https://$domain/@$username"
+fi
# Append https if not present
if [[ ! $url =~ ^https?:// ]]; then
@@ -26,5 +35,56 @@ if [[ $url =~ ^https://[^/]+/@[^@]+@([^/]+)$ ]]; then
url="https://$remote_domain/@$username"
fi
+# Determine the category based on URL
+if [[ $url =~ ^https://bsky\.app/ ]]; then
+ category="Bluesky"
+elif [[ $url =~ ^https://[^/]+/@[^/]+$ ]]; then
+ category="Fediverse"
+else
+ category="Indieweb"
+fi
+
# Generate the follow shortcode
-echo "{{< follow \"$url\" \"$today\" >}}"
+follow_line="{{< follow \"$url\" \"$today\" >}}"
+
+# If markdown file is provided, append to the appropriate section
+if [ "$2" != "" ] || [ -f "$markdown_file" ]; then
+ if [ ! -f "$markdown_file" ]; then
+ echo "Error: Markdown file '$markdown_file' not found"
+ exit 1
+ fi
+
+ # Find the line number of the category section
+ section_line=$(grep -n "^## $category" "$markdown_file" | cut -d: -f1)
+
+ if [ -z "$section_line" ]; then
+ echo "Error: Section '## $category' not found in $markdown_file"
+ exit 1
+ fi
+
+ # Find the end of the section (next ## header or end of file)
+ next_section_line=$(tail -n +"$((section_line + 1))" "$markdown_file" | grep -n "^## " | head -1 | cut -d: -f1)
+
+ if [ -z "$next_section_line" ]; then
+ # No next section found, append at end of file
+ end_line=$(wc -l < "$markdown_file")
+ else
+ # Calculate actual line number of next section
+ end_line=$((section_line + next_section_line - 1))
+ fi
+
+ # Create a temporary file with the new follow added at the end of the section
+ temp_file=$(mktemp)
+ head -n "$((end_line - 1))" "$markdown_file" > "$temp_file"
+ echo "$follow_line" >> "$temp_file"
+ tail -n +"$end_line" "$markdown_file" >> "$temp_file"
+
+ # Replace the original file
+ mv "$temp_file" "$markdown_file"
+
+ echo "Added follow to $category section in $markdown_file:"
+else
+ echo "Follow shortcode (not added to file):"
+fi
+
+echo "$follow_line"
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage