]> git.plutz.net Git - confetti/commitdiff
unify client and attendee display templates
authorpaul <paul@plutz.net>
Mon, 14 Nov 2016 17:20:36 +0000 (17:20 +0000)
committerpaul <paul@plutz.net>
Mon, 14 Nov 2016 17:20:36 +0000 (17:20 +0000)
svn path=/trunk/; revision=149

pages/cards.sh
templates/view_card.sh [moved from templates/view_attendee.sh with 95% similarity]
templates/view_client.sh [deleted file]

index 945908ea70edb1b937dbc401a7122edb730285df..7be33e1ba5bd2e5a6269d2ec55c927548195679b 100755 (executable)
@@ -30,7 +30,6 @@ case $PROFILE in
 medical)
   SUP_FIELDS=(N NICKNAME GENDER BDAY ADR TEL EMAIL X-HEALTH-INSURANCE X-HEALTH-INSURANCE-NOCONTRIB IMPP URL NOTE X-CLIENT-REFERRAL)
   FORCE_ITEMS=(ADR TEL EMAIL NOTE X-CLIENT-REFERRAL)
-  view_card="$_EXEC/templates/view_client.sh"
   _GET[order]="${_GET[order]:-lastname}"
   _GET[filtertype]="${_GET[filtertype]:-name}"
   profile_medical=x
@@ -38,7 +37,6 @@ medical)
 circus)
   SUP_FIELDS=(N NICKNAME GENDER BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE EMAIL TEL IMPP ADR URL NOTE)
   FORCE_ITEMS=(BDAY X-ZACK-JOINDATE TEL EMAIL ADR NOTE)
-  view_card="$_EXEC/templates/view_attendee.sh"
   _GET[order]="${_GET[order]:-firstname}"
   _GET[filtertype]="${_GET[filtertype]:-any}"
   profile_circus=x
@@ -254,7 +252,7 @@ view_card() {  #Parameter: Cardfile
   else
     declare -A values
     vcf_parse "$cardfile"
-    . $view_card |tee "$cachefile"
+    . "$_EXEC/templates/view_card.sh" |tee "$cachefile"
   fi
 }
 
similarity index 95%
rename from templates/view_attendee.sh
rename to templates/view_card.sh
index 10cb06e764d9b2219665db638fd0c820fa20bf95..3319e07e188bdf2e0df64fec841c73f6524f8598 100755 (executable)
@@ -59,13 +59,13 @@ for n in NICKNAME NICKNAME{0..100}; do
 done
 
 [ -n "$values[BDAY]" ] && printf '
-  <span class="item BDAY"><b>*:</b>%s</span>
+  <span class="item BDAY"><b>*:</b> %s</span>
   ' "$(htmlsafe "$values[BDAY]")"
 [ -n "$values[X-ZACK-JOINDATE]" ] && printf '
-  <span class="item X-ZACK-JOINDATE"><b>%s:</b>%s</span>
+  <span class="item X-ZACK-JOINDATE"><b>%s:</b> %s</span>
   ' "$(l10n label_join)" "$(htmlsafe "$values[X-ZACK-JOINDATE]")"
 [ -n "$values[X-ZACK-LEAVEDATE]" ] && printf '
-  <span class="item X-ZACK-LEAVEDATE"><b>%s:</b>%s</span>
+  <span class="item X-ZACK-LEAVEDATE"><b>%s:</b >%s</span>
   ' "$(l10n label_leave)" "$(htmlsafe "$values[X-ZACK-LEAVEDATE]")"
 
 [ -n "$values[SOUND]" ] && printf '
@@ -105,9 +105,9 @@ elif [ "$PROFILE" = medical ]; then
   printf '<div class="section insurance"><h3>%s</h3>' "$(l10n X-HEALTH-INSURANCE)"
   [ -n "$hi_company" ] && printf '<span class="item hi_comapany">%s</span>' \
     "$(htmlsafe "$hi_company")"
-  [ -n "$hi_number" ] && printf '<span class="item hi_number"><label>%s:</label>%s</span>' \
+  [ -n "$hi_number" ] && printf '<span class="item hi_number"><label>%s:</label> %s</span>' \
     "$(l10n hi_number)" "$(htmlsafe "$hi_number")"
-  [ -n "$hi_status" ] && printf '<span class="item hi_status"><label>%s:</label>%s</span>' \
+  [ -n "$hi_status" ] && printf '<span class="item hi_status"><label>%s:</label> %s</span>' \
     "$(l10n hi_status)" "$(htmlsafe "$hi_status")"
   printf '</div>'
 
