]> git.plutz.net Git - confetti/commitdiff
make use of improved parser
authorpaul <paul@plutz.net>
Sat, 12 Nov 2016 02:47:09 +0000 (02:47 +0000)
committerpaul <paul@plutz.net>
Sat, 12 Nov 2016 02:47:09 +0000 (02:47 +0000)
svn path=/trunk/; revision=144

templates/edit_attendee.sh
templates/view_attendee.sh

index 047879ad84f5d994f247c1d5431a8cf60b2ac8f8..e27592c6d9b32da57a39e7ec266cf6e74f521bec 100755 (executable)
@@ -1,4 +1,4 @@
-# Copyright 2014, 2015 Paul Hänsch
+# Copyright 2014 - 2016 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
@@ -22,12 +22,6 @@ check_a() {
   egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && echo 'checked="checked"'
 }
 
-n_last="$(echo "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
-n_first="$(echo "$values[N]" |sed -rn 's:^([^;]*;){1} *([^;]*).*$:\2:p')"
-n_middle="$(echo "$values[N]" |sed -rn 's:^([^;]*;){2} *([^;]*).*$:\2:p')"
-n_pre="$(echo "$values[N]" |sed -rn 's:^([^;]*;){3} *([^;]*).*$:\2:p')"
-n_post="$(echo "$values[N]" |sed -rn 's:^([^;]*;){4} *([^;]*)*$:\2:p')"
-
 SUP_FIELDS=(N NICKNAME GENDER BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE EMAIL TEL IMPP ADR URL NOTE)
 
 [ -z "$values[UID]" ] && values[UID]="$(uuidgenerator)"
@@ -37,11 +31,11 @@ cat <<END_HTML
   <input type="hidden" name="card" value="${id}"/>
   <div class="section basic">
     <h3>$(l10n N)</h3>
-    <input class="item N" name="3N" placeholder="$(l10n n_pre)" value="$n_pre" />
-    <input class="item N" name="1N" placeholder="$(l10n n_first)" value="$n_first" />
-    <input class="item N" name="2N" placeholder="$(l10n n_middle)" value="$n_middle" />
-    <input class="item N" name="0N" placeholder="$(l10n n_last)" value="$n_last" />
-    <input class="item N" name="4N" placeholder="$(l10n n_post)" value="$n_post" />
+    <input class="item N" name="3N" placeholder="$(l10n n_pre)" value="$values[N+3]" />
+    <input class="item N" name="1N" placeholder="$(l10n n_first)" value="$values[N+1]" />
+    <input class="item N" name="2N" placeholder="$(l10n n_middle)" value="$values[N+2]" />
+    <input class="item N" name="0N" placeholder="$(l10n n_last)" value="$values[N+0]" />
+    <input class="item N" name="4N" placeholder="$(l10n n_post)" value="$values[N+4]" />
 
     <select class="item GENDER" name="GENDER">
       <option value="" disabled="disabled">$(l10n GENDER)</option>
@@ -52,7 +46,7 @@ cat <<END_HTML
     </select>
 
     $(for n in NICKNAME NICKNAME{0..10}; do
-      echo "${values[$n]:+<input class="item NICKNAME" name="NICKNAME" placeholder="$(l10n NICKNAME)" value="$values[$n]" />}"
+      echo "${values[$n]+<input class="item NICKNAME" name="NICKNAME" placeholder="$(l10n NICKNAME)" value="$values[$n]" />}"
     done)
 
     <h3>$(l10n BDAY)</h3>
@@ -70,15 +64,15 @@ cat <<END_HTML
       echo '      <source type="audio/ogg" src="data:audio/ogg;base64,'$values[SOUND]'" />'
       echo '    </audio>'
     fi)
-    ${values[PHOTO]:+<img class="item PHOTO" src="data:image/$values[PHOTO_TYPE];base64,$values[PHOTO]" />}
-    ${values[LOGO]:+<img class="item LOGO" src="data:image/$values[LOGO_TYPE];base64,$values[LOGO]" />}
+    ${values[PHOTO]+<img class="item PHOTO" src="data:image/$values[PHOTO_TYPE];base64,$values[PHOTO]" />}
+    ${values[LOGO]+<img class="item LOGO" src="data:image/$values[LOGO_TYPE];base64,$values[LOGO]" />}
   </div>
 
   <div class="section phone">
     <h3>$(l10n TEL)</h3>
     <input class="item TEL" name="TEL" value="$values[TEL]" />
     $(for n in TEL{0..10}; do
-      echo "${values[$n]:+<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
+      echo "${values[$n]+<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
     done)
   </div>
 
@@ -86,11 +80,11 @@ cat <<END_HTML
     <h3>$(l10n EMAIL)</h3>
     <input class="item EMAIL" name="EMAIL" value="$values[EMAIL]" />
     $(for n in EMAIL{0..10}; do
-      echo "${values[$n]:+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
+      echo "${values[$n]+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
     done)
-    ${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
+    ${values[IMPP]+<h3>$(l10n IMPP)</h3>}
     $(for n in IMPP IMPP{0..10}; do
-      echo "${values[$n]:+<input class="item IMPP" name="IMPP" value="$values[$n]" />}"
+      echo "${values[$n]+<input class="item IMPP" name="IMPP" value="$values[$n]" />}"
     done)
   </div>
 
@@ -98,11 +92,11 @@ cat <<END_HTML
     <h3>$(l10n ADR)</h3>
     <textarea class="item ADR" name="ADR">$values[ADR]</textarea>
     $(for n in ADR{0..10}; do
-      echo "${values[$n]:+<textarea class="item ADR" name="ADR">$values[$n]</textarea>}"
+      echo "${values[$n]+<textarea class="item ADR" name="ADR">$values[$n]</textarea>}"
     done)
-    ${values[URL]:+<h3>$(l10n URL)</h3>}
+    ${values[URL]+<h3>$(l10n URL)</h3>}
     $(for n in URL URL{0..10}; do
-      echo "${values[$n]:+<input class="item URL" name="URL" value="$values[$n]" />}"
+      echo "${values[$n]+<input class="item URL" name="URL" value="$values[$n]" />}"
     done)
   </div>
 
@@ -110,7 +104,7 @@ cat <<END_HTML
     <h3>$(l10n NOTE)</h3>
     <textarea class="item NOTE" name="NOTE">$values[NOTE]</textarea>
     $(for n in NOTE{0..10}; do
-      echo "${values[$n]:+<textarea class="item NOTE" name="NOTE">$values[$n]</textarea>}"
+      echo "${values[$n]+<textarea class="item NOTE" name="NOTE">$values[$n]</textarea>}"
     done)
   </div>
 
index 1394cedacae447feae5e644e5b97c493a53da9af..5966729e01611df62bb78485d186cf8ecefd1b0d 100755 (executable)
@@ -15,9 +15,8 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-n=$(printf %s "$values[N]" \
-    | sed -rn 's:^([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\4 \2 \3 \1 \5:gp' \
-    | sed -r 's:,: :;s:\;: :g;s: +: :g;s:^ $::;'
+n=$(printf %s "$values[N+3] $values[N+1] $values[N+2] $values[N+0] $values[N+4]" \
+    | sed -r ':X;$!{N;bX}; s;^[\n ]+;;; s;[\n ]+$;;; s;[\r\t\n ]+; ;g;'
    )
 fullname="${n:-${values[FN]:-${values[NICKNAME]}}}"