[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
# create directories for object storage
-for each in "$_DATA"/{vcard,mappings,courses}; do
+for each in "$_DATA"/{vcard,mappings,courses,cache}; do
[ ! -e "$each" ] && mkdir "$each"
[ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
done
listcards() {
case "$_GET["filtertype"]" in
any)
- grep -il "$_GET[\"filter\"]" ${_DATA}/vcard/*vcf |debug
+ grep -il "$_GET[\"filter\"]" ${_DATA}/vcard/*vcf
;;
name)
- egrep -xil "(FN|NICKNAME|N)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+ egrep -xil "(FN|NICKNAME|N)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
;;
street)
- egrep -xil "(ADR)(;.+)*:([^;]*;){2}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+ egrep -xil "(ADR)(;.+)*:([^;]*;){2}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
;;
zip)
- egrep -xil "(ADR)(;.+)*:([^;]*;){5}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+ egrep -xil "(ADR)(;.+)*:([^;]*;){5}$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
;;
telephone)
- egrep -xil "(TEL)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+ egrep -xil "(TEL)(;.+)*:.*$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
;;
birth)
- egrep -xil "(BDAY)(;.+)*:$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf |debug
+ egrep -xil "(BDAY)(;.+)*:$_GET[\"filter\"].*" ${_DATA}/vcard/*vcf
;;
course)
;;
case "$line" in
key=*) echo -E "$line"
;;
- value=*) echo -E "$line" |debug
+ value=*) echo -E "$line"
;;
tag=*) ot=''
echo -E "$line" \
}
view_attendee() { #Parameter: Cardfile
- key=""
- vcf_parse "$1" |while read -r line; do
+ 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";;
fi
;;
esac
- done
+ done |tee "$cachefile"
}