From 28a2c1efac4c9bb93a57f09a387f5991e0c7573c Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 7 Oct 2013 03:39:26 +0000 Subject: [PATCH] optical preparation for vcard display svn path=/trunk/; revision=10 --- pages/attendees.sh | 56 +++++++++++++++------- templates/attendees.css.sh | 31 +++++++++++- templates/attendees.html.sh | 8 ++-- templates/view_attendee.sh | 95 +++++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 24 deletions(-) diff --git a/pages/attendees.sh b/pages/attendees.sh index 75092c1..b6088d6 100755 --- a/pages/attendees.sh +++ b/pages/attendees.sh @@ -38,7 +38,7 @@ vcf_parse() { 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:^LABEL(;[^"\:]+|;"[^"]+")*\:(.*)$:019 ADR;LABEL="\2"\1\::p; s:^URL:021 URL:p; s:^X-EVOLUTION-BLOG-URL:021 URL:p; s:^LANG:022 LANG:p; @@ -56,12 +56,12 @@ vcf_parse() { 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:^BEGIN.*$:000 &:p; s:^CALADRURI.*$::; s:^CALURI.*$::; s:^CLASS.*$::; s:^CLIENTPIDMAP.*$::; - s:^END.*$::; + s:^END.*$:100 &:p; s:^FBURL.*$::; s:^GEO.*$::; s:^MAILER.*$::; @@ -73,38 +73,60 @@ vcf_parse() { s:^SOURCE.*$::; s:^TZ.*$::; s:^UID.*$::; - s:^VERSION.*$::; + s:^VERSION.*$:000 VERSION\:4.0:p; s:^XML.*$::; s:^([A-Z].*)$:024 \1:p; ' \ | sort |while read -r line; do case "$line" in - 001*) - echo -E "$line" - ;; - 002*) + 00[012]*) echo -E "$line" ;; 003*) - fn=$(echo "$line" |sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:g' |tr -d '\r') + fn=$(echo -E "$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') + n=$(echo -E "$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') + nick=$(echo -E "$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" + *) [ -n "$n" ] && fn="$n" + [ -n "$fn" -a -n "$nick" ] && fn="$fn aka. $nick" + [ -n "$fn" ] && echo -E "003 FN:$fn" \ + || echo -E "003 FN:$nick" echo -E "$line" cat ;; esac - done | sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:key=\1\nvalue=\3\ntag=\2:g' + done |tr -d '\r' \ + | sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:key="\1"\nvalue="\3"\ntag=\2:g' \ + | while read -r line; do + case "$line" in + key=*) echo -E "$line" + ;; + value=*) echo -E "$line" + ;; + tag=*) ot='' + echo -E "$line" \ + | sed -r 's:^tag=::;s:\;([A-Z+_-]+="[^"]+"|[A-Z+_-]+=[^\;]+):\n\1:g;' \ + | sed -r 's:([A-Z+_-]+)="?(.*)"?:tag\[\1\]="\2":g' \ + | sed -r '/^ *$/d' \ + | sort |while read -r tag; do + nt="$(echo -E "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\1:')" + nv="$(echo -E "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\2:')" + [ "$nt" = "$ot" ] && vl="$nv,$vl" || vl="$nv" + echo -E "tag[$nt]=\"$vl\"" + ot="$nt" + done + ;; + esac + done } case "$1" in diff --git a/templates/attendees.css.sh b/templates/attendees.css.sh index a5d9035..52e771f 100644 --- a/templates/attendees.css.sh +++ b/templates/attendees.css.sh @@ -6,10 +6,37 @@ cat <
@@ -30,11 +32,7 @@ cat < $(listcards |while read card; do echo '
' - vcf_parse "$card" |sed -r ' - s:^key=(.+)$: \1:g - s:^value=(.*)$:\1:g - s:^tag=(.*)$: \1
:g - ' + view_attendee "$card" echo '
' done) diff --git a/templates/view_attendee.sh b/templates/view_attendee.sh index e69de29..fa9241e 100755 --- a/templates/view_attendee.sh +++ b/templates/view_attendee.sh @@ -0,0 +1,95 @@ +declare -A item_name + +item_name[PHOTO]="Foto" +item_name[LOGO]="Logo" +item_name[FN]="Voller Name" +item_name[SOUND]="Aussprache" +item_name[GENDER]="Geschlecht" +item_name[KIND]="Typ" +item_name[TITLE]="Beruf" +item_name[ROLE]="Position" +item_name[ORG]="Organisation" +item_name[MEMBER]="Mitglied" +item_name[CATEGORIES]="Kategorien" +item_name[ANNIVERSARY]="Jubiläum" +item_name[BDAY]="Geburtstag" +item_name[EMAIL]="E-Mail" +item_name[TEL]="Telefon" +item_name[IMPP]="Chat" +item_name[ADR]="Anschrift" +item_name[URL]="Webseite" +item_name[LANG]="Sprache" +item_name[NOTE]="Notiz" +item_name +item_name[RELATED]="Kontakte" +item_name +item_name[BEGIN]="" +item_name[CALADRURI]="" +item_name[CALURI]="" +item_name[CLASS]="" +item_name[CLIENTPIDMAP]="" +item_name[END]="" +item_name[FBURL]="" +item_name[GEO]="" +item_name[MAILER]="" +item_name[NAME]="" +item_name[PRODID]="" +item_name[PROFILE]="" +item_name[REV]="" +item_name[SORT-STRING]="" +item_name[SOURCE]="" +item_name[TZ]="" +item_name[UID]="" +item_name[VERSION]="" +item_name[XML]="" + +l10n() { + [ -n "$item_name[$1]" ] && echo "$item_name[$1]" || echo "$1" +} + +view_card_item() { + debug "Item: $key" + case "$key" in + BEGIN|VERSION|END);; + PHOTO) + debug "Type: $tag[TYPE]" + echo "" + ;; + FN) + echo "

$value

" + ;; + *) + echo "$(l10n "$key")" + [ -n "$tag[TYPE]" ] && echo "($tag[TYPE])" + echo ":" + ;| + EMAIL) + echo "$value
" + ;; + IMPP) + echo ""$(echo "$value" |cut -d: -f2-)"
" + ;; + *) + echo "$value
" + ;; + esac +} + +view_attendee() { #Parameter: Cardfile + key="" + vcf_parse "$1" |while read -r line; do + declare -A tag + case "$line" in + value*) eval "$line";; + tag*) eval "$line";; + key*) + if [ -z "$key" ]; then + eval "$line" + else + view_card_item + eval "$line" + fi + ;; + esac + done +} -- 2.39.2