X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=actions%2Fupdate_therapy.sh;h=52daa11ba0e042f921a66738edee62c7c21e16d7;hp=43a2e1fdff49cd1421765bf34f0c46e2c1a63e3a;hb=a9d6bfdfa84de24b8800b6d34b24c28cbdb2feb4;hpb=c8980226006bdd5a9d518e7d3221dc3d527be321 diff --git a/actions/update_therapy.sh b/actions/update_therapy.sh index 43a2e1f..52daa11 100755 --- a/actions/update_therapy.sh +++ b/actions/update_therapy.sh @@ -26,7 +26,7 @@ tempfile="$_DATA/temp/$tpy" # serialize POST array into file for key in ${(k)_POST}; do - printf %s:%s\\n "$key" "${_POST[$key]//$BR/\\n}" + [ "$key" != imagedata ] && printf %s:%s\\n "$key" "${_POST[$key]//$BR/\\n}" done >"$tempfile" if [ -n "$_POST[delete_session]" ]; then @@ -42,13 +42,35 @@ if [ -n "$_POST[delete_session]" ]; then elif [ -n "$_POST[new_session]" ]; then sid="$_POST[new_session]" - printf '%s:exists\n' "$sid" >>"$tempfile" identify "$_EXEC/templates/therapy_background.png" \ | sed -r 's;^.* ([0-9]+x[0-9]+) .*$;\1;' \ | read dim convert -size "$dim" xc:transparent "${tpyfile%.tpy}_${sid}.png" + + printf '%s:exists\n' "$sid" >>"$tempfile" + printf '%s_open:checked\n' "$sid" >>"$tempfile" + +elif [ -n "$_POST[dotmark.x]" -a -n "$_POST[dotmark.y]" ]; then + sed -rn 's;^(session[0-9]+)_open:checked$;\1;p' "$tempfile" \ + | sort -n \ + | tail -n1 \ + | read sid + + x="$_POST[dotmark.x]" + y="$_POST[dotmark.y]" + + convert "${tpyfile%.tpy}_${sid}.png" -draw "fill $_POST[color] circle $x,$y $(($x+5)),$y" "${tpyfile%.tpy}_${sid}.png" + +elif [ -n "$_POST[imagedata]" ]; then + sed -rn 's;^(session[0-9]+)_open:checked$;\1;p' "$tempfile" \ + | sort -n \ + | tail -n1 \ + | read sid + + convert "${tpyfile%.tpy}_${sid}.png" -draw "${_POST[imagedata]}" -transparent white "${tpyfile%.tpy}_${sid}.png" + sync fi mv "$tempfile" "$tpyfile"