3 . "${_EXEC}"/pdiread.sh
6 local card="$1" n1 n2 n3 n4 n5
8 local N="$(pdi_value "$card" N)"
9 local FN="$(pdi_value "$card" FN)"
10 local NICKNAME="$(pdi_value "$card" NICKNAME)"
15 IFS=\; read n1 n2 n3 n4 n5 <<-EOF
16 $(pdi_value "$card" N)
18 printf '%s %s %s %s %s' "$n4" "$n2" "$n3" "$n1" "$n5"
19 elif [ "$NICKNAME" ]; then
20 printf '"%s"' "$NICKNAME"
30 cnt="$(pdi_count "$card" "$item")"
33 FN) printf '[h2 .item .FN ­%s]' "$(card_fullname "$card" |HTML)"
35 GENDER) printf '[span .item .GENDER ­%s]' "$(pdi_value "$card" GENDER |l10n)"
37 NICKNAME) seq 1 $cnt |while read c; do
38 printf '[span .item .NICKNAME ­aka. "%s"]' \
39 "$(pdi_value "$card" NICKNAME $c |HTML)"
42 X-ZACK-JOINDATE|X-ZACK-LEAVEDATE) if [ $cnt -gt 0 ]; then
43 printf '[span .item .%s [b %s:] %s]' \
44 "$item" "$(l10n "${item}_short")" \
45 "$(pdi_value "$card" "$item" |HTML)"
48 BDAY) if [ $cnt -gt 0 ]; then
49 printf '[span .item .BDAY [b *:] %s]' \
50 "$(pdi_value "$card" BDAY |grep -xE '[0-9-]+')"
53 SOUND) if [ $cnt -gt 0 ]; then
54 printf '[audio .item .SOUND controls="controls"
55 [source type="audio/ogg" src="data:audio/ogg;base64,%s"]
57 "$(pdi_value "$card" SOUND |grep -xE '[a-zA-Z0-9/+=]+')"
60 PHOTO|LOGO) if [ $cnt -gt 0 ]; then
61 printf '[img .item .%s src="data:image/%s;base64,%s"]' "$item" \
62 "$(pdi_attrib "$card" "$item" |sed -r 's;^(.*;)?TYPE="?(.+)"?(;.*)?$;\2;')" \
63 "$(pdi_value "$card" "$item" |grep -xE '[a-zA-Z0-9/+=]+')"
66 EMAIL) if [ $cnt -gt 0 ]; then
67 printf '[h3 %s]' "$(l10n EMAIL)"
68 seq 1 $cnt |while read c; do
69 printf '[a .item .EMAIL href="mailto:%s" ­%s]' \
70 "$(pdi_value "$card" EMAIL $c |HTML)" \
71 "$(pdi_value "$card" EMAIL $c |HTML)"
75 *) if [ $cnt -gt 0 ]; then
76 printf '[h3 %s]' "$(l10n "$item")"
77 seq 1 $cnt |while read c; do
78 printf '[span .item .%s ­%s]' "$item" \
79 "$(pdi_value "$card" "$item" $c |HTML)"
89 local cachefile="${_DATA}/cache/${cardfile##*/}.cache"
91 if [ "$cachefile" -nt "$cardfile" -a "$cachefile" -nt "${_EXEC}/cards" ]; then
94 local card="$(pdi_load "$cardfile")"
95 tee "$cachefile" <<-EOF
96 [div .card #${cardfile##*/}
97 [div .section .basic ­$(
98 card_item "$card" FN GENDER NICKNAME BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE SOUND PHOTO LOGO
100 [div .section .phone ­$(card_item "$card" TEL)]
101 [div .section .message ­$(card_item "$card" EMAIL IMPP URL)]
102 [div .section .address ­$(card_item "$card" ADR)]
103 [div .section .note ­$(card_item "$card" NOTE)]
104 [div .section .attendance [h3 $(l10n course_attendance) ] [ul ­
105 $(grep -F " ${cardfile##*/}" "$_DATA/mappings/attendance" |while read each discard; do
106 printf '[li [a .item .attendance href="/courses#%s" ­%s]]' \
108 "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY |HTML)"
110 $(card_item "$card" CATEGORIES)
113 [a .item href="/cards/${cardfile##*/}?action=edit" $(l10n edit)]
114 [a .item href="/cards/${cardfile##*/}?action=export" $(l10n vcf_export)]
122 for cardfile in "${_DATA}"/vcard/*.vcf; do
123 print_card "$cardfile"