๐Ÿ“ฆโž”๐Ÿฆ‹ Store and retrieve files on the Atmosphere
35
fork

Configure Feed

Select the types of activity you want to include in your feed.

various

Ducky e4a465a4 2abf5c49

+188 -69
+188 -69
atfile.sh
··· 1521 1521 fi 1522 1522 } 1523 1523 1524 - function atfile.invoke.update() { 1525 - function atfile.invoke.update.parse_version() { 1526 - version="$1" 1527 - version="$(echo $version | cut -d "+" -f 1)" 1528 - v_major="$(printf "%04d\n" "$(echo $version | cut -d "." -f 1)")" 1529 - v_minor="$(printf "%04d\n" "$(echo $version | cut -d "." -f 2)")" 1530 - v_rev="$(printf "%04d\n" "$(echo $version | cut -d "." -f 3)")" 1531 - echo "$(echo ${v_major}${v_minor}${v_rev} | sed 's/^0*//')" 1532 - } 1524 + function atfile.util.get_app_url_for_at_uri() { 1525 + uri="$1" 1526 + 1527 + actor="$(echo $uri | cut -d / -f 3)" 1528 + collection="$(echo $uri | cut -d / -f 4)" 1529 + rkey="$(echo $uri | cut -d / -f 5)" 1533 1530 1534 - if [[ $_output_json == 1 ]]; then 1535 - atfile.die "Command not available as JSON" 1531 + ignore_url_validation=0 1532 + resolved_actor="$(atfile.util.resolve_identity "$actor")" 1533 + unset actor_handle 1534 + unset actor_pds 1535 + unset resolved_url 1536 + 1537 + if [[ $? == 0 ]]; then 1538 + actor="$(echo "$resolved_actor" | cut -d "|" -f 1)" 1539 + actor_handle="$(echo "$resolved_actor" | cut -d "|" -f 3 | cut -d "/" -f 3)" 1540 + actor_pds="$(echo "$resolved_actor" | cut -d "|" -f 2)" 1541 + else 1542 + unset actor 1536 1543 fi 1537 - 1538 - atfile.say.debug "Getting latest release..." 1539 - latest_release="$(curl -s -H "User-Agent $_uas" "https://api.github.com/repos/$_gh_user/$_gh_repo/releases/latest")" 1540 - [[ $? != 0 ]] && atfile.die "Unable to get latest version (is GitHub up?)" 1541 - 1542 - latest_version="$(echo "$latest_release" | jq -r ".name")" 1543 - latest_tag="$(echo "$latest_release" | jq -r ".tag_name")" 1544 - 1545 - parsed_latest_version="$(atfile.invoke.update.parse_version $latest_version)" 1546 - parsed_running_version="$(atfile.invoke.update.parse_version $_version)" 1547 - 1548 - atfile.say.debug "Version\nโ†ณ Latest: $latest_version ($parsed_latest_version)\n โ†ณ Tag: $latest_tag\nโ†ณ Running: $_version ($parsed_running_version)" 1549 - 1550 - if [[ $_version == *+git* ]]; then 1551 - atfile.die "Cannot update Git version ($_version)" 1544 + 1545 + [[ -z "$rkey" ]] && rkey="self" 1546 + 1547 + if [[ -n "$actor" && -n "$collection" && -n "$rkey" ]]; then 1548 + case "$collection" in 1549 + "app.bsky.actor.profile") resolved_url="https://bsky.app/profile/$actor" ;; 1550 + "app.bsky.feed.generator") resolved_url="https://bsky.app/profile/$actor/feed/$rkey" ;; 1551 + "app.bsky.graph.list") resolved_url="https://bsky.app/profile/$actor/lists/$rkey" ;; 1552 + "app.bsky.graph.starterpack") resolved_url="https://bsky.app/starter-pack/$actor/$rkey" ;; 1553 + "app.bsky.feed.post") resolved_url="https://bsky.app/profile/$actor/post/$rkey" ;; 1554 + "blue.linkat.board") ignore_url_validation=1 && resolved_url="https://linkat.blue/$actor_handle" ;; 1555 + "blue.zio.atfile.lock") ignore_url_validation=1 && resolved_url="atfile://$actor/upload/$rkey" ;; 1556 + "blue.zio.atfile.upload") ignore_url_validation=1 && resolved_url="atfile://$actor/upload/$rkey" ;; 1557 + "chat.bsky.actor.declaration") resolved_url="https://bsky.app/messages/settings" ;; 1558 + "com.shinolabs.pinksea.oekaki") resolved_url="https://pinksea.art/$actor/oekaki/$rkey" ;; 1559 + "com.whtwnd.blog.entry") resolved_url="https://whtwnd.com/$actor/$rkey" ;; 1560 + "events.smokesignal.app.profile") resolved_url="https://smokesignal.events/$actor" ;; 1561 + "events.smokesignal.calendar.event") resolved_url="https://smokesignal.events/$actor/$rkey" ;; 1562 + "fyi.unravel.frontpage.post") resolved_url="https://frontpage.fyi/post/$actor/$rkey" ;; 1563 + "app.bsky.feed.like"| \ 1564 + "app.bsky.feed.postgate"| \ 1565 + "app.bsky.feed.repost"| \ 1566 + "app.bsky.feed.threadgate"| \ 1567 + "app.bsky.graph.follow"| \ 1568 + "app.bsky.graph.listblock"| \ 1569 + "app.bsky.graph.listitem"| \ 1570 + "events.smokesignal.calendar.rsvp"| \ 1571 + "fyi.unravel.frontpage.comment"| \ 1572 + "fyi.unravel.frontpage.vote") 1573 + record="$(atfile.xrpc.get "com.atproto.repo.getRecord" "repo=$actor&collection=$collection&rkey=$rkey" "" "$actor_pds")" 1574 + 1575 + if [[ "$(atfile.util.is_xrpc_success $? "$record")" == 1 ]]; then 1576 + case "$collection" in 1577 + "app.bsky.feed.like") 1578 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 1579 + "app.bsky.feed.postgate") 1580 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.post')")" ;; 1581 + "app.bsky.feed.repost") 1582 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 1583 + "app.bsky.feed.threadgate") 1584 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.post')")" ;; 1585 + "app.bsky.graph.follow") 1586 + resolved_url="https://bsky.app/profile/$(echo "$record" | jq -r '.value.subject')" ;; 1587 + "app.bsky.graph.listblock") 1588 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject')")" ;; 1589 + "app.bsky.graph.listitem") 1590 + resolved_url="https://bsky.app/profile/$(echo "$record" | jq -r '.value.subject')" ;; 1591 + "events.smokesignal.calendar.rsvp") 1592 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 1593 + "fyi.unravel.frontpage.comment") 1594 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.post.uri')")/$actor/$rkey" ;; 1595 + "fyi.unravel.frontpage.vote") 1596 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 1597 + esac 1598 + fi 1599 + ;; 1600 + esac 1601 + elif [[ -n "$actor" ]]; then 1602 + resolved_url="https://pdsls.dev/at/$actor" 1552 1603 fi 1553 - 1554 - if [[ $(( $parsed_latest_version > $parsed_running_version )) == 1 ]]; then 1555 - temp_updated_path="$_prog_dir/${_prog}-${latest_version}.tmp" 1556 - 1557 - atfile.say.debug "Touching temporary path ($temp_updated_path)..." 1558 - touch "$temp_updated_path" 1559 - [[ $? != 0 ]] && atfile.die "Unable to create temporary file (do you have permission?)" 1560 - 1561 - atfile.say.debug "Downloading latest release..." 1562 - curl -s -o "$temp_updated_path" "https://raw.githubusercontent.com/$_gh_user/$_gh_repo/refs/tags/$latest_tag/atfile.sh" 1563 - if [[ $? == 0 ]]; then 1564 - mv "$temp_updated_path" "$_prog_path" 1565 - if [[ $? != 0 ]]; then 1566 - atfile.die "Unable to update (do you have permission?)" 1567 - else 1568 - chmod +x "$_prog_path" 1569 - atfile.say "๐Ÿ˜Ž Updated to $latest_version!" 1570 - exit 0 1571 - fi 1572 - else 1573 - atfile.die "Unable to download latest version" 1604 + 1605 + if [[ -n "$resolved_url" && $ignore_url_validation == 0 ]]; then 1606 + if [[ $(atfile.util.is_url_okay "$resolved_url") == 0 ]]; then 1607 + unset resolved_url 1574 1608 fi 1609 + fi 1610 + 1611 + echo "$resolved_url" 1612 + } 1613 + 1614 + function atfile.invoke.handle() { 1615 + uri="$1" 1616 + 1617 + [[ $_output_json == 1 ]] && atfile.die "Command not available as JSON" 1618 + [[ "$uri" != "at://"* ]] && atfile.die "Invalid AT URI\nโ†ณ Must be 'at://<actor>[/<collection>/<rkey>]'" 1619 + 1620 + app_uri="$(atfile.util.get_app_url_for_at_uri "$uri")" 1621 + [[ -z "$app_uri" ]] && atfile.die "Unable to resolve AT URI to App" 1622 + 1623 + app_proto="$(echo $app_uri | cut -d ":" -f 1)" 1624 + 1625 + if [[ $app_proto == "atfile" ]]; then 1626 + atfile.util.override_actor "$(echo "$app_uri" | cut -d "/" -f 3)" 1627 + 1628 + case "$(echo "$app_uri" | cut -d "/" -f 4)" in 1629 + "upload") 1630 + if [[ -n $TERM ]]; then 1631 + atfile.invoke.get "$(echo "$app_uri" | cut -d "/" -f 5)" 1632 + else 1633 + xdg-open "$(atfile.invoke.get_url "$(echo "$app_uri" | cut -d "/" -f 5)")" 1634 + fi 1635 + ;; 1636 + esac 1575 1637 else 1576 - atfile.say "No updates found" 1638 + xdg-open "$app_uri" 1577 1639 fi 1578 1640 } 1579 1641 ··· 1928 1990 atfile.js.subscribe "$collection" 1929 1991 } 1930 1992 1993 + function atfile.invoke.update() { 1994 + function atfile.invoke.update.parse_version() { 1995 + version="$1" 1996 + version="$(echo $version | cut -d "+" -f 1)" 1997 + v_major="$(printf "%04d\n" "$(echo $version | cut -d "." -f 1)")" 1998 + v_minor="$(printf "%04d\n" "$(echo $version | cut -d "." -f 2)")" 1999 + v_rev="$(printf "%04d\n" "$(echo $version | cut -d "." -f 3)")" 2000 + echo "$(echo ${v_major}${v_minor}${v_rev} | sed 's/^0*//')" 2001 + } 2002 + 2003 + if [[ $_output_json == 1 ]]; then 2004 + atfile.die "Command not available as JSON" 2005 + fi 2006 + 2007 + atfile.say.debug "Getting latest release..." 2008 + latest_release="$(curl -s -H "User-Agent $_uas" "https://api.github.com/repos/$_gh_user/$_gh_repo/releases/latest")" 2009 + [[ $? != 0 ]] && atfile.die "Unable to get latest version (is GitHub up?)" 2010 + 2011 + latest_version="$(echo "$latest_release" | jq -r ".name")" 2012 + latest_tag="$(echo "$latest_release" | jq -r ".tag_name")" 2013 + 2014 + parsed_latest_version="$(atfile.invoke.update.parse_version $latest_version)" 2015 + parsed_running_version="$(atfile.invoke.update.parse_version $_version)" 2016 + 2017 + atfile.say.debug "Version\nโ†ณ Latest: $latest_version ($parsed_latest_version)\n โ†ณ Tag: $latest_tag\nโ†ณ Running: $_version ($parsed_running_version)" 2018 + 2019 + if [[ $_version == *+git* ]]; then 2020 + atfile.die "Cannot update Git version ($_version)" 2021 + fi 2022 + 2023 + if [[ $(( $parsed_latest_version > $parsed_running_version )) == 1 ]]; then 2024 + temp_updated_path="$_prog_dir/${_prog}-${latest_version}.tmp" 2025 + 2026 + atfile.say.debug "Touching temporary path ($temp_updated_path)..." 2027 + touch "$temp_updated_path" 2028 + [[ $? != 0 ]] && atfile.die "Unable to create temporary file (do you have permission?)" 2029 + 2030 + atfile.say.debug "Downloading latest release..." 2031 + curl -s -o "$temp_updated_path" "https://raw.githubusercontent.com/$_gh_user/$_gh_repo/refs/tags/$latest_tag/atfile.sh" 2032 + if [[ $? == 0 ]]; then 2033 + mv "$temp_updated_path" "$_prog_path" 2034 + if [[ $? != 0 ]]; then 2035 + atfile.die "Unable to update (do you have permission?)" 2036 + else 2037 + chmod +x "$_prog_path" 2038 + atfile.say "๐Ÿ˜Ž Updated to $latest_version!" 2039 + exit 0 2040 + fi 2041 + else 2042 + atfile.die "Unable to download latest version" 2043 + fi 2044 + else 2045 + atfile.say "No updates found" 2046 + fi 2047 + } 2048 + 1931 2049 function atfile.invoke.upload() { 1932 2050 file="$(atfile.util.get_file_path "$1")" 1933 2051 recipient="$2" ··· 2067 2185 fi 2068 2186 2069 2187 # ------------------------------------------------------------------------------ 2070 - usage_arguments="<actor> Act upon another ATProto user (either by handle or DID) 2071 - <cursor> Key or CID used as a reference to paginate through lists 2072 - <key> Key of an uploaded file (unique to that user and collection) 2073 - <nick> Nickname 2074 - <recipient> GPG recipient during file encryption 2075 - See 'gpg --help' for more information" 2076 - 2077 2188 usage_commands="upload <file> [<key>] 2078 2189 Upload new file to the PDS 2079 2190 โš ๏ธ ATProto records are public: do not upload sensitive files ··· 2121 2232 update 2122 2233 Check for updates and update if outdated" 2123 2234 2124 - if [[ $_enable_hidden_commands == 1 ]]; then 2125 - usage_commands+="\n\nCommands (Hidden) 2126 - blob list 2235 + usage_commands_tools="blob list 2127 2236 blob upload <path> 2128 - Manage blobs on a repository 2237 + Manage blobs on authenticated repository 2238 + 2239 + handle <at-uri> 2240 + Open at:// URL with relevant App 2129 2241 2130 2242 record add <record-json> [<collection>] 2131 2243 record get <key> [<collection>] [<actor>] ··· 2135 2247 record rm <key> [<collection>] 2136 2248 record rm <at-uri> 2137 2249 Manage records on a repository 2138 - โš ๏ธ Intended for advanced users. Here be dragons 2250 + โš ๏ธ No validation is performed. Here be dragons! 2139 2251 โ„น๏ธ <collection> defaults to '$_nsid_upload' 2140 2252 2141 2253 resolve <actor> ··· 2143 2255 2144 2256 stream <collection> 2145 2257 Stream records from Jetstream" 2146 - fi 2147 2258 2148 2259 usage_envvars="${_envvar_prefix}_USERNAME <string> (required) 2149 2260 Username of the PDS user (handle or DID) ··· 2202 2313 ${_envvar_prefix}_DEBUG <boolยน> (default: $_debug_default) 2203 2314 Print debug outputs 2204 2315 โš ๏ธ When output is JSON (${_envvar_prefix}_OUTPUT_JSON=1), sets to 0 2205 - ${_envvar_prefix}_ENABLE_HIDDEN_COMMANDS <boolยน> (default: $_enable_hidden_commands_default) 2206 - Enable hidden commands 2207 - โš ๏ธ When sourcing, sets to 1 2208 2316 2209 2317 ยน A bool in Bash is 1 (true) or 0 (false) 2210 2318 ยฒ These servers are ran by @ducky.ws (and @astra.blue). You can trust us!" ··· 2214 2322 on the shell (with \`export \$ATFILE_VARIABLE\`) overrides these values 2215 2323 2216 2324 $_cache_dir/ 2217 - Cache and temporary storage" 2325 + Cache and temporary storage 2326 + โ„น๏ธ Intended for future use" 2218 2327 2219 2328 usage="ATFile | ๐Ÿ“ฆ โž” ๐Ÿฆ‹ 2220 2329 Store and retrieve files on the ATmosphere ··· 2225 2334 2226 2335 ๐Ÿ˜Ž Stay updated with \`$_prog update\` 2227 2336 2228 - Commands 2337 + Commands (General) 2229 2338 $usage_commands 2230 2339 2231 - Arguments 2232 - $usage_arguments 2340 + Commands (Tools) 2341 + $usage_commands_tools 2233 2342 2234 2343 Environment Variables 2235 2344 $usage_envvars ··· 2388 2497 "rm") _command="delete" ;; 2389 2498 "download"|"f"|"d") _command="fetch" ;; 2390 2499 "download-crypt"|"fc"|"dc") _command="fetch-crypt" ;; 2500 + "at") _command="handle" ;; 2391 2501 "get"|"i") _command="info" ;; 2392 2502 "ls") _command="list" ;; 2393 2503 "did") _command="resolve" ;; ··· 2432 2542 fi 2433 2543 2434 2544 # NOTE: Speeds things up a little if the command doesn't need actor resolving 2435 - if [[ $_command == "resolve" ]]; then 2545 + if [[ $_command == "handle" ]] ||\ 2546 + [[ $_command == "resolve" ]]; then 2436 2547 atfile.say.debug "Skipping identity resolving\nโ†ณ Not required for command '$_command'" 2437 2548 skip_resolving=1 2438 2549 fi ··· 2519 2630 fi 2520 2631 2521 2632 atfile.invoke.download "$2" 1 2633 + ;; 2634 + "handle") 2635 + if [[ "$_enable_hidden_commands" == 1 ]]; then 2636 + atfile.invoke.handle "$2" 2637 + else 2638 + atfile.util.print_hidden_command_warning 2639 + exit 1 2640 + fi 2522 2641 ;; 2523 2642 "info") 2524 2643 [[ -z "$2" ]] && atfile.die "<key> not set"