Skip to content

Commit

Permalink
Merge pull request #916 from teepobharu/image-code-param-fix
Browse files Browse the repository at this point in the history
[DevUtil - create-image-from-code] Simplify title encoding logic and change the params to pass correctly
  • Loading branch information
samuelkraft authored Mar 21, 2024
2 parents a067a63 + 3cd3e45 commit 485b573
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions commands/developer-utils/create-image-from-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

# Optional parameters:
# @raycast.icon ./images/ray-so.png
# @raycast.argument1 { "type": "text", "placeholder": "Title", "optional": true }
# @raycast.argument1 { "type": "text", "placeholder": "Title", "optional": true, "percentEncoded": true }

# Documentation:
# @raycast.description Create beautiful images of your code with https://ray.so
Expand All @@ -29,16 +29,10 @@ PADDING="64"
LANGUAGE="auto"

# Main:

if [[ -z "$1" ]]
then
TITLE="Untitled-1"
else
TITLE=$(php -r "echo urlencode(\"$1\");")
fi
TITLE=${1:-"Untitled"}

CODE=$(pbpaste | base64)
# Urlencode any + symbols in the base64 encoded string
CODE=${CODE//+/%2B}

open "https://ray.so/?colors=$COLORS&background=$BACKGROUND&darkMode=$DARK_MODE&padding=$PADDING&title=$TITLE&code=$CODE&language=$LANGUAGE"
open "https://ray.so?#title=$TITLE&code=$CODE&colors=$COLORS&background=$BACKGROUND&darkMode=$DARK_MODE&padding=$PADDING&title=$TITLE&code=$CODE&language=$LANGUAGE"

0 comments on commit 485b573

Please sign in to comment.