]> git.plutz.net Git - confetti/blobdiff - templates/view_attendee.sh
more reliable color selection, bugfix regarding backend color transparency
[confetti] / templates / view_attendee.sh
index 01fb3f0383565c3f9baa56a26aac6b1eb2367705..bdfdc6a621ebe2fe5ebfb0335f072d353d5c3352 100755 (executable)
-declare -A item_name
+# Copyright 2014, 2015 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/>. 
 
-item_name[PHOTO]="Foto"
-item_name[LOGO]="Logo"
-item_name[FN]="Voller Name"
-item_name[SOUND]="Aussprache"
-item_name[GENDER]="Geschlecht"
-item_name[KIND]="Typ"
-item_name[TITLE]="Beruf"
-item_name[ROLE]="Position"
-item_name[ORG]="Organisation"
-item_name[MEMBER]="Mitglied"
-item_name[CATEGORIES]="Kategorien"
-item_name[ANNIVERSARY]="Jubiläum"
-item_name[BDAY]="Geburtstag"
-item_name[EMAIL]="E-Mail"
-item_name[TEL]="Telefon"
-item_name[IMPP]="Chat"
-item_name[ADR]="Anschrift"
-item_name[URL]="Webseite"
-item_name[LANG]="Sprache"
-item_name[NOTE]="Notiz"
+n=$(printf %s "$values[N]" \
+    | sed -rn 's:^([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\4 \2 \3 \1 \5:gp' \
+    | sed -r 's:,: :;s:\;: :g;s: +: :g;s:^ $::;'
+   )
+fullname="${n:-${values[FN]:-${values[NICKNAME]}}}"
 
-item_name[RELATED]="Kontakte"
+cat <<END_HTML
+  <div class="section basic">
+    <h2 class="item FN">$fullname</h2>
+    ${values[GENDER]:+<span class="item GENDER">$(l10n $values[GENDER])</span>}
 
-item_name[BEGIN]=""
-item_name[CALADRURI]=""
-item_name[CALURI]=""
-item_name[CLASS]=""
-item_name[CLIENTPIDMAP]=""
-item_name[END]=""
-item_name[FBURL]=""
-item_name[GEO]=""
-item_name[MAILER]=""
-item_name[NAME]=""
-item_name[PRODID]=""
-item_name[PROFILE]=""
-item_name[REV]=""
-item_name[SORT-STRING]=""
-item_name[SOURCE]=""
-item_name[TZ]=""
-item_name[UID]=""
-item_name[VERSION]=""
-item_name[XML]=""
+    $(for n in NICKNAME NICKNAME{0..10}; do
+      echo "${values[$n]:+<span class="item NICKNAME">aka. $values[$n]</span>}"
+    done)
 
-l10n() {
-  [ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1"
-}
+    ${values[BDAY]:+<span class="item BDAY"><b>*:</b> $values[BDAY]</span>}
+    ${values[X-ZACK-JOINDATE]:+<span class="item X-ZACK-JOINDATE"><b>$(l10n label_join):</b> $values[X-ZACK-JOINDATE]</span>}
+    ${values[X-ZACK-LEAVEDATE]:+<span class="item X-ZACK-LEAVEDATE"><b>$(l10n label_leave):</b> $values[X-ZACK-LEAVEDATE]</span>}
+    ${values[SOUND]:+<audio controls="controls" class="item SOUND"><source type="audio/ogg" src="data:audio/ogg;base64,$values[SOUND]" /></audio>}
+    ${values[PHOTO]:+<img class="item PHOTO" src="data:image/$tags[PHOTO_TYPE];base64,$values[PHOTO]" />}
+    ${values[LOGO]:+<img class="item LOGO" src="data:image/$tags[LOGO_TYPE];base64,$values[LOGO]" />}
+  </div><!--
 
-view_card_item() {
-  case "$key" in
-    BEGIN|VERSION|END);;
-    PHOTO)
-      echo "<img class=\"PHOTO\" src=\"data:image/$tag[TYPE];base64,$value\"/>"
-      ;;
-    FN)
-      echo "<h2 CLASS=\"FN\">$value</h2>"
-      ;;
-    *)
-      echo -n "<span class=\"item\"><span class=\"KEY $key\">$(l10n "$key")"
-      [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])"
-      echo ":</span>"
-      ;|
-    EMAIL)
-      echo "<a href=\"mailto:$value\" class=\"VALUE $key\">$value</a></item>"
-      ;;
-    IMPP)
-      echo "<a href=\"$value\" class=\"VALUE $key\">"$(echo "$value" |cut -d: -f2-)"</a></item>"
-      ;;
-    *)
-      echo "<span class=\"VALUE $key\">$value</span></item>"
-      ;;
-  esac
-}
+  --><div class="section phone">
+    <h3>$(l10n TEL)</h3>
+    $(for n in TEL TEL{0..10}; do
+      echo "${values[$n]:+<span class="item TEL">$tags[${n}_TYPE] $values[$n]</span>}"
+    done)
+  </div><!--
 
-edit_card_item() {
-  case "$key" in
-    BEGIN|VERSION|END);;
-    PHOTO)
-      echo "<img class=\"PHOTO\" src=\"data:image/$tag[TYPE];base64,$value\"/>"
-      ;;
-    *)
-      echo -n "<span class=\"item\"><span class=\"KEY\">$(l10n "$key")"
-      [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])"
-      echo ":</span>"
-      ;|
-    *)
-      echo "<input class=\"VALUE\" name=\"$key\" value=\"$value\" /></item>"
-      ;;
-  esac
-}
+  --><div class="section message">
+    ${values[EMAIL]:+<h3>$(l10n EMAIL)</h3>}
+    $(for n in EMAIL EMAIL{0..10}; do
+      echo "${values[$n]:+<span class="item EMAIL"><a href="mailto:$values[$n]">$values[$n]</a></span>}"
+    done)
+    ${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
+    $(for n in IMPP IMPP{0..10}; do
+      echo "${values[$n]:+<span class="item IMPP">$tags[${n}_TYPE] <a href="$values[$n]">$values[$n]</a></span>}"
+    done)
+  </div><!--
 
-view_attendee() {  #Parameter: Cardfile
-  cardfile="$1"
-  cachefile="cache/vcf_$(basename "$cardfile").cache"
-  unset key
-  [ "$cachefile" -nt "$cardfile" ] && cat "$cachefile" \
-  || vcf_parse "$cardfile" |while read -r line; do
-    declare -A tag
-    case "$line" in
-      value*) eval "$line";;
-      tag*)   eval "$line";;
-      key*)
-        if [ -z "$key" ]; then
-          eval "$line"
-        else
-          view_card_item
-          eval "$line"
-         unset value
-         unset tag
-        fi
-      ;;
-    esac
-  done |tee "$cachefile"
-}
+  --><div class="section address">
+    <h3>$(l10n ADR)</h3>
+    $(for n in ADR ADR{0..10}; do
+      echo "${values[$n]:+<span class="item ADR">$values[$n]</span>}"
+    done)
+    ${values[URL]:+<h3>$(l10n URL)</h3>}
+    $(for n in URL URL{0..10}; do
+      echo "${values[$n]:+<span class="item URL"><a href="$values[$n]">$values[$n]</a></span>}"
+    done)
+  </div><!--
 
-edit_attendee() {
-  cardfile="$1"
-  unset key
-  vcf_parse "$cardfile" |while read -r line; do
-    declare -A tag
-    case "$line" in
-      value*) eval "$line";;
-      tag*)   eval "$line";;
-      key*)
-        if [ -z "$key" ]; then
-          eval "$line"
-        else
-          edit_card_item
-          eval "$line"
-         unset value
-         unset tag
-        fi
-      ;;
-    esac
-  done
-}
+  --><div class="section note">
+    <h3>$(l10n NOTE)</h3>
+    $(for n in NOTE NOTE{0..10}; do
+      echo "${values[$n]:+<span class="item NOTE">$values[$n]</span>}"
+    done)
+  </div><!--
+
+  --><div class="section attendance">
+    <h3>$(l10n course_attendance)</h3>
+    <ul>
+    $(sed -rn 's:(.*)\t'$id'$:\1:p' "$_DATA/mappings/attendance" |while read each; do
+      cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")"
+      echo '   <li><a class="item attendance" href="?p=courses#'$each'">'$cname'</a></li>'
+    done)
+    </ul>
+  </div>
+END_HTML