From a3ee7cab96fbabc22e550fa884d4342b98ae8776 Mon Sep 17 00:00:00 2001 From: Ducky Date: Sat, 24 May 2025 15:35:17 +0100 Subject: [PATCH] add support for alt social apps (with _ENDPOINT_SOCIAL_APP) --- src/commands/bsky_profile.sh | 2 +- src/commands/help.sh | 6 ++++-- src/commands/old_cmds.sh | 6 ++++-- src/commands/something_broke.sh | 2 ++ src/commands/update.sh | 3 ++- src/entry.sh | 23 +++++++++++++++-------- src/shared/util.sh | 26 ++++++++++++++++++-------- 7 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/commands/bsky_profile.sh b/src/commands/bsky_profile.sh index 9e5d5a0..9e16d83 100644 --- a/src/commands/bsky_profile.sh +++ b/src/commands/bsky_profile.sh @@ -90,7 +90,7 @@ function atfile.bsky_profile() { 📃 $count_posts $(atfile.util.get_int_suffix "$count_followers" "\e[37mPost\e[0m" "\e[37mPosts\e[0m") ∙ ⚙️ $count_feeds $(atfile.util.get_int_suffix "$count_feeds" "\e[37mFeed\e[0m" "\e[37mFeeds\e[0m") ∙ 📋 $count_lists $(atfile.util.get_int_suffix "$count_lists" "\e[37mList\e[0m" "\e[37mLists\e[0m") ∙ 👥 $count_packs $(atfile.util.get_int_suffix "$count_packs" "\e[37mPack\e[0m" "\e[37mPacks\e[0m") $type ∙ ✨ $date_created ∙ 🕷️ $date_indexed \e[37m$(atfile.util.repeat_char "-" 3)\e[0m - 🦋 https://bsky.app/profile/$actor\n" + 🦋 $_endpoint_social_app/profile/$actor\n" if [[ "$date_indexed" == "0001-01-01 00:00:00" ]]; then atfile.die "No Bluesky profile for '$actor'" diff --git a/src/commands/help.sh b/src/commands/help.sh index e563dcb..9cb5845 100644 --- a/src/commands/help.sh +++ b/src/commands/help.sh @@ -105,7 +105,7 @@ function atfile.help() { ${_envvar_prefix}_PASSWORD (required) Password of the PDS user ℹ️ An App Password is recommended - (https://bsky.app/settings/app-passwords)\n + ($_endpoint_social_app/settings/app-passwords)\n ${_envvar_prefix}_ENABLE_FINGERPRINT (default: $_enable_fingerprint_default) Apply machine fingerprint to uploaded files ${_envvar_prefix}_OUTPUT_JSON (default: $_output_json_default) @@ -157,6 +157,8 @@ function atfile.help() { resolving fails) ${_envvar_prefix}_ENDPOINT_PLC_DIRECTORY (default: ${_endpoint_plc_directory_default}$([[ $_endpoint_plc_directory_default == *"zio.blue" ]] && echo "²")) Endpoint of the PLC directory + ${_envvar_prefix}_ENDPOINT_SOCIAL_APP (default: ${_endpoint_social_app_default}) + Endpoint of the Bluesky (or compatible) social app ${_envvar_prefix}_DISABLE_PBC_FALLBACK (default: $_disable_pbc_fallback) Disable the (hardcoded) usage of various Bluesky PBC-hosted fallbacks if/when required. Currently, there are fallbacks for: @@ -190,7 +192,7 @@ function atfile.help() { (c) $_meta_year $_meta_author <$_meta_repo> Licensed as MIT License ✨\n 🦋 Follow @$handle on the ATmosphere - ↳ Bluesky: https://bsky.app/profile/$handle + ↳ $_endpoint_social_app_name: $_endpoint_social_app/profile/$handle ↳ Tangled: https://tangled.sh/@$handle Usage diff --git a/src/commands/old_cmds.sh b/src/commands/old_cmds.sh index 72798b3..af35ce0 100644 --- a/src/commands/old_cmds.sh +++ b/src/commands/old_cmds.sh @@ -333,7 +333,8 @@ function atfile.invoke.handle_atfile() { [ -x "$(command -v xdg-open)" ] && \ [ -x "$(command -v gtk-launch)" ]; then - [[ -z $file_type ]] && file_type="text/html" # HACK: Open with browser if $file_type isn't set + # HACK: Open with browser if $file_type isn't set + [[ -z $file_type ]] && file_type="text/html" if [[ -z $handler ]]; then atfile.say.debug "Querying for handler '$file_type'..." @@ -455,7 +456,8 @@ function atfile.invoke.list() { json_output+="$c," else if [[ $_os == "haiku" ]]; then - echo -e "$key\t$name" # BUG: Haiku Terminal has issues with emojis + # BUG: Haiku Terminal has issues with emojis + echo -e "$key\t$name" else echo -e "$key\t$type_emoji $name" fi diff --git a/src/commands/something_broke.sh b/src/commands/something_broke.sh index e79cfc2..8b9fdf8 100644 --- a/src/commands/something_broke.sh +++ b/src/commands/something_broke.sh @@ -73,6 +73,7 @@ $(atfile.something_broke.print_envvar "DEVEL_ENTRY") $(for s in "${ATFILE_DEVEL_INCLUDES[@]}"; do echo " ↳ $s"; done) $(atfile.something_broke.print_envvar "DEVEL_SOURCE") $(atfile.something_broke.print_envvar "DEVEL_PUBLISH" "$_devel_publish_default") +$(atfile.something_broke.print_envvar "DISABLE_PBC_FALLBACK" "$_disable_pbc_fallback_default") $(atfile.something_broke.print_envvar "DISABLE_UPDATE_CHECKING" "$_disable_update_checking_default") $(atfile.something_broke.print_envvar "DISABLE_UPDATER" "$_disable_updater_default") ↳ ${_envvar_prefix}_DIST_PASSWORD: $([[ -n $(atfile.util.get_envvar "${_envvar_prefix}_DIST_PASSWORD") ]] && echo "(Set)") @@ -83,6 +84,7 @@ $(atfile.something_broke.print_envvar "ENDPOINT_APPVIEW" "$_endpoint_appview_def $(atfile.something_broke.print_envvar "ENDPOINT_JETSTREAM" "$_endpoint_jetstream_default") $(atfile.something_broke.print_envvar "ENDPOINT_PDS") $(atfile.something_broke.print_envvar "ENDPOINT_PLC_DIRECTORY" "$_endpoint_plc_directory_default") +$(atfile.something_broke.print_envvar "ENDPOINT_SOCIAL_APP" "$_endpoint_social_app_default") $(atfile.something_broke.print_envvar "FMT_BLOB_URL" "$_fmt_blob_url_default") $(atfile.something_broke.print_envvar "FMT_OUT_FILE" "$_fmt_out_file_default") $(atfile.something_broke.print_envvar "FORCE_META_AUTHOR") diff --git a/src/commands/update.sh b/src/commands/update.sh index 47b98bf..1ffbac6 100644 --- a/src/commands/update.sh +++ b/src/commands/update.sh @@ -65,8 +65,9 @@ function atfile.update() { echo "---" if [[ $_os == "haiku" ]]; then + # BUG: Haiku Terminal has issues with emojis # shellcheck disable=SC2154 - atfile.say "Update available ($latest_version)\n↳ Run \`$_prog update\` to update" # BUG: Haiku Terminal has issues with emojis + atfile.say "Update available ($latest_version)\n↳ Run \`$_prog update\` to update" else atfile.say "😎 Update available ($latest_version)\n ↳ Run \`$_prog update\` to update" fi diff --git a/src/entry.sh b/src/entry.sh index 3a3fd3b..24227e8 100644 --- a/src/entry.sh +++ b/src/entry.sh @@ -87,6 +87,7 @@ _endpoint_appview_default="https://api.bsky.app" #_endpoint_jetstream_default="wss://stream.zio.blue" _endpoint_jetstream_default="$_endpoint_jetstream_fallback" _endpoint_plc_directory_default="https://plc.zio.blue" +_endpoint_social_app_default="https://bsky.app" _fmt_blob_url_default="[server]/xrpc/com.atproto.sync.getBlob?did=[did]&cid=[cid]" _fmt_out_file_default="[key]__[name]" _enable_fingerprint_default=0 @@ -114,6 +115,7 @@ _enable_update_git_clobber="$(atfile.util.get_envvar "${_envvar_prefix}_ENABLE_U _endpoint_appview="$(atfile.util.get_envvar "${_envvar_prefix}_ENDPOINT_APPVIEW" "$_endpoint_appview_default")" _endpoint_jetstream="$(atfile.util.get_envvar "${_envvar_prefix}_ENDPOINT_JETSTREAM" "$_endpoint_jetstream_default")" _endpoint_plc_directory="$(atfile.util.get_envvar "${_envvar_prefix}_ENDPOINT_PLC_DIRECTORY" "$_endpoint_plc_directory_default")" +_endpoint_social_app="$(atfile.util.get_envvar "${_envvar_prefix}_ENDPOINT_SOCIAL_APP" "$_endpoint_social_app_default")" _fmt_blob_url="$(atfile.util.get_envvar "${_envvar_prefix}_FMT_BLOB_URL" "$_fmt_blob_url_default")" _fmt_out_file="$(atfile.util.get_envvar "${_envvar_prefix}_FMT_OUT_FILE" "$_fmt_out_file_default")" _force_meta_author="$(atfile.util.get_envvar "${_envvar_prefix}_FORCE_META_AUTHOR")" @@ -136,12 +138,17 @@ _password="$(atfile.util.get_envvar "${_envvar_prefix}_PASSWORD")" _test_desktop_uas="Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0" _username="$(atfile.util.get_envvar "${_envvar_prefix}_USERNAME")" -### NSIDs +### Read-only _nsid_prefix="blue.zio" _nsid_lock="${_nsid_prefix}.atfile.lock" _nsid_meta="${_nsid_prefix}.atfile.meta" _nsid_upload="${_nsid_prefix}.atfile.upload" +_endpoint_social_app_name="Bluesky" + +case "$_endpoint_social_app" in + "https://deer.social") _endpoint_social_app_name="Deer" ;; +esac ## "Hello, world!" @@ -167,26 +174,26 @@ fi [[ -n $_force_meta_author ]] && \ _meta_author="$_force_meta_author" &&\ - atfile.say.debug "Overriding Copyright Author (\$_meta_author)\n↳ ${_envvar_prefix}_FORCE_META_AUTHOR set to '$_force_meta_author'" + atfile.util.print_override_envvar_debug "Copyright Author" "_meta_author" [[ -n $_force_meta_did ]] && \ _meta_did="$_force_meta_did" &&\ _dist_username="$(atfile.util.get_envvar "${_envvar_prefix}_DIST_USERNAME" "$_meta_did")" &&\ - atfile.say.debug "Overriding DID (\$_meta_did)\n↳ ${_envvar_prefix}_FORCE_META_DID set to '$_force_meta_did'" + atfile.util.print_override_envvar_debug "DID" "_meta_did" [[ -n $_force_meta_repo ]] && \ _meta_repo="$_force_meta_repo" &&\ - atfile.say.debug "Overriding Repo URL (\$_meta_repo)\n↳ ${_envvar_prefix}_FORCE_META_REPO set to '$_force_meta_repo'" + atfile.util.print_override_envvar_debug "Repo URL" "_meta_author" [[ -n $_force_meta_year ]] && \ _meta_year="$_force_meta_year" &&\ - atfile.say.debug "Overriding Copyright Year (\$_meta_year)\n↳ ${_envvar_prefix}_FORCE_META_YEAR set to '$_force_meta_year'" + atfile.util.print_override_envvar_debug "Copyright Year" "_meta_year" [[ -n $_force_now ]] && \ _now="$_force_now" &&\ - atfile.say.debug "Overriding Now (\$_now)\n↳ ${_envvar_prefix}_FORCE_NOW set to '$_force_now'" + atfile.util.print_override_envvar_debug "Current Time" "_now" [[ -n $_force_os ]] &&\ _os="$_force_os" &&\ - atfile.say.debug "Overriding OS (\$_os)\n↳ ${_envvar_prefix}_FORCE_OS set to '$_force_os'" + atfile.util.print_override_envvar_debug "OSL" "_os" [[ -n $_force_version ]] && \ _version="$_force_version" &&\ - atfile.say.debug "Overriding Version (\$_version)\n↳ ${_envvar_prefix}_FORCE_VERSION set to '$_force_version'" + atfile.util.print_override_envvar_debug "Version" "_version" ### Validation diff --git a/src/shared/util.sh b/src/shared/util.sh index 4035715..38054dd 100644 --- a/src/shared/util.sh +++ b/src/shared/util.sh @@ -114,14 +114,14 @@ function atfile.util.get_app_url_for_at_uri() { if [[ -n "$actor" && -n "$collection" && -n "$rkey" ]]; then case "$collection" in - "app.bsky.actor.profile") resolved_url="https://bsky.app/profile/$actor" ;; - "app.bsky.feed.generator") resolved_url="https://bsky.app/profile/$actor/feed/$rkey" ;; - "app.bsky.graph.list") resolved_url="https://bsky.app/profile/$actor/lists/$rkey" ;; - "app.bsky.graph.starterpack") resolved_url="https://bsky.app/starter-pack/$actor/$rkey" ;; - "app.bsky.feed.post") resolved_url="https://bsky.app/profile/$actor/post/$rkey" ;; + "app.bsky.actor.profile") resolved_url="$_endpoint_social_app/profile/$actor" ;; + "app.bsky.feed.generator") resolved_url="$_endpoint_social_app/profile/$actor/feed/$rkey" ;; + "app.bsky.graph.list") resolved_url="$_endpoint_social_app/profile/$actor/lists/$rkey" ;; + "app.bsky.graph.starterpack") resolved_url="$_endpoint_social_app/starter-pack/$actor/$rkey" ;; + "app.bsky.feed.post") resolved_url="$_endpoint_social_app/profile/$actor/post/$rkey" ;; "blue.linkat.board") resolved_url="https://linkat.blue/$actor_handle" ;; "blue.zio.atfile.upload") ignore_url_validation=1 && resolved_url="atfile://$actor/$rkey" ;; - "chat.bsky.actor.declaration") resolved_url="https://bsky.app/messages/settings" ;; + "chat.bsky.actor.declaration") resolved_url="$_endpoint_social_app/messages/settings" ;; "com.shinolabs.pinksea.oekaki") resolved_url="https://pinksea.art/$actor/oekaki/$rkey" ;; "com.whtwnd.blog.entry") resolved_url="https://whtwnd.com/$actor/$rkey" ;; "events.smokesignal.app.profile") resolved_url="https://smokesignal.events/$actor" ;; @@ -151,11 +151,11 @@ function atfile.util.get_app_url_for_at_uri() { "app.bsky.feed.threadgate") resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.post')")" ;; "app.bsky.graph.follow") - resolved_url="https://bsky.app/profile/$(echo "$record" | jq -r '.value.subject')" ;; + resolved_url="$_endpoint_social_app/profile/$(echo "$record" | jq -r '.value.subject')" ;; "app.bsky.graph.listblock") resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject')")" ;; "app.bsky.graph.listitem") - resolved_url="https://bsky.app/profile/$(echo "$record" | jq -r '.value.subject')" ;; + resolved_url="$_endpoint_social_app/profile/$(echo "$record" | jq -r '.value.subject')" ;; "events.smokesignal.calendar.rsvp") resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; "fyi.unravel.frontpage.comment") @@ -1032,6 +1032,16 @@ function atfile.util.print_copyright_warning() { fi } +function atfile.util.print_override_envvar_debug() { + pretty_name="$1" + override_variable="$2" + + override_value="$(eval echo "\$_force${override_variable}")" + envvar_suffix="_FORCE${override_variable^^}" + + atfile.say.debug "Overriding $pretty_name (\$$override_variable)\n↳ ${_envvar_prefix}$envvar_suffix set to '$override_value'" +} + function atfile.util.print_seconds_since_start_debug() { seconds=$(atfile.util.get_seconds_since_start) second_unit="$(atfile.util.get_int_suffix "$seconds" "second" "seconds")" -- 2.51.2