From 849b32bf42eb8a3f600fed555c48c29dd7b9c694 Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 1 Jun 2025 22:34:07 -0400 Subject: Add mastodon posting script --- www/photo.causal.agency/.gitignore | 5 +++- www/photo.causal.agency/mastodon.sh | 54 +++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 www/photo.causal.agency/mastodon.sh (limited to 'www/photo.causal.agency') diff --git a/www/photo.causal.agency/.gitignore b/www/photo.causal.agency/.gitignore index 4e55d718..e6e1a830 100644 --- a/www/photo.causal.agency/.gitignore +++ b/www/photo.causal.agency/.gitignore @@ -1,3 +1,6 @@ -*.JPG *.jpg +*.JPG +app.json +posted.txt static/ +token.json diff --git a/www/photo.causal.agency/mastodon.sh b/www/photo.causal.agency/mastodon.sh new file mode 100644 index 00000000..1eaa1114 --- /dev/null +++ b/www/photo.causal.agency/mastodon.sh @@ -0,0 +1,54 @@ +#!/bin/sh +set -eu + +Instance=https://tilde.zone +Root=${1:-static} + +if ! test -f app.json; then + echo 'No app.json!' >&2 + exit 1 +fi +chmod 600 app.json + +if ! test -f token.json; then + client_id=$(jq -r .client_id app.json) + client_secret=$(jq -r .client_secret app.json) + echo "Please open ${Instance}/oauth/authorize?client_id=${client_id}&scope=write&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code" + printf 'Enter code: ' + read -r code + curl -Ss -X POST \ + -F 'grant_type=authorization_code' \ + -F "client_id=${client_id}" \ + -F "client_secret=${client_secret}" \ + -F 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \ + -F "code=${code}" \ + ${Instance}/oauth/token >token.json +fi +chmod 600 token.json + +access_token=$(jq -r .access_token token.json) + +if ! test -f posted.txt; then + touch posted.txt +fi + +photo=$( + find ${Root} -type f -path '*/0*/*.jpg' | + sort | comm -13 posted.txt - | head -n 1 +) +preview=${Root}/preview/${photo##*/} + +media_id=$( + curl -Ss -X POST \ + -H "Authorization: Bearer ${access_token}" \ + -F "file=@${preview}" \ + ${Instance}/api/v2/media | + jq -r .id +) + +curl -Ss -X POST \ + -H "Authorization: Bearer ${access_token}" \ + -F "media_ids[]=${media_id}" \ + ${Instance}/api/v1/statuses >/dev/null + +echo ${photo} >>posted.txt -- cgit 1.4.1 592a7c029fc581cc5844c&showmsg=1&follow=1'>bin/cash/libedit/histedit.h (unfollow)
Commit message (Collapse)Author
2019-02-20Move /opt/pkg after /usr in PATHJune McEnroe
Installing mandoc from pkgsrc also installs a man executable which is horribly broken. Keep using the system man.
2019-02-20Set man_hard_wrap in nvimJune McEnroe
Vendoring man.vim until <https://github.com/neovim/neovim/pull/9633> is merged and appears in a release.
2019-02-18Use hi -o anchor in upJune McEnroe
2019-02-18Don't match nested parentheses in Tag for CJune McEnroe
Fixes mistaken highlight of: pngWrite(file, (uint8_t []) { 0, 0, 0 }, 3);
2019-02-18Match whitespace between * [] {}June McEnroe
2019-02-18Fix function-like #define regexJune McEnroe
A define like #define FOO (1) is not function-like.
2019-02-18Match Tag in RustJune McEnroe
2019-02-18Match sh functions as TagJune McEnroe
2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe
2019-02-18Match statics and typedefs as TagJune McEnroe
2019-02-18Clean up htmlHeaderJune McEnroe
2019-02-18Remove hi line numberingJune McEnroe
Tags are much better for referring to specific parts of a file and line numbering is better done by a post-processing tool such as cat -n or producing a two-column HTML <table>.
2019-02-18Add Tag class to hiJune McEnroe
2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe
Running hi twice to insert stuff between the head and the content is a bit of a hack but oh well.
2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe
2019-02-17Simplify temp trap in upJune McEnroe
2019-02-17Add line numbers to hiJune McEnroe
Renames previous -n option to -m to stay consistent with cat -n. Prefixing lines with line numbers affects where the first tab indent ends up relative to the text above it. Not sure if it's worth fixing somehow.
2019-02-17Always split spans after newlinesJune McEnroe
Simplifies ANSI and IRC output code, and prepares for line numbered output.
2019-02-15Color format specifiers light cyan in vimJune McEnroe
2019-02-15Highlight Interp as yellowJune McEnroe
2019-02-15Highlight strings in sh command substitutionsJune McEnroe
2019-02-15Add nmap gpJune McEnroe
2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe
2019-02-13Add forgotten "sixth" book of H2G2June McEnroe