]> git.plutz.net Git - serve0/commitdiff
use new cgi engine for multitagging
authorpaul <paul@plutz.net>
Mon, 22 Sep 2014 01:55:08 +0000 (01:55 +0000)
committerpaul <paul@plutz.net>
Mon, 22 Sep 2014 01:55:08 +0000 (01:55 +0000)
svn path=/trunk/; revision=16

actions/multitag.sh

index fcf56d95268ce2f5bd8c2a6ebb85b9da54ebba92..7c5b252601ce97566f165d5a295ef124aad1d9ab 100755 (executable)
@@ -25,31 +25,26 @@ $description
 EOF
 }
 
-n=0
-if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then
-(head -c "${CONTENT_LENGTH}"; echo)|sed 's/&/\n/g' |while read line; do
-  if expr "$line" : "tagsel=" >/dev/null; then
-    n=$(($n + 1))
-    tagsel[$n]="$(echo -e "$(sed -nr 's:(^|&)tagsel=(.*)(&|$):\2:;s:&.*$::;s:\+: :g;s:%:\\x:g;p' <<<"$line" )")"
-  elif expr "$line" : "ctag=" >/dev/null; then
-    tag="$(sed -r 's:^ctag=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
-    tag="$(echo -e "${tag}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\&lt\;/g;s/>/\&gt\;/g')"
-    for i in {1..$n}; do
-      addtag "${_DATA}/meta/$tagsel[$i].meta" "$tag"
-      rm "${_DATA}/cache/$tagsel[$i].cache" 2>/dev/null
+cgi_post
+n=''
+while [ -n "$_POST[\"tagsel$n\"]" ]; do
+  tagsel="$_POST[\"tagsel$n\"]"
+  ( t=''
+    while [ -n "$_POST[\"ctag$t\"]" ]; do
+      echo "$_POST[\"ctag$t\"]"
+      [ -z "$t" ] && t=0 || t=$(($t + 1))
     done
-  elif expr "$line" : 'tags=.\+' >/dev/null; then
-    tags="$(sed -r 's:^tags=(.*)$:\1:;s:\+:_:g;s:%:\\x:g' <<<"$line")"
-    tags="$(echo -e "${tags}" |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\&lt\;/g;s/>/\&gt\;/g')"
-    for i in {1..$n}; do echo "$tags" |while read tag; do
-      addtag "${_DATA}/meta/$tagsel[$i].meta" "$tag"
-      rm "${_DATA}/cache/$tagsel[$i].cache" 2>/dev/null
-    done; done
-  fi
+    echo "$_POST[\"tags\"]"
+  ) |sed -r 's:\t| :_:g;s:^!|\r|\$|\^::g;s:\\:\\\\:g;s/</\&lt\;/g;s/>/\&gt\;/g' \
+  | while read tag; do
+    addtag "${_DATA}/meta/$tagsel.meta" "$tag"
+  done
+  rm "${_DATA}/cache/$tagsel.cache" 2>/dev/null
+
+  [ -z "$n" ] && n=0 || n=$(($n + 1))
 done
-fi
 
 rm "${_DATA}"/cache/\?* 2>/dev/null
-rm "${_DATA}"/cache/taglist 2>/dev/null
+[ -n "$_POST[\"tags\"]" ] && rm "${_DATA}"/cache/taglist 2>/dev/null
 
-echo -n "Location: ?o=$order&s=$search&f=$filter&p=$page#$info\n\n"
+echo -n "Location: ?o=$order&s=$search&f=$filter&p=$page\n\n"