diff --git a/templates/view_client.sh b/templates/view_client.sh
deleted file mode 100755 (executable)
index 0fe5e98..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-# Copyright 2014 - 2016 Paul Hänsch
-#
-# This file is part of Confetti.
-# 
-# Confetti is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# Confetti is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License
-# along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
-
-list_items(){
-  item="$1"
-  [ -n "${values[$item]+x}" ] && \
-    printf '<h3>%s</h3>\n' "$(l10n $item)"
-  for n in "$item" "$item"{0..100}; do
-    [ -z "${values[$n]+x}" ] && break \
-    || printf '<span class="item %s">%s</span>\n' \
-         "$item" "$(htmlsafe ${values[$n]})"
-  done
-}
-
-list_section(){
-  printf '<div class="section %s">' "$1"
-  shift 1
-  for each in $@; do
-    list_items "$each"
-  done
-  printf '</div>'
-}
-
-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]}}}"
-
-hi_company="${values[X-HEALTH-INSURANCE+0]}"
- hi_number="${values[X-HEALTH-INSURANCE+1]}"
- hi_status="${values[X-HEALTH-INSURANCE+2]}"
-
-printf '<div class="section basic">
-    <h2 class="item FN">%s</h2>
-' "$fullname"
-[ -n "$values[GENDER]" ] && printf '
-  <span class="item GENDER">%s</span>
-  ' "$(l10n "$values[GENDER]")"
-
-for n in NICKNAME NICKNAME{0..100}; do
-  [ -z "${values[$n]+x}" ] && break \
-  || printf '
-      <span class="item NICKNAME">aka. %s</span>
-  ' "$(htmlsafe ${values[$n]})"
-done
-
-[ -n "$values[BDAY]" ] && printf '
-  <span class="item BDAY"><b>*:</b>%s</span>
-  ' "$(htmlsafe "$values[BDAY]")"
-[ -n "$values[X-ZACK-JOINDATE]" ] && printf '
-  <span class="item X-ZACK-JOINDATE"><b>%s:</b>%s</span>
-  ' "$(l10n label_join)" "$(htmlsafe "$values[X-ZACK-JOINDATE]")"
-[ -n "$values[X-ZACK-LEAVEDATE]" ] && printf '
-  <span class="item X-ZACK-LEAVEDATE"><b>%s:</b>%s</span>
-  ' "$(l10n label_leave)" "$(htmlsafe "$values[X-ZACK-LEAVEDATE]")"
-
-[ -n "$values[SOUND]" ] && printf '
-  <audio controls="controls" class="item SOUND">
-    <source type="audio/ogg" src="data:audio/ogg;base64,%s" />
-  </audio>' "$values[SOUND]"
-
-[ -n "$values[PHOTO]" ] && printf '
-  <img class="item PHOTO" src="data:image/%s;base64,%s" />
-  ' "${values[PHOTO_TYPE]}" "${values[PHOTO]}"
-
-[ -n "$values[LOGO]" ] && printf '
-  <img class="item PHOTO" src="data:image/%s;base64,%s" />
-  ' "${values[LOGO_TYPE]}" "${values[LOGO]}"
-
-list_items ADR
-list_items URL
-printf '</div>'
-
-  list_section phone TEL EMAIL IMPP
-
-cat <<-END_HTML
-  <div class="section insurance">
-    <h3>$(l10n X-HEALTH-INSURANCE)</h3>
-    ${hi_company:+<span class="\""item hi_comapany"\"">${hi_company}</span>}
-    ${hi_number:+<span class="\""item hi_number"\""><label>$(l10n hi_number):</label> ${hi_number}</span>}
-    ${hi_status:+<span class="\""item hi_status"\""><label>$(l10n hi_status):</label> ${hi_status}</span>}
-  </div>
-END_HTML
-
-list_section note NOTE X-CLIENT-REFERRAL
-
-cat <<-END_HTML
-  <div class="section prescriptions">
-    <h3>$(l10n prescriptions)</h3>
-    <ul>
-    $(declare -A mpx
-      find "$_DATA/prescriptions/" -name "${id%.vcf}.*.mpx" \
-      | while read pfile; do
-        mpx=(); cat "$pfile" |while read -r line; do
-          val="${line#*:}"
-          mpx[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")"
-        done
-        printf '<li><a href="?p=prescriptions&amp;client=%s#%s" >%s: %s - %s</a></li>' \
-          "${id}" "${pfile##*/}" "${mpx[date]}" "${mpx[indicator]}" \
-          "$([ -n "${mpx[remidy]}" ] && printf '%s %s' "${mpx[quantity]}" "${mpx[remidy]}" 
-             for n in {0..10}; do
-               [ -n "${mpx[remidy${n}]}" ] && printf ', %s %s' "${mpx[quantity${n}]}" "${mpx[remidy${n}]}" 
-             done
-           )"
-      done |sort -r
-    )
-    </ul>
-  </div>
-END_HTML