From: paul Date: Sun, 6 Oct 2013 21:44:56 +0000 (+0000) Subject: ordering of vcard attributes + parsing of name (n,fn,nickname) X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=2dc9740e1452127d64d027b57432032242f04eff;p=lobster ordering of vcard attributes + parsing of name (n,fn,nickname) svn path=/trunk/; revision=9 --- diff --git a/index.cgi b/index.cgi index f012782..327135f 100755 --- a/index.cgi +++ b/index.cgi @@ -7,7 +7,8 @@ die() { } debug() { #change to false to disable debugging #true && echo "$*" >>debug - true && echo "$*" >>/dev/stderr + true && [ -n "$*" ] && echo "$*" >>/dev/stderr + true && [ -z "$*" ] && tee /dev/stderr } # this program is supposed to be symlinked into a http root directory diff --git a/pages/attendees.sh b/pages/attendees.sh index c1e0eb2..75092c1 100755 --- a/pages/attendees.sh +++ b/pages/attendees.sh @@ -6,7 +6,105 @@ listcards() { vcf_parse() { tr -d '\n' <"$1" |sed -r 's:\r ::g;s:\r:\n:g' \ - | sed -r 's:^([^;]+)(;[^"]+|;"[^"]+")*\:(.*)$:key=\1\nvalue=\3\ntag=\2:g' + | sed -rn ' + s:^PHOTO:001 PHOTO:p; + s:^X-MS-CARDPICTURE:001 PHOTO:p; + s:^LOGO:002 LOGO:p; + s:^FN:003 FN:p; + s:^NICKNAME:005 NICKNAME:p; + s:^N:004 N:p + s:^SOUND:006 SOUND:p; + s:^GENDER:007 GENDER:p; + s:^X-GENDER:007 GENDER:p; + s:^KIND:008 KIND:p; + s:^TITLE:009 TITLE:p; + s:^ROLE:010 ROLE:p; + s:^ORG:011 ORG:p; + s:^MEMBER:012 MEMBER:p; + s:^CATEGORIES:013 CATEGORIES:p; + s:^ANNIVERSARY:014 ANNIVERSARY:p; + s:^X-ANNIVERSARY:014 ANNIVERSARY:p; + s:^X-EVOLUTION-ANNIVERSARY:014 ANNIVERSARY:p; + s:^X-KADDRESSBOOK-X-Anniversary:014 ANNIVERSARY:p; + s:^BDAY:015 BDAY:p; + s:^EMAIL:016 EMAIL:p; + s:^TEL:017 TEL:p; + s:^IMPP:018 IMPP:p; + s:^X-AIM(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:aim\:\2:p; + s:^X-ICQ(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:aim\:\2:p; + s:^X-GOOGLE-TALK(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:xmpp\:\2:p; + s:^X-JABBER(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:xmpp\:\2:p; + s:^X-MSN(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:msn\:\2:p; + s:^X-YAHOO(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:ymsgr\:\2:p; + s:^X-SIP(;[^"\:]+|;"[^"]+")*\:(sip\:)?(.*)$:018 IMPP\1\:sip\:\3:p; + s:^ADR:019 ADR:p; + s:^LABEL:020 LABEL:p; + s:^URL:021 URL:p; + s:^X-EVOLUTION-BLOG-URL:021 URL:p; + s:^LANG:022 LANG:p; + s:^NOTE:023 NOTE:p; + + s:^RELATED:025 RELATED:p; + s:^AGENT:025 RELATED\;TYPE=agent:p; + s:^X-ASSISTANT:025 RELATED\;TYPE=assistant;VALUE=text:p; + s:^X-EVOLUTION-ASSISTANT:025 RELATED\;TYPE=assistant;VALUE=text:p; + s:^X-KADDRESSBOOK-X-AssistantsName:025 RELATED\;TYPE=assistant;VALUE=text:p; + s:^X-MANAGER:025 RELATED\;TYPE=manager;VALUE=text:p; + s:^X-EVOLUTION-MANAGER:025 RELATED\;TYPE=manager;VALUE=text:p; + s:^X-KADDRESSBOOK-X-ManagersName:025 RELATED\;TYPE=manager;VALUE=text:p; + s:^X-SPOUSE:025 RELATED\;TYPE=spouse;VALUE=text:p; + s:^X-EVOLUTION-SPOUSE:025 RELATED\;TYPE=spouse;VALUE=text:p; + s:^X-KADDRESSBOOK-X-SpouseName:025 RELATED\;TYPE=spouse;VALUE=text:p; + + s:^BEGIN.*$::; + s:^CALADRURI.*$::; + s:^CALURI.*$::; + s:^CLASS.*$::; + s:^CLIENTPIDMAP.*$::; + s:^END.*$::; + s:^FBURL.*$::; + s:^GEO.*$::; + s:^MAILER.*$::; + s:^NAME.*$::; + s:^PRODID.*$::; + s:^PROFILE.*$::; + s:^REV.*$::; + s:^SORT-STRING.*$::; + s:^SOURCE.*$::; + s:^TZ.*$::; + s:^UID.*$::; + s:^VERSION.*$::; + s:^XML.*$::; + + s:^([A-Z].*)$:024 \1:p; + ' \ + | sort |while read -r line; do + case "$line" in + 001*) + echo -E "$line" + ;; + 002*) + echo -E "$line" + ;; + 003*) + fn=$(echo "$line" |sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:g' |tr -d '\r') + ;; + 004*) + n=$(echo "$line" |sed -rn 's:^([0-9]{3} )([^;\:]+)(;[^"\:]+|;"[^"]+")*\:([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\7 \5 \6 \4 \8:gp' |sed -r 's:,: :;s:\;: :g;s: +: :g' |tr -d '\r') + ;; + 005*) + nick=$(echo "$line" |sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:g' |tr -d '\r') + ;; + *) [ -n "$fn" -a -n "$nick" ] && fn="$fn aka. $nick" + [ -n "$n" -a -n "$nick" ] && n="$n aka. $nick" + [ -n "$fn" -a -z "$n" ] && echo "003 FN:$fn" + [ -n "$n" ] && echo "003 FN:$n" + [ -z "$fn" -a -z "$n" ] && echo "003 FN:$nick" + echo -E "$line" + cat + ;; + esac + done | sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:key=\1\nvalue=\3\ntag=\2:g' } case "$1" in