๐Ÿ“ฆโž”๐Ÿฆ‹ 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 62843e6b d7ac37aa

+85 -35
+1 -1
atfile.sh
··· 49 49 # Entry 50 50 51 51 function atfile.devel.die() { 52 - echo -e "\033[1;31mError: $1\033[0m" 52 + echo -e "\033[1;31mError: $1\033[0m" >&2 53 53 exit 255 54 54 } 55 55
+1 -5
src/commands/old_cmds.sh
··· 326 326 [ -x "$(command -v xdg-open)" ] && \ 327 327 [ -x "$(command -v gtk-launch)" ]; then 328 328 329 - [[ -z $file_type ]] && file_type="text/html" # HACK: Open with browser is file_type isn't set 329 + [[ -z $file_type ]] && file_type="text/html" # HACK: Open with browser if $file_type isn't set 330 330 331 331 if [[ -z $handler ]]; then 332 332 atfile.say.debug "Querying for handler '$file_type'..." ··· 610 610 if [[ -n "$error" ]]; then 611 611 atfile.die "Unable to cat '$key'" "$error" 612 612 fi 613 - } 614 - 615 - function atfile.invoke.token() { 616 - atfile.xrpc.pds.jwt 617 613 } 618 614 619 615 function atfile.invoke.toggle_desktop() {
+5
src/commands/token.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + function atfile.invoke.token() { 4 + atfile.xrpc.pds.jwt 5 + }
-1
src/commands/update.sh
··· 85 85 atfile.say.debug "Getting blob URL for $latest_version ($latest_version_record_id)..." 86 86 blob_url="$(atfile.invoke.get_url $latest_version_record_id)" 87 87 [[ $? != 0 ]] && atfile.die "Unable to get blob URL" 88 - blob_url="$(echo -e "$blob_url" | tail -n 1)" # HACK: ATFILE_DEBUG=1 screws up output, so we'll `tail` for safety 89 88 90 89 atfile.say.debug "Downloading latest release..." 91 90 curl -H "User-Agent: $(atfile.util.get_uas)" -s -o "$temp_updated_path" "$blob_url"
+47
src/shared/http.sh
··· 4 4 uri="$1" 5 5 out_path="$2" 6 6 7 + atfile.say.debug "$uri\nโ†ณ $out_path" "GET: " 8 + 7 9 curl -s -X GET "$uri" \ 8 10 -H "User-Agent: $(atfile.util.get_uas)" \ 9 11 -o "$out_path" ··· 11 13 12 14 function atfile.http.get() { 13 15 uri="$1" 16 + auth="$2" 17 + type="$3" 18 + 19 + [[ -n $auth ]] && auth="Authorization: $auth" 20 + [[ -z $type ]] && type="application/json" 21 + 22 + atfile.say.debug "$uri" "GET: " 14 23 15 24 curl -s -X GET "$uri" \ 25 + -H "$auth" \ 26 + -H "Content-Type: $type" \ 16 27 -H "User-Agent: $(atfile.util.get_uas)" 17 28 } 29 + 30 + function atfile.http.post() { 31 + uri="$1" 32 + data="$2" 33 + auth="$3" 34 + type="$4" 35 + 36 + [[ -n $auth ]] && auth="Authorization: $auth" 37 + [[ -z $type ]] && type="application/json" 38 + 39 + atfile.say.debug "$uri\nโ†ณ $data" "POST: " 40 + 41 + curl -s -X POST "$uri" \ 42 + -H "$auth" \ 43 + -H "Content-Type: $type" \ 44 + -H "User-Agent: $(atfile.util.get_uas)" \ 45 + -d "$data" 46 + } 47 + 48 + function atfile.http.upload() { 49 + uri="$1" 50 + file="$2" 51 + auth="$3" 52 + type="$4" 53 + 54 + [[ -n $auth ]] && auth="Authorization: $auth" 55 + [[ -z $type ]] && type="*/*" 56 + 57 + atfile.say.debug "$uri\nโ†ณ $file" "POST: " 58 + 59 + curl -s -X POST $_server/xrpc/$lexi \ 60 + -H "$auth" \ 61 + -H "Content-Type: $type" \ 62 + -H "User-Agent: $(atfile.util.get_uas)" \ 63 + --data-binary @"$file" | jq 64 + }
+11 -3
src/shared/say.sh
··· 31 31 fi 32 32 33 33 if [[ -n $prefix ]]; then 34 - prefix_length=$(( ${#prefix} + 2 )) 35 - prefix="${color_prefix}${prefix}: \033[0m" 34 + if [[ $prefix == *":"* ]]; then 35 + prefix_length=${#prefix} 36 + prefix="${color_prefix}${prefix}\033[0m" 37 + else 38 + prefix_length=$(( ${#prefix} + 2 )) 39 + prefix="${color_prefix}${prefix}: \033[0m" 40 + fi 36 41 fi 37 42 38 43 message="$(echo "$message" | sed -e "s|\\\n|\\\n$(atfile.util.repeat_char " " $prefix_length)|g")" ··· 42 47 43 48 function atfile.say.debug() { 44 49 message="$1" 50 + prefix="$2" 51 + 52 + [[ -z "$prefix" ]] && prefix="Debug" 45 53 46 54 if [[ $_debug == 1 ]]; then 47 - atfile.say "$message" "Debug" 35 >&2 55 + atfile.say "$message" "$prefix" 35 >&2 48 56 fi 49 57 } 50 58
+20 -25
src/shared/xrpc.sh
··· 10 10 [[ -z $lexi ]] && lexi="com.atproto.repo.uploadBlob" 11 11 [[ -z $type ]] && type="*/*" 12 12 13 - curl -s -X POST $_server/xrpc/$lexi \ 14 - -H "Authorization: Bearer $(atfile.xrpc.pds.jwt)" \ 15 - -H "Content-Type: $type" \ 16 - -H "User-Agent: $(atfile.util.get_uas)" \ 17 - --data-binary @"$file" | jq 13 + atfile.http.upload \ 14 + "$_server/xrpc/$lexi" \ 15 + "$file" \ 16 + "Bearer $(atfile.xrpc.pds.jwt)" \ 17 + "$type" | jq 18 18 } 19 19 20 20 function atfile.xrpc.pds.get() { ··· 23 23 type="$3" 24 24 endpoint="$4" 25 25 26 - [[ -z $type ]] && type="application/json" 27 26 [[ -z $endpoint ]] && endpoint="$_server" 28 27 29 - curl -s -X GET $endpoint/xrpc/$lexi?$query \ 30 - -H "Authorization: Bearer $(atfile.xrpc.pds.jwt)" \ 31 - -H "Content-Type: $type" \ 32 - -H "User-Agent: $(atfile.util.get_uas)" \ | jq 28 + atfile.http.get \ 29 + "$endpoint/xrpc/$lexi?$query" \ 30 + "Bearer $(atfile.xrpc.pds.jwt)" \ 31 + "$type" | jq 33 32 } 34 33 35 34 function atfile.xrpc.pds.jwt() { 36 - curl -s -X POST $_server/xrpc/com.atproto.server.createSession \ 37 - -H "Content-Type: application/json" \ 38 - -H "User-Agent: $(atfile.util.get_uas)" \ 39 - -d '{"identifier": "'$_username'", "password": "'$_password'"}' | jq -r ".accessJwt" 35 + atfile.http.post \ 36 + "$_server/xrpc/com.atproto.server.createSession" \ 37 + '{"identifier": "'$_username'", "password": "'$_password'"}' | jq -r ".accessJwt" 40 38 } 41 39 42 40 function atfile.xrpc.pds.post() { ··· 62 60 query="$2" 63 61 type="$3" 64 62 65 - [[ -z $type ]] && type="application/json" 66 - 67 - curl -s -X GET $_endpoint_appview_bsky/xrpc/$lexi?$query \ 68 - -H "Content-Type: $type" \ 69 - -H "User-Agent: $(atfile.util.get_uas)" | jq 63 + atfile.http.get \ 64 + "$_endpoint_appview_bsky/xrpc/$lexi?$query" \ 65 + "" \ 66 + "$type" | jq 70 67 } 71 68 72 69 ## Bluesky Video ··· 85 82 query="$2" 86 83 type="$3" 87 84 88 - [[ -z $type ]] && type="application/json" 89 - 90 - curl -s -X GET $_endpoint_appview_bsky_video/xrpc/$lexi?$query \ 91 - -H "Authorization: Bearer $(atfile.xrpc.bsky_video.jwt "$lexi")" \ 92 - -H "Content-Type: $type" \ 93 - -H "User-Agent: $(atfile.util.get_uas)" | jq 85 + atfile.http.get \ 86 + "$_endpoint_appview_bsky_video/xrpc/$lexi?$query" \ 87 + "Bearer $(atfile.xrpc.bsky_video.jwt "$lexi")" \ 88 + "$type" | jq 94 89 }