๐Ÿ“ฆโž”๐Ÿฆ‹ 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 6c2bb515 e4a465a4

+142 -102
+142 -102
atfile.sh
··· 110 110 [[ $_skip_ni_mediainfo == 0 ]] && atfile.util.check_prog "mediainfo" "https://mediaarea.net/en/MediaInfo" "${_envvar_prefix}_SKIP_NI_MEDIAINFO" 111 111 } 112 112 113 + function atfile.util.get_app_url_for_at_uri() { 114 + uri="$1" 115 + 116 + actor="$(echo $uri | cut -d / -f 3)" 117 + collection="$(echo $uri | cut -d / -f 4)" 118 + rkey="$(echo $uri | cut -d / -f 5)" 119 + 120 + ignore_url_validation=0 121 + resolved_actor="$(atfile.util.resolve_identity "$actor")" 122 + unset actor_handle 123 + unset actor_pds 124 + unset resolved_url 125 + 126 + if [[ $? == 0 ]]; then 127 + actor="$(echo "$resolved_actor" | cut -d "|" -f 1)" 128 + actor_handle="$(echo "$resolved_actor" | cut -d "|" -f 3 | cut -d "/" -f 3)" 129 + actor_pds="$(echo "$resolved_actor" | cut -d "|" -f 2)" 130 + else 131 + unset actor 132 + fi 133 + 134 + [[ -z "$rkey" ]] && rkey="self" 135 + 136 + if [[ -n "$actor" && -n "$collection" && -n "$rkey" ]]; then 137 + case "$collection" in 138 + "app.bsky.actor.profile") resolved_url="https://bsky.app/profile/$actor" ;; 139 + "app.bsky.feed.generator") resolved_url="https://bsky.app/profile/$actor/feed/$rkey" ;; 140 + "app.bsky.graph.list") resolved_url="https://bsky.app/profile/$actor/lists/$rkey" ;; 141 + "app.bsky.graph.starterpack") resolved_url="https://bsky.app/starter-pack/$actor/$rkey" ;; 142 + "app.bsky.feed.post") resolved_url="https://bsky.app/profile/$actor/post/$rkey" ;; 143 + "blue.linkat.board") ignore_url_validation=1 && resolved_url="https://linkat.blue/$actor_handle" ;; 144 + "blue.zio.atfile.lock") ignore_url_validation=1 && resolved_url="atfile://$actor/upload/$rkey" ;; 145 + "blue.zio.atfile.upload") ignore_url_validation=1 && resolved_url="atfile://$actor/upload/$rkey" ;; 146 + "chat.bsky.actor.declaration") resolved_url="https://bsky.app/messages/settings" ;; 147 + "com.shinolabs.pinksea.oekaki") resolved_url="https://pinksea.art/$actor/oekaki/$rkey" ;; 148 + "com.whtwnd.blog.entry") resolved_url="https://whtwnd.com/$actor/$rkey" ;; 149 + "events.smokesignal.app.profile") resolved_url="https://smokesignal.events/$actor" ;; 150 + "events.smokesignal.calendar.event") resolved_url="https://smokesignal.events/$actor/$rkey" ;; 151 + "fyi.unravel.frontpage.post") resolved_url="https://frontpage.fyi/post/$actor/$rkey" ;; 152 + "app.bsky.feed.like"| \ 153 + "app.bsky.feed.postgate"| \ 154 + "app.bsky.feed.repost"| \ 155 + "app.bsky.feed.threadgate"| \ 156 + "app.bsky.graph.follow"| \ 157 + "app.bsky.graph.listblock"| \ 158 + "app.bsky.graph.listitem"| \ 159 + "events.smokesignal.calendar.rsvp"| \ 160 + "fyi.unravel.frontpage.comment"| \ 161 + "fyi.unravel.frontpage.vote") 162 + record="$(atfile.xrpc.get "com.atproto.repo.getRecord" "repo=$actor&collection=$collection&rkey=$rkey" "" "$actor_pds")" 163 + 164 + if [[ "$(atfile.util.is_xrpc_success $? "$record")" == 1 ]]; then 165 + case "$collection" in 166 + "app.bsky.feed.like") 167 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 168 + "app.bsky.feed.postgate") 169 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.post')")" ;; 170 + "app.bsky.feed.repost") 171 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 172 + "app.bsky.feed.threadgate") 173 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.post')")" ;; 174 + "app.bsky.graph.follow") 175 + resolved_url="https://bsky.app/profile/$(echo "$record" | jq -r '.value.subject')" ;; 176 + "app.bsky.graph.listblock") 177 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject')")" ;; 178 + "app.bsky.graph.listitem") 179 + resolved_url="https://bsky.app/profile/$(echo "$record" | jq -r '.value.subject')" ;; 180 + "events.smokesignal.calendar.rsvp") 181 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 182 + "fyi.unravel.frontpage.comment") 183 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.post.uri')")/$actor/$rkey" ;; 184 + "fyi.unravel.frontpage.vote") 185 + resolved_url="$(atfile.util.get_app_url_for_at_uri "$(echo "$record" | jq -r '.value.subject.uri')")" ;; 186 + esac 187 + fi 188 + ;; 189 + esac 190 + elif [[ -n "$actor" ]]; then 191 + resolved_url="https://pdsls.dev/at/$actor" 192 + fi 193 + 194 + if [[ -n "$resolved_url" && $ignore_url_validation == 0 ]]; then 195 + if [[ $(atfile.util.is_url_okay "$resolved_url") == 0 ]]; then 196 + unset resolved_url 197 + fi 198 + fi 199 + 200 + echo "$resolved_url" 201 + } 202 + 113 203 function atfile.util.get_cache() { 114 204 file="$_cache_dir/$1" 115 205 ··· 528 618 function atfile.util.get_pds_pretty() { 529 619 pds="$1" 530 620 531 - pds="$(echo $pds | cut -d "/" -f 3)" 621 + pds_host="$(echo $pds | cut -d "/" -f 3)" 532 622 533 - if [[ $pds == *".host.bsky.network" ]]; then 534 - pds_host="$(echo $pds | cut -d "." -f 1)" 535 - pds_region="$(echo $pds | cut -d "." -f 2)" 536 - echo "๐Ÿ„ ${pds_host^} ($(atfile.util.get_region_pretty "$pds_region"))" 623 + if [[ $pds_host == *".host.bsky.network" ]]; then 624 + bsky_host="$(echo $pds_host | cut -d "." -f 1)" 625 + bsky_region="$(echo $pds_host | cut -d "." -f 2)" 626 + echo "๐Ÿ„ ${bsky_host^} ($(atfile.util.get_region_pretty "$bsky_region"))" 627 + elif [[ $pds_host == "atproto.brid.gy" ]]; then 628 + echo "๐Ÿ”€ Bridy Fed" 537 629 else 538 - case $pds in 539 - "atproto.brid.gy") echo "๐Ÿ”€ Bridgy Fed" ;; 540 - "extwitter.link") echo "๐Ÿฆ Twitter Mirrors" ;; 541 - "zio.blue") echo "๐ŸŸง @Zio" ;; 542 - *) echo "$pds" ;; 543 - esac 630 + pds_oauth_url="$pds/oauth/authorize" 631 + pds_oauth_page="$(curl -s -L -X GET "$pds_oauth_url")" 632 + pds_customization_data="$(echo $pds_oauth_page | sed -s s/.*_customizationData\"]=//g | sed -s s/\;document\.currentScript\.remove.*//g)" 633 + 634 + if [[ $pds_customization_data == "{"* ]]; then 635 + echo "๐ŸŸฆ $(echo $pds_customization_data | jq -r '.name')" 636 + else 637 + echo "$pds" 638 + fi 544 639 fi 545 640 } 546 641 ··· 1521 1616 fi 1522 1617 } 1523 1618 1524 - function atfile.util.get_app_url_for_at_uri() { 1619 + function atfile.invoke.handle() { 1525 1620 uri="$1" 1526 1621 1527 - actor="$(echo $uri | cut -d / -f 3)" 1528 - collection="$(echo $uri | cut -d / -f 4)" 1529 - rkey="$(echo $uri | cut -d / -f 5)" 1622 + function atfile.invoke.handle.handle_error() { 1623 + cli_error="$1" 1624 + gui_error="$2" 1530 1625 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 1543 - fi 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" 1603 - fi 1626 + [[ -z $gui_error ]] && gui_error="$cli_error" 1604 1627 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 1628 + if [ -x "$(command -v zenity)" ]; then 1629 + zenity --error --text "$gui_error" 1608 1630 fi 1609 - fi 1610 1631 1611 - echo "$resolved_url" 1612 - } 1632 + atfile.die "$cli_error" 1633 + } 1613 1634 1614 - function atfile.invoke.handle() { 1615 - uri="$1" 1635 + function atfile.invoke.handle.launch_xdg() { 1636 + if [[ -n $DISPLAY ]] && [ -x "$(command -v xdg-open)" ]; then 1637 + if [[ $(atfile.util.get_os) == "macos" ]]; then 1638 + open "$app_uri" 1639 + else 1640 + xdg-open "$app_uri" 1641 + fi 1642 + else 1643 + echo "$app_uri" 1644 + fi 1645 + } 1616 1646 1617 1647 [[ $_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>]'" 1648 + [[ "$uri" != "at://"* ]] && atfile.invoke.handle.handle_error \ 1649 + "Invalid AT URI\nโ†ณ Must be 'at://<actor>[/<collection>/<rkey>]'" \ 1650 + "Invalid AT URI" 1619 1651 1652 + atfile.say.debug "Resolving '$uri'..." 1620 1653 app_uri="$(atfile.util.get_app_url_for_at_uri "$uri")" 1621 - [[ -z "$app_uri" ]] && atfile.die "Unable to resolve AT URI to App" 1654 + [[ -z "$app_uri" ]] && atfile.invoke.handle.handle_error \ 1655 + "Unable to resolve AT URI to App" 1622 1656 1623 1657 app_proto="$(echo $app_uri | cut -d ":" -f 1)" 1658 + 1659 + atfile.say.debug "Opening '$app_uri' ($app_proto)..." 1624 1660 1625 1661 if [[ $app_proto == "atfile" ]]; then 1626 1662 atfile.util.override_actor "$(echo "$app_uri" | cut -d "/" -f 3)" 1627 1663 1628 1664 case "$(echo "$app_uri" | cut -d "/" -f 4)" in 1629 - "upload") 1665 + "lock"|"upload") 1630 1666 if [[ -n $TERM ]]; then 1631 1667 atfile.invoke.get "$(echo "$app_uri" | cut -d "/" -f 5)" 1632 1668 else 1633 - xdg-open "$(atfile.invoke.get_url "$(echo "$app_uri" | cut -d "/" -f 5)")" 1669 + atfile.invoke.handle.launch_xdg "$(atfile.invoke.get_url "$(echo "$app_uri" | cut -d "/" -f 5)")" 1634 1670 fi 1635 1671 ;; 1636 1672 esac 1637 1673 else 1638 - xdg-open "$app_uri" 1674 + atfile.invoke.handle.launch_xdg "$app_uri" 1639 1675 fi 1640 1676 } 1641 1677 ··· 1949 1985 pds_name="$(atfile.util.get_pds_pretty "$pds")" 1950 1986 atfile.say.debug "Getting PDS version for '$pds'..." 1951 1987 pds_version="$(curl -s -l -X GET "$pds/xrpc/_health" | jq -r '.version')" 1988 + 1989 + [[ "$did" == "null" ]] && atfile.die "Unable to resolve '$actor'" 1952 1990 1953 1991 case "$did_type" in 1954 1992 "did:web") ··· 2456 2494 2457 2495 ## Git detection 2458 2496 2459 - if [ -x "$(command -v git)" ] && [[ -d "$_prog_dir/.git" ]]; then 2497 + if [ -x "$(command -v git)" ] && [[ -d "$_prog_dir/.git" ]] && [[ "$(realpath $(pwd))" == "$_prog_dir" ]]; then 2460 2498 atfile.say.debug "Getting tag from Git..." 2461 2499 git describe --exact-match --tags > /dev/null 2>&1 2462 2500 [[ $? != 0 ]] && _version+="+git.$(git rev-parse --short HEAD)" ··· 2735 2773 ;; 2736 2774 esac 2737 2775 fi 2776 + 2777 + # lord help me