From: paul Date: Mon, 21 Oct 2013 15:12:08 +0000 (+0000) Subject: implemented vcf caching X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=c778a3abd05946586813bb0b676e04b616d294a4;p=lobster implemented vcf caching svn path=/trunk/; revision=14 --- diff --git a/index.cgi b/index.cgi index 90ded2d..def6da0 100755 --- a/index.cgi +++ b/index.cgi @@ -30,7 +30,7 @@ debug "Storage dir: $_DATA" [ -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 diff --git a/pages/attendees.sh b/pages/attendees.sh index 4c84af1..1a34b8b 100755 --- a/pages/attendees.sh +++ b/pages/attendees.sh @@ -4,22 +4,22 @@ 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) ;; @@ -134,7 +134,7 @@ vcf_parse() { case "$line" in key=*) echo -E "$line" ;; - value=*) echo -E "$line" |debug + value=*) echo -E "$line" ;; tag=*) ot='' echo -E "$line" \ diff --git a/templates/view_attendee.sh b/templates/view_attendee.sh index c9adf7f..1e02e3d 100755 --- a/templates/view_attendee.sh +++ b/templates/view_attendee.sh @@ -74,8 +74,11 @@ view_card_item() { } 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";; @@ -91,5 +94,5 @@ view_attendee() { #Parameter: Cardfile fi ;; esac - done + done |tee "$cachefile" }