commit bacd6ee2f95dfae233f5a74af8447f8021f51e2f Author: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Thu Mar 28 00:43:34 2024 -0500 Init diff --git a/fedi2html.sh b/fedi2html.sh new file mode 100755 index 0000000..1dcb364 --- /dev/null +++ b/fedi2html.sh @@ -0,0 +1,124 @@ +#!/bin/sh +#――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― +# Name: fedi2html.sh +# Desc: +# Reqs: +# Date: +#――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― + + +url_id() { + local url="$1" + # Pleroma-style URLs: https://jam.xwx.moe/notice/Ac6PIZAP0ZzkMTYBBg + # Mastodon-style URLs: https://esperanto.masto.host/@minjo/111461250815264185 + if echo "$url" | grep "/notice/" > /dev/null; then + echo "$url" \ + | sed 's%.*/notice/%%' + else + echo "$url" \ + | sed 's%.*/@[[:alnum:]]*/%%' + fi +} + + +url_server() { + local url="$1" + local protocol="$(echo "$url" | grep --only-matching '[[:alnum:]]*://')" + printf "$protocol" + echo "$url" \ + | sed 's%^'"$protocol"'%%' \ + | sed 's%/.*%%' +} + + +statuses_api_request() { + local post_url="$1" + local api_request="$2" + if test -n "$api_request"; then + api_request="/$api_request" + fi + + local id="$(url_id "$url")" + local server="$(url_server "$url")" + curl --location --header 'Accept: application/json,application/activity+json' \ + "$server/api/v1/statuses/${id}${api_request}" +} + + +fetch_post_context() { + local url="$1" + statuses_api_request "$url" "context" +} + + +fetch_post() { + local url="$1" + statuses_api_request "$url" +} + + +POST_TEMPLATE=' + + +
+ +