๐Ÿ“ฆโž”๐Ÿฆ‹ 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 2b2c54b7 845514b1

+74 -36
+14
.vscode/launch.json
··· 1 + { 2 + // Use IntelliSense to learn about possible attributes. 3 + // Hover to view descriptions of existing attributes. 4 + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 + "version": "0.2.0", 6 + "configurations": [ 7 + { 8 + "type": "bashdb", 9 + "request": "launch", 10 + "name": "Debug", 11 + "program": "atfile.sh" 12 + } 13 + ] 14 + }
+60 -36
atfile.sh
··· 81 81 82 82 # Utilities 83 83 84 + function atfile.util.build_blob_uri() { 85 + did="$1" 86 + cid="$2" 87 + pds="$_server" 88 + 89 + echo "$_fmt_blob_url" | sed -e "s|\[pds\]|$pds|g" -e "s|\[server\]|$pds|g" -e "s|\[cid\]|$cid|g" -e "s|\[did\]|$did|g" 90 + } 91 + 92 + function atfile.util.build_out_filename() { 93 + key="$1" 94 + name="$2" 95 + 96 + echo "$_fmt_out_file" | sed -e "s|\[name\]|$name|g" -e "s|\[key\]|$key|g" 97 + } 98 + 84 99 function atfile.util.check_prog() { 85 100 command="$1" 86 101 download_hint="$2" ··· 755 770 fi 756 771 } 757 772 758 - function atfile.util.build_blob_uri() { 759 - did="$1" 760 - cid="$2" 761 - pds="$_server" 773 + function atfile.until.launch_uri() { 774 + uri="$1" 762 775 763 - echo "$_fmt_blob_url" | sed -e "s|\[pds\]|$pds|g" -e "s|\[server\]|$pds|g" -e "s|\[cid\]|$cid|g" -e "s|\[did\]|$did|g" 764 - } 765 - 766 - function atfile.util.build_out_filename() { 767 - key="$1" 768 - name="$2" 769 - 770 - echo "$_fmt_out_file" | sed -e "s|\[name\]|$name|g" -e "s|\[key\]|$key|g" 776 + if [[ -n $DISPLAY ]] && [ -x "$(command -v xdg-open)" ]; then 777 + if [[ $(atfile.util.get_os) == "macos" ]]; then 778 + open "$uri" 779 + else 780 + xdg-open "$uri" 781 + fi 782 + else 783 + echo "$uri" 784 + fi 771 785 } 772 786 773 787 # HACK: This essentially breaks the entire session (it overrides $_username and ··· 1626 1640 atfile.die "$cli_error" 1627 1641 } 1628 1642 1629 - function atfile.invoke.handle.launch_xdg() { 1630 - if [[ -n $DISPLAY ]] && [ -x "$(command -v xdg-open)" ]; then 1631 - if [[ $(atfile.util.get_os) == "macos" ]]; then 1632 - open "$app_uri" 1633 - else 1634 - xdg-open "$app_uri" 1635 - fi 1636 - else 1637 - echo "$app_uri" 1638 - fi 1639 - } 1640 - 1641 1643 [[ $_output_json == 1 ]] && atfile.die "Command not available as JSON" 1642 1644 [[ "$uri" != "at://"* ]] && atfile.invoke.handle.handle_error \ 1643 1645 "Invalid AT URI\nโ†ณ Must be 'at://<actor>[/<collection>/<rkey>]'" \ ··· 1653 1655 atfile.say.debug "Opening '$app_uri' ($app_proto)..." 1654 1656 1655 1657 if [[ $app_proto == "atfile" ]]; then 1656 - atfile.util.override_actor "$(echo "$app_uri" | cut -d "/" -f 3)" 1657 - 1658 - case "$(echo "$app_uri" | cut -d "/" -f 4)" in 1659 - "lock"|"upload") 1660 - if [[ -n $TERM ]]; then 1661 - atfile.invoke.get "$(echo "$app_uri" | cut -d "/" -f 5)" 1662 - else 1663 - atfile.invoke.handle.launch_xdg "$(atfile.invoke.get_url "$(echo "$app_uri" | cut -d "/" -f 5)")" 1664 - fi 1665 - ;; 1666 - esac 1658 + atfile.util.handle_protocol "$app_uri" 1667 1659 else 1668 - atfile.invoke.handle.launch_xdg "$app_uri" 1660 + atfile.until.launch_uri "$app_uri" 1669 1661 fi 1670 1662 } 1671 1663 ··· 2608 2600 atfile.die "Cannot skip authentication validation without a DID\nโ†ณ \$${_envvar_prefix}_USERNAME currently set to '$_username' (need \"did:<type>:<key>\")" 2609 2601 fi 2610 2602 fi 2603 + fi 2604 + 2605 + function atfile.util.handle_protocol() { 2606 + uri="$1" 2607 + 2608 + actor="$(echo $uri | cut -d "/" -f 3)" 2609 + path="$(echo $uri | cut -d "/" -f 4)" 2610 + key="$(echo $uri | cut -d "/" -f 5)" 2611 + 2612 + if [[ -n "$actor" && -n "$path" && -n "$key" ]]; then 2613 + case "$path" in 2614 + "upload") 2615 + atfile.util.override_actor "$actor" 2616 + 2617 + if [[ -n $TERM ]]; then 2618 + atfile.invoke.get "$key" 2619 + else 2620 + atfile.until.launch_uri "$key" 2621 + fi 2622 + ;; 2623 + *) 2624 + atfile.die "Unable to handle '$path'" 2625 + esac 2626 + fi 2627 + } 2628 + 2629 + ## Protocol Handler 2630 + 2631 + if [[ "$_command" == "atfile:"* ]]; then 2632 + atfile.say.debug "Handling '$_command'..." 2633 + atfile.util.handle_protocol "$_command" 2634 + exit 0 2611 2635 fi 2612 2636 2613 2637 ## Commands