Add invocation code, for actual use
This commit is contained in:
parent
abe60d8b11
commit
dafae250c5
38
fedi2html.sh
38
fedi2html.sh
|
@ -145,6 +145,13 @@ media_attachments() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Pass a post’s context JSON along stdin; out comes the response_data in JSON.
|
||||||
|
# fetch_post_context $url | context_to_responses
|
||||||
|
context_to_responses() {
|
||||||
|
jq -cr '.descendants[]'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# Make a request to the /api/v1/statuses/:id/$request API endpoint.
|
# Make a request to the /api/v1/statuses/:id/$request API endpoint.
|
||||||
# statuses_api_request $post_url $request
|
# statuses_api_request $post_url $request
|
||||||
statuses_api_request() {
|
statuses_api_request() {
|
||||||
|
@ -228,3 +235,34 @@ env_subst() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "usage: $(basename "$0") POST_URL"
|
||||||
|
echo
|
||||||
|
echo "$(basename "$0") does exactly what it says on the tin: It formats"
|
||||||
|
echo "a fediverse post (and its replies) into simple-and-embeddable HTML."
|
||||||
|
echo
|
||||||
|
echo "It works with posts from any server that supports Mastodon’s API,"
|
||||||
|
echo "including Pleroma, Akkoma, Glitch, etc."
|
||||||
|
echo
|
||||||
|
echo "Notably, it supports post-atachments and custom-emoji. Keep in mind"
|
||||||
|
echo "that images are all fetched from remote sources. It is recommended,"
|
||||||
|
echo "if privacy or total archival, is a concern, to use wget(1)’s --mirror"
|
||||||
|
echo "(or something like it) to fetch even these foreign files."
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
URL="$1"
|
||||||
|
|
||||||
|
if test -z "$URL"; then
|
||||||
|
usage 1>&2
|
||||||
|
exit 2
|
||||||
|
elif test "$URL" = "-h" -o "$URL" = "--help"; then
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
POST="$(fetch_post "$URL")"
|
||||||
|
RESPONSES="$(fetch_post_context "$URL" | context_to_responses)"
|
||||||
|
render_post "$POST" "$RESPONSES" 0
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue