optical preparation for vcard display
[confetti] / pages / attendees.sh
1 #!/bin/sh
2
3 listcards() {
4   ls -1 ${_DATA}/vcard/*vcf
5 }
6
7 vcf_parse() {
8   tr -d '\n' <"$1" |sed -r 's:\r ::g;s:\r:\n:g' \
9   | sed -rn '
10     s:^PHOTO:001 PHOTO:p;
11     s:^X-MS-CARDPICTURE:001 PHOTO:p;
12     s:^LOGO:002 LOGO:p;
13     s:^FN:003 FN:p;
14     s:^NICKNAME:005 NICKNAME:p;
15     s:^N:004 N:p
16     s:^SOUND:006 SOUND:p;
17     s:^GENDER:007 GENDER:p;
18     s:^X-GENDER:007 GENDER:p;
19     s:^KIND:008 KIND:p;
20     s:^TITLE:009 TITLE:p;
21     s:^ROLE:010 ROLE:p;
22     s:^ORG:011 ORG:p;
23     s:^MEMBER:012 MEMBER:p;
24     s:^CATEGORIES:013 CATEGORIES:p;
25     s:^ANNIVERSARY:014 ANNIVERSARY:p;
26     s:^X-ANNIVERSARY:014 ANNIVERSARY:p;
27     s:^X-EVOLUTION-ANNIVERSARY:014 ANNIVERSARY:p;
28     s:^X-KADDRESSBOOK-X-Anniversary:014 ANNIVERSARY:p;
29     s:^BDAY:015 BDAY:p;
30     s:^EMAIL:016 EMAIL:p;
31     s:^TEL:017 TEL:p;
32     s:^IMPP:018 IMPP:p;
33     s:^X-AIM(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:aim\:\2:p;
34     s:^X-ICQ(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:aim\:\2:p;
35     s:^X-GOOGLE-TALK(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:xmpp\:\2:p;
36     s:^X-JABBER(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:xmpp\:\2:p;
37     s:^X-MSN(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:msn\:\2:p;
38     s:^X-YAHOO(;[^"\:]+|;"[^"]+")*\:(.*)$:018 IMPP\1\:ymsgr\:\2:p;
39     s:^X-SIP(;[^"\:]+|;"[^"]+")*\:(sip\:)?(.*)$:018 IMPP\1\:sip\:\3:p;
40     s:^ADR:019 ADR:p;
41     s:^LABEL(;[^"\:]+|;"[^"]+")*\:(.*)$:019 ADR;LABEL="\2"\1\::p;
42     s:^URL:021 URL:p;
43     s:^X-EVOLUTION-BLOG-URL:021 URL:p;
44     s:^LANG:022 LANG:p;
45     s:^NOTE:023 NOTE:p;
46
47     s:^RELATED:025 RELATED:p;
48     s:^AGENT:025 RELATED\;TYPE=agent:p;
49     s:^X-ASSISTANT:025 RELATED\;TYPE=assistant;VALUE=text:p;
50     s:^X-EVOLUTION-ASSISTANT:025 RELATED\;TYPE=assistant;VALUE=text:p;
51     s:^X-KADDRESSBOOK-X-AssistantsName:025 RELATED\;TYPE=assistant;VALUE=text:p;
52     s:^X-MANAGER:025 RELATED\;TYPE=manager;VALUE=text:p;
53     s:^X-EVOLUTION-MANAGER:025 RELATED\;TYPE=manager;VALUE=text:p;
54     s:^X-KADDRESSBOOK-X-ManagersName:025 RELATED\;TYPE=manager;VALUE=text:p;
55     s:^X-SPOUSE:025 RELATED\;TYPE=spouse;VALUE=text:p;
56     s:^X-EVOLUTION-SPOUSE:025 RELATED\;TYPE=spouse;VALUE=text:p;
57     s:^X-KADDRESSBOOK-X-SpouseName:025 RELATED\;TYPE=spouse;VALUE=text:p;
58
59     s:^BEGIN.*$:000 &:p;
60     s:^CALADRURI.*$::;
61     s:^CALURI.*$::;
62     s:^CLASS.*$::;
63     s:^CLIENTPIDMAP.*$::;
64     s:^END.*$:100 &:p;
65     s:^FBURL.*$::;
66     s:^GEO.*$::;
67     s:^MAILER.*$::;
68     s:^NAME.*$::;
69     s:^PRODID.*$::;
70     s:^PROFILE.*$::;
71     s:^REV.*$::;
72     s:^SORT-STRING.*$::;
73     s:^SOURCE.*$::;
74     s:^TZ.*$::;
75     s:^UID.*$::;
76     s:^VERSION.*$:000 VERSION\:4.0:p;
77     s:^XML.*$::;
78
79     s:^([A-Z].*)$:024 \1:p;
80     ' \
81   | sort |while read -r line; do
82     case "$line" in
83       00[012]*)
84         echo -E "$line"
85         ;;
86       003*)
87         fn=$(echo -E "$line" |sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:g' |tr -d '\r')
88         ;;
89       004*)
90         n=$(echo -E "$line" \
91           |sed -rn 's:^([0-9]{3} )([^;\:]+)(;[^"\:]+|;"[^"]+")*\:([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\7 \5 \6 \4 \8:gp' \
92           |sed -r 's:,: :;s:\;: :g;s: +: :g' \
93           |tr -d '\r'
94         )
95         ;;
96       005*)
97         nick=$(echo -E "$line" |sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:g' |tr -d '\r')
98         ;;
99       *) [ -n "$n" ] && fn="$n"
100          [ -n "$fn" -a -n "$nick" ] && fn="$fn aka. $nick"
101          [ -n "$fn" ] && echo -E "003 FN:$fn" \
102                       || echo -E "003 FN:$nick"
103          echo -E "$line"
104          cat
105         ;;
106     esac
107   done |tr -d '\r' \
108   | sed -r 's:^[0-9]{3} ([^;\:]+)(;[^"\:]+|;"[^"]+")*\:(.*)$:key="\1"\nvalue="\3"\ntag=\2:g' \
109   | while read -r line; do
110     case "$line" in
111       key=*) echo -E "$line"
112         ;;
113       value=*) echo -E "$line"
114         ;;
115       tag=*) ot=''
116              echo -E "$line" \
117              | sed -r 's:^tag=::;s:\;([A-Z+_-]+="[^"]+"|[A-Z+_-]+=[^\;]+):\n\1:g;' \
118              | sed -r 's:([A-Z+_-]+)="?(.*)"?:tag\[\1\]="\2":g' \
119              | sed -r '/^ *$/d' \
120              | sort |while read -r tag; do
121                nt="$(echo -E "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\1:')"
122                nv="$(echo -E "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\2:')"
123                [ "$nt" = "$ot" ] && vl="$nv,$vl" || vl="$nv"
124                echo -E "tag[$nt]=\"$vl\""
125                ot="$nt"
126              done
127         ;;
128     esac
129   done
130 }
131
132 case "$1" in
133   title)
134     echo "Teilnehmende"
135   ;;
136   css)
137     . ${_EXEC}/templates/attendees.css.sh
138   ;;
139   body)
140     . ${_EXEC}/templates/attendees.html.sh
141   ;;
142 esac
143