From: paul Date: Sun, 1 Dec 2013 04:29:07 +0000 (+0000) Subject: keep filter and order settings when updating a card X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=debd0bd0d774c6151a8fbf6759778e2e0757c8bd;p=confetti keep filter and order settings when updating a card svn path=/trunk/; revision=28 --- diff --git a/actions/edit_attendee.sh b/actions/edit_attendee.sh new file mode 100644 index 0000000..9a5bcb4 --- /dev/null +++ b/actions/edit_attendee.sh @@ -0,0 +1,11 @@ +#!/bin/zsh + +cgi_refdata + +card="$_GET[\"card\"]" +debug card: $card +filter="&filter=$_REF[\"filter\"]" +filtertype="&filtertype=$_REF[\"filtertype\"]" +order="&order=$_REF[\"order\"]" + +echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}&edit=$card\n\n" diff --git a/actions/new_attendee.sh b/actions/new_attendee.sh index b7242bf..d1eb77a 100644 --- a/actions/new_attendee.sh +++ b/actions/new_attendee.sh @@ -1,6 +1,11 @@ #!/bin/zsh cgi_post +cgi_refdata + +filter="&filter=$_REF[\"filter\"]" +filtertype="&filtertype=$_REF[\"filtertype\"]" +order="&order=$_REF[\"order\"]" uid=$(dbus-uuidgen) card="${uid}.vcf" @@ -20,4 +25,4 @@ UID:$uid END:VCARD EOF -echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card\n\n" +echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}&edit=$card\n\n" diff --git a/actions/update_attendee.sh b/actions/update_attendee.sh index 6bfbe88..9657d05 100644 --- a/actions/update_attendee.sh +++ b/actions/update_attendee.sh @@ -1,6 +1,11 @@ #!/bin/zsh cgi_post +cgi_refdata + +filter="&filter=$_REF[\"filter\"]" +filtertype="&filtertype=$_REF[\"filtertype\"]" +order="&order=$_REF[\"order\"]" card="$_POST[\"card\"]" tempfile="temp/$card" @@ -24,21 +29,21 @@ case "$_POST[\"action\"]" in addfield) echo "$_POST[\"newfield\"]:\r" >>"$tempfile" echo "END:VCARD\r" >>"$tempfile" - echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card\n\n" + echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}&edit=$card\n\n" ;; update) echo "END:VCARD\r" >>"$tempfile" mv "$tempfile" "$cardfile" - echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n" + echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}#$card\n\n" ;; cancel) rm "$tempfile" [ -f "$cardfile" ] \ - && echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n" \ - || echo -n "Location: http://$HTTP_HOST/?page=attendees\n\n" + && echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}#$card\n\n" \ + || echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}\n\n" ;; delete) rm "$tempfile" "$cardfile" - echo -n "Location: http://$HTTP_HOST/?page=attendees\n\n" + echo -n "Location: http://$HTTP_HOST/?page=attendees${filter}${filtertype}${order}\n\n" ;; esac diff --git a/cgi.sh b/cgi.sh index bde75d6..39172ba 100755 --- a/cgi.sh +++ b/cgi.sh @@ -2,6 +2,7 @@ declare -A _GET declare -A _POST +declare -A _REF cgi_get() { # parse HTTP GET string echo "$QUERY_STRING" |tr '&' '\n' |while read query; do @@ -25,3 +26,11 @@ cgi_post() { # parse HTTP POST string fi done } + +cgi_refdata() { # Parse GET data from referer + echo "$HTTP_REFERER" |cut -d'?' -f2- |tr '&' '\n' |while read query; do + key="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\1:')" + val="$(echo "$query" |sed -r 's:^([a-zA-Z0-9_-]*)=(.*)$:\2:')" + _REF["$key"]="$(echo -e "$(echo "$val" |sed 's:+: :g;s:%:\\x:g')")" + done +} diff --git a/templates/view_attendee.sh b/templates/view_attendee.sh index 1bfccee..53c508c 100755 --- a/templates/view_attendee.sh +++ b/templates/view_attendee.sh @@ -59,7 +59,7 @@ done echo ' ' echo '' echo '
' -echo ' '$(l10n edit)'' +echo ' '$(l10n edit)'' echo ' '$(l10n vcf_export)'' echo '
' echo ''