. "${_EXEC}"/pdiread.sh
+unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; }
+upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; '
+
card_fullname(){
local card="$1" n1 n2 n3 n4 n5
fi
}
+
card_item(){
local card="$1"
local item cnt c
cnt="$(pdi_count "$card" "$item")"
case $item in
- FN) printf '[h2 .item .FN ­%s]' "$(card_fullname "$card" |HTML)"
+ FN) printf '[h2 .item .FN ­%s]' "$(card_fullname "$card" |unescape |HTML)"
;;
GENDER) printf '[span .item .GENDER ­%s]' "$(pdi_value "$card" GENDER |l10n)"
;;
NICKNAME) seq 1 $cnt |while read c; do
printf '[span .item .NICKNAME ­aka. "%s"]' \
- "$(pdi_value "$card" NICKNAME $c |HTML)"
+ "$(pdi_value "$card" NICKNAME $c |unescape |HTML)"
done
;;
X-ZACK-JOINDATE|X-ZACK-LEAVEDATE) if [ $cnt -gt 0 ]; then
;;
PHOTO|LOGO) if [ $cnt -gt 0 ]; then
printf '[img .item .%s src="data:image/%s;base64,%s"]' "$item" \
- "$(pdi_attrib "$card" "$item" |sed -r 's;^(.*;)?TYPE="?(.+)"?(;.*)?$;\2;')" \
+ "$(pdi_attrib "$card" "$item" |sed -E 's;^(.*;)?TYPE="?(.+)"?(;.*)?$;\2;')" \
"$(pdi_value "$card" "$item" |grep -xE '[a-zA-Z0-9/+=]+')"
fi
;;
printf '[h3 %s]' "$(l10n EMAIL)"
seq 1 $cnt |while read c; do
printf '[a .item .EMAIL href="mailto:%s" ­%s]' \
- "$(pdi_value "$card" EMAIL $c |HTML)" \
- "$(pdi_value "$card" EMAIL $c |HTML)"
+ "$(pdi_value "$card" EMAIL $c |unescape |HTML)" \
+ "$(pdi_value "$card" EMAIL $c |unescape |HTML)"
done
fi
;;
printf '[h3 %s]' "$(l10n "$item")"
seq 1 $cnt |while read c; do
printf '[span .item .%s ­%s]' "$item" \
- "$(pdi_value "$card" "$item" $c |HTML)"
+ "$(pdi_value "$card" "$item" $c |unescape |HTML)"
done
fi
;;
$(grep -F " ${cardfile##*/}" "$_DATA/mappings/attendance" |while read each discard; do
printf '[li [a .item .attendance href="/courses#%s" ­%s]]' \
"$each" \
- "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY |HTML)"
+ "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY |unescape |HTML)"
done)]
$(card_item "$card" CATEGORIES)
]
fi
}
-list_cards(){
+filter_cards(){
+ local filter f fex='x;p;'
+
+ filter="$(printf %s "${filter}" \
+ | sed -E 's;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\\\&;g;
+ '"$upcase"
+ )^"
+
+ while [ "$filter" ]; do
+ f="${filter%%^*}" filter="${filter#*^}"
+ case $f in
+ '') break
+ ;;
+ ANY:*) fex="/\n.*(\;[^:]*)?:.*(${f#*:}).*\r?\n/{${fex}}"
+ ;;
+ NAME:*) fex="/\n(N|FN|NICKNAME)(\;[^:]*)?:.*(${f#*:}).*\r?\n/{${fex}}"
+ ;;
+ STREET:*|ZIP:*) fex="/\nADR(\;[^:]*)?:.*(${f#*:}).*\r?\n/{${fex}}"
+ ;;
+ *) fex="/\n${f%%:*}(\;[^:]*)?:.*(${f#*:}).*\r?\n/{${fex}}"
+ ;;
+ esac
+ done
+
for cardfile in "${_DATA}"/vcard/*.vcf; do
+ printf '%s\n' "$cardfile"
+ cat "$cardfile"
+ done \
+ | sed -En ':X; /\nEND:VCARD\r?$/!{ N; bX; }; h; s;\n.*$;;; x; s;^[^\n]+\n;;;
+ '"$upcase""$fex"
+}
+
+list_cards(){
+ filter_cards \
+ | while read cardfile; do
print_card "$cardfile"
done
}