--- /dev/null
+#!/bin/zsh
+
+cgi_post
+
+uid=$(dbus-uuidgen)
+card="${uid}.vcf"
+
+cardfile="vcard/$card"
+tempfile="temp/$card"
+
+touch "$cardfile"
+
+cat >"$tempfile" <<EOF
+BEGIN:VCARD
+VERSION:4.0
+N:;;;;
+BDAY:
+TEL:
+EMAIL:
+ADR:
+NOTE:
+UID:$uid
+END:VCARD
+EOF
+
+echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card\n\n"
addfield)
echo "$_POST[\"newfield\"]:\r" >>"$tempfile"
echo "END:VCARD\r" >>"$tempfile"
- echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card#$card\n\n"
+ echo -n "Location: http://$HTTP_HOST/?page=attendees&edit=$card\n\n"
;;
update)
echo "END:VCARD\r" >>"$tempfile"
rm "$tempfile"
echo -n "Location: http://$HTTP_HOST/?page=attendees#$card\n\n"
;;
+ delete)
+ rm "$tempfile" "$cardfile"
+ echo -n "Location: http://$HTTP_HOST/?page=attendees\n\n"
+ ;;
esac
#!/bin/sh
-[ "$_GET[\"action\"]" = "del_filter" ] && _GET["filter"]="" && _GET["filtertype"]=""
+[ "$_GET[\"choice\"]" = "del_filter" ] && _GET["filter"]="" && _GET["filtertype"]=""
listcards() {
case "$_GET["filtertype"]" in
any)
;;
*) ls -1 ${_DATA}/vcard/*vcf
;;
- esac
+ esac |sed -r 's:^(.*/)([^/]+)$:\2:'
}
vcf_parse() {
s:^X-EVOLUTION-BLOG-URL:021 URL:p;
s:^LANG:022 LANG:p;
s:^NOTE:023 NOTE:p;
+ s:^UID:026 UID:p;
s:^RELATED:025 RELATED:p;
s:^AGENT:025 RELATED\;TYPE=agent:p;
s:^SORT-STRING.*$::;
s:^SOURCE.*$::;
s:^TZ.*$::;
- s:^UID.*$::;
s:^VERSION.*$:000 VERSION\:4.0:p;
s:^XML.*$::;
done
}
+view_attendee() { #Parameter: Cardfile
+ id="$1"
+ cardfile="$_DATA/vcard/${id}"
+ cachefile="$_DATA/cache/${id}.cache"
+ unset key
+ if [ "$cachefile" -nt "$cardfile" ]; then
+ cat "$cachefile"
+ else
+ declare -A tags
+ declare -A values
+ vcf_parse "$cardfile" |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
+ values[$key]="$value"
+ for t in ${(k)tag}; do
+ tags[${key}_$t]="$tag[$t]"
+ done
+ eval "$line"
+ if [ -n "$values[$key]" ]; then
+ n=0
+ while [ -n "$values[$key$n]" ]; do n=$(($n + 1)); done
+ key=$key$n
+ fi
+ unset value
+ unset tag
+ fi
+ ;;
+ esac
+ done
+ . ${_EXEC}/templates/view_attendee.sh |tee "$cachefile"
+ fi
+}
+
+edit_attendee() { #Parameter: Cardfile
+ id="$1"
+ cardfile="$_DATA/vcard/$id"
+ tempfile="$_DATA/temp/$id"
+ [ -f "$tempfile" ] && cardfile="$tempfile"
+ unset key
+
+ declare -A tags
+ declare -A values
+ vcf_parse "$cardfile" |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
+ [ -n "$value" ] && values[$key]="$value" || values[$key]='\r'
+ for t in ${(k)tag}; do
+ tags[${key}_$t]="$tag[$t]"
+ done
+ eval "$line"
+ if [ -n "$values[$key]" ]; then
+ n=0
+ while [ -n "$values[${key}${n}]" ]; do n=$(($n + 1)); done
+ key=$key$n
+ fi
+ unset value
+ unset tag
+ fi
+ ;;
+ esac
+ done
+ . ${_EXEC}/templates/edit_attendee.sh
+}
+
case "$1" in
title)
echo "Teilnehmende"
. ${_EXEC}/templates/attendees.css.sh
;;
body)
+ . ${_EXEC}/templates/text_attendee.sh
. ${_EXEC}/templates/attendees.html.sh
;;
esac
-. ${_EXEC}/templates/text_attendee.sh
-. ${_EXEC}/templates/view_attendee.sh
-. ${_EXEC}/templates/edit_attendee.sh
-
check(){
[ "$_GET[\"filtertype\"]" = "$1" ] && echo 'checked="checked"'
}
+edit="$_GET[\"edit\"]"
+[ -z "$_GET[\"filtertype\"]" ] && _GET[filtertype]="any"
+
cat <<EOF
<div class="filter">
<form action="/" method="GET">
<input type="radio" name="filtertype" value="telephone" $(check telephone)>$(l10n filter_phone)</input>
<input type="radio" name="filtertype" value="birth" $(check birth)>$(l10n filter_birthyear)</input>
<input type="radio" name="filtertype" value="course" $(check course)>$(l10n filter_course)</input><br/>
- <button type="submit" name="action" value="new_filter">$(l10n filter_apply)</button>
- <button type="submit" name="action" value="del_filter">$(l10n filter_cancel)</button>
+ <button type="submit" name="choice" value="new_filter">$(l10n filter_apply)</button>
+ <button type="submit" name="choice" value="del_filter">$(l10n filter_cancel)</button>
</div>
</form>
</div>
<div class="newcard">
-<h2>Neuer Eintrag</h2>
-<form action="actions/newcard.cgi" method="POST">
- <span class="label">Name:</span>
- <input type="text" name="name"/>
- <button type="submit">Anlegen</button>
+<form action="?action=new_attendee" method="POST">
+ <button type="submit">$(l10n newcard)</button>
</form>
</div>
<div class="cardlist">
-$(listcards |while read card; do
- id="$(basename "$card")"
- if [ "$_GET[\"edit\"]" = "$id" ]; then cat <<x_EOF
- <div id="${id}" class="card">
- <form action="/?action=update_attendee" method="POST">
- <input type="hidden" name="card" value="${id}"/>
- $(edit_attendee "$id")
- </form>
- </div>
-x_EOF
- else cat <<x_EOF
- <div id="${id}" class="card">
- $(view_attendee "$id")
- </div>
-x_EOF
- fi
-done)
+$(
+[ -f "vcard/$edit" -o -f "temp/$edit" ] && edit_attendee "$edit"
+if [ "$?" = 0 ]; then
+ listcards |grep -v "$edit"
+else
+ listcards
+fi |while read card; do
+ view_attendee "$card"
+done
+)
</div>
-
EOF
# vi:set filetype=html:
[ "$value[GENDER]" = "$1" ] && echo 'selected="selected"'
}
-edit_card() {
- n_last="$(echo "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
- n_first="$(echo "$values[N]" |sed -rn 's:^([^;]*;){1} *([^;]*).*$:\2:p')"
- n_middle="$(echo "$values[N]" |sed -rn 's:^([^;]*;){2} *([^;]*).*$:\2:p')"
- n_pre="$(echo "$values[N]" |sed -rn 's:^([^;]*;){3} *([^;]*).*$:\2:p')"
- n_post="$(echo "$values[N]" |sed -rn 's:^([^;]*;){4} *([^;]*)*$:\2:p')"
+n_last="$(echo "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
+n_first="$(echo "$values[N]" |sed -rn 's:^([^;]*;){1} *([^;]*).*$:\2:p')"
+n_middle="$(echo "$values[N]" |sed -rn 's:^([^;]*;){2} *([^;]*).*$:\2:p')"
+n_pre="$(echo "$values[N]" |sed -rn 's:^([^;]*;){3} *([^;]*).*$:\2:p')"
+n_post="$(echo "$values[N]" |sed -rn 's:^([^;]*;){4} *([^;]*)*$:\2:p')"
- [ -z "$values[UID]" ] && values[UID]="$(dbus-uuidgen)"
+declare -A SUP_FIELDS
+SUP_FIELDS=(N NICKNAME GENDER BDAY EMAIL TEL IMPP ADR URL NOTE)
- echo ' <div class="section basic">'
- echo ' <span class="sectitle">'$(l10n N)'</span>'
- echo ' <input class="item N" name="3N" placeholder="'$(l10n n_pre)'" value="'$n_pre'" />'
- echo ' <input class="item N" name="1N" placeholder="'$(l10n n_first)'" value="'$n_first'" />'
- echo ' <input class="item N" name="2N" placeholder="'$(l10n n_middle)'" value="'$n_middle'" />'
- echo ' <input class="item N" name="0N" placeholder="'$(l10n n_last)'" value="'$n_last'" />'
- echo ' <input class="item N" name="4N" placeholder="'$(l10n n_post)'" value="'$n_post'" />'
- if [ -n "$value[GENDER]" ]; then
- echo ' <div class="section control">'
- echo ' <select class="item control" name="newfield">'
- echo ' <option value="" disabled="disabled">'$(l10n GENDER)'</option>'
- echo ' <option value="female" disabled="disabled" '$(check_gen female)'>'$(l10n female)'</option>'
- echo ' <option value="male" disabled="disabled" '$(check_gen male)'>'$(l10n male)'</option>'
- echo ' <option value="other" disabled="disabled" '$(check_gen other)'>'$(l10n gender_other)'</option>'
- echo ' </select>'
- fi
- for n in NICKNAME NICKNAME{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <input class="item NICKNAME" name="NICKNAME" placeholder="'$(l10n NICKNAME)'" value="'$values[$n]'" />'
- done
- if [ -n "$values[BDAY]" ]; then
- echo ' <span class="sectitle">'$(l10n BDAY)'</span>'
- echo ' <input class="item BDAY" name="BDAY" value="'$values[BDAY]'" />'
- fi
- if [ -n "$values[SOUND]" ]; then
- echo ' <audio controls="controls" class="item SOUND">'
- echo ' <source type="audio/ogg" src="data:audio/ogg;base64,'$values[SOUND]'" />'
- echo ' </audio>'
- fi
- [ -n "$values[PHOTO]" ] &&\
- echo ' <img class="item PHOTO" src="data:image/'$tags[PHOTO_TYPE]';base64,'$values[PHOTO]'" />'
- [ -n "$values[LOGO]" ] &&\
- echo ' <img class="item LOGO" src="data:image/'$tags[LOGO_TYPE]';base64,'$values[LOGO]'" />'
- echo ' </div>'
- echo ''
- echo ' <div class="section phone">'
- echo ' <span class="sectitle">'$(l10n TEL)'</span>'
- print -l ${(k)values} |egrep '^TEL[0-9]*$' |while read n; do
- echo ' <input class="item TEL" name="TEL" value="'$values[$n]'" />'
- done
- echo ' </div>'
- echo ''
- echo ' <div class="section message">'
- echo ' <span class="sectitle">'$(l10n EMAIL)'</span>'
- for n in EMAIL EMAIL{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <input class="item EMAIL" name="EMAIL" value="'$values[$n]'" />'
- done
- [ -n "$values[IMPP]" ] && \
- echo ' <span class="sectitle">'$(l10n IMPP)'</span>'
- for n in IMPP IMPP{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <input class="item IMPP" name="IMPP" value="'$values[$n]'" />'
- done
- echo ' </div>'
- echo ''
- echo ' <div class="section address">'
- echo ' <span class="sectitle">'$(l10n ADR)'</span>'
- for n in ADR ADR{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <textarea class="item ADR" name="ADR">'$values[$n]'</textarea>'
- done
- [ -n "$values[URL]" ] && \
- echo ' <span class="sectitle">'$(l10n URL)'</span>'
- for n in URL URL{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <input class="item URL" name="URL" value="'$values[$n]'" />'
- done
- echo ' </div>'
- echo ''
- echo ' <div class="section note">'
- echo ' <span class="sectitle">'$(l10n NOTE)'</span>'
- for n in NOTE NOTE{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <textarea class="item NOTE" name="NOTE">'$values[$n]'</textarea>'
- done
- echo ' </div>'
- echo ''
+[ -z "$values[UID]" ] && values[UID]="$(dbus-uuidgen)"
+
+echo '<div id="'${id}'" class="card">'
+echo '<form action="/?action=update_attendee" method="POST">'
+echo '<input type="hidden" name="card" value="'${id}'"/>'
+echo ' <div class="section basic">'
+echo ' <span class="sectitle">'$(l10n N)'</span>'
+echo ' <input class="item N" name="3N" placeholder="'$(l10n n_pre)'" value="'$n_pre'" />'
+echo ' <input class="item N" name="1N" placeholder="'$(l10n n_first)'" value="'$n_first'" />'
+echo ' <input class="item N" name="2N" placeholder="'$(l10n n_middle)'" value="'$n_middle'" />'
+echo ' <input class="item N" name="0N" placeholder="'$(l10n n_last)'" value="'$n_last'" />'
+echo ' <input class="item N" name="4N" placeholder="'$(l10n n_post)'" value="'$n_post'" />'
+if [ -n "$value[GENDER]" ]; then
echo ' <div class="section control">'
echo ' <select class="item control" name="newfield">'
- echo ' <option value="" disabled="disabled" selected="selected">'$(l10n edit_addfieldtext)'</option>'
- for f in $VCF_FIELDS; do echo "<option value=\"$f\">$(l10n $f)</option>"; done
+ echo ' <option value="" disabled="disabled">'$(l10n GENDER)'</option>'
+ echo ' <option value="female" disabled="disabled" '$(check_gen female)'>'$(l10n female)'</option>'
+ echo ' <option value="male" disabled="disabled" '$(check_gen male)'>'$(l10n male)'</option>'
+ echo ' <option value="other" disabled="disabled" '$(check_gen other)'>'$(l10n gender_other)'</option>'
echo ' </select>'
- echo ' <button class="item control" type="submit" name="action" value="addfield">'$(l10n edit_addfield)'</button>'
- echo ' <button class="item control" type="submit" name="action" value="update">'$(l10n edit_update)'</button>'
- echo ' <button class="item control" type="submit" name="action" value="cancel">'$(l10n edit_cancel)'</button>'
- echo ' </div>'
- echo '<input type="hidden" name="UID" value="'$values[UID]'"/>'
-}
+fi
+for n in NICKNAME NICKNAME{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <input class="item NICKNAME" name="NICKNAME" placeholder="'$(l10n NICKNAME)'" value="'$values[$n]'" />'
+done
+if [ -n "$values[BDAY]" ]; then
+ echo ' <span class="sectitle">'$(l10n BDAY)'</span>'
+ echo ' <input class="item BDAY" name="BDAY" value="'$values[BDAY]'" />'
+fi
+if [ -n "$values[SOUND]" ]; then
+ echo ' <audio controls="controls" class="item SOUND">'
+ echo ' <source type="audio/ogg" src="data:audio/ogg;base64,'$values[SOUND]'" />'
+ echo ' </audio>'
+fi
+[ -n "$values[PHOTO]" ] &&\
+ echo ' <img class="item PHOTO" src="data:image/'$tags[PHOTO_TYPE]';base64,'$values[PHOTO]'" />'
+[ -n "$values[LOGO]" ] &&\
+ echo ' <img class="item LOGO" src="data:image/'$tags[LOGO_TYPE]';base64,'$values[LOGO]'" />'
+echo ' </div>'
+echo ''
+echo ' <div class="section phone">'
+echo ' <span class="sectitle">'$(l10n TEL)'</span>'
+for n in TEL TEL{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <input class="item TEL" name="TEL" value="'$values[$n]'" />'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section message">'
+echo ' <span class="sectitle">'$(l10n EMAIL)'</span>'
+for n in EMAIL EMAIL{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <input class="item EMAIL" name="EMAIL" value="'$values[$n]'" />'
+done
+[ -n "$values[IMPP]" ] && \
+ echo ' <span class="sectitle">'$(l10n IMPP)'</span>'
+for n in IMPP IMPP{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <input class="item IMPP" name="IMPP" value="'$values[$n]'" />'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section address">'
+echo ' <span class="sectitle">'$(l10n ADR)'</span>'
+for n in ADR ADR{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <textarea class="item ADR" name="ADR">'$values[$n]'</textarea>'
+done
+[ -n "$values[URL]" ] && \
+ echo ' <span class="sectitle">'$(l10n URL)'</span>'
+for n in URL URL{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <input class="item URL" name="URL" value="'$values[$n]'" />'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section note">'
+echo ' <span class="sectitle">'$(l10n NOTE)'</span>'
+for n in NOTE NOTE{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <textarea class="item NOTE" name="NOTE">'$values[$n]'</textarea>'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section control">'
+echo ' <button class="item control" type="submit" name="action" value="addfield">'$(l10n edit_addfield)'</button>'
+echo ' <select class="item control" name="newfield">'
+echo ' <option value="" disabled="disabled" selected="selected">'$(l10n edit_addfieldtext)'</option>'
+ for f in $SUP_FIELDS; do echo "<option value=\"$f\">$(l10n $f)</option>"; done
+echo ' </select>'
+echo ' <button class="item control" type="submit" name="action" value="update">'$(l10n edit_update)'</button>'
+echo ' <button class="item control" type="submit" name="action" value="delete">'$(l10n edit_delete)'</button>'
+echo ' <button class="item control" type="submit" name="action" value="cancel">'$(l10n edit_cancel)'</button>'
+echo ' </div>'
+echo '<input type="hidden" name="UID" value="'$values[UID]'"/>'
+echo '</form>'
+echo '</div>'
-edit_attendee() { #Parameter: Cardfile
- id="$1"
- cardfile="vcard/$id"
- unset key
-
- declare -A tags
- declare -A values
- vcf_parse "$cardfile" |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
- [ -n "$value" ] && values[$key]="$value" || values[$key]='\r'
- for t in ${(k)tag}; do
- tags[${key}_$t]="$tag[$t]"
- done
- eval "$line"
- if [ -n "$values[$key]" ]; then
- n=0
- while [ -n "$values[$key$n]" ]; do n=$(($n + 1)); done
- key=$key$n
- fi
- unset value
- unset tag
- fi
- ;;
- esac
- done
- edit_card
-}
item_name[edit]="Bearbeiten"
item_name[vcf_export]="Vcard Exportieren"
item_name[control]="Aktionen"
-item_name[edit_update]="Daten Ã\9cbernehmen"
+item_name[edit_update]="Daten übernehmen"
item_name[edit_cancel]="Abbrechen"
-item_name[edit_addfieldtext]="Feld hinzufügen"
+item_name[edit_delete]="Eintrag löschen"
+item_name[edit_addfieldtext]="Neues Feld"
item_name[edit_addfield]="+"
item_name[edit_deletefield]="X"
item_name[filter_all]="Alles"
item_name[filter_course]="Kurs"
item_name[filter_apply]="Filtern"
item_name[filter_cancel]="Filter löschen"
+item_name[newcard]="Neuen Eintrag anlegen"
l10n() {
[ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1"
-print_card() {
- echo ' <div class="section basic">'
- echo ' <span class="item FN">'$values[FN]'</span>'
- [ -n "$value[GENDER]" ] && \
- echo ' <span class="item GENDER">'$(l10n $values[GENDER])'</span>'
- for n in NICKNAME NICKNAME{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <span class="item NICKNAME">aka. '$values[$n]'</span>'
- done
- [ -n "$values[BDAY]" ] &&\
- echo ' <span class="item BDAY"><b>*:</b> '$values[BDAY]'</span>'
- if [ -n "$values[SOUND]" ]; then
- echo ' <audio controls="controls" class="item SOUND">'
- echo ' <source type="audio/ogg" src="data:audio/ogg;base64,'$values[SOUND]'" />'
- echo ' </audio>'
- fi
- [ -n "$values[PHOTO]" ] &&\
- echo ' <img class="item PHOTO" src="data:image/'$tags[PHOTO_TYPE]';base64,'$values[PHOTO]'" />'
- [ -n "$values[LOGO]" ] &&\
- echo ' <img class="item LOGO" src="data:image/'$tags[LOGO_TYPE]';base64,'$values[LOGO]'" />'
- echo ' </div>'
- echo ''
- echo ' <div class="section phone">'
- echo ' <span class="sectitle">'$(l10n TEL)'</span>'
- for n in TEL TEL{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <span class="item TEL">'$tags[${n}_TYPE]' '$values[$n]'</span>'
- done
- echo ' </div>'
- echo ''
- echo ' <div class="section message">'
- [ -n "$values[EMAIL]" ] && \
- echo ' <span class="sectitle">'$(l10n EMAIL)'</span>'
- for n in EMAIL EMAIL{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <span class="item EMAIL"><a href="mailto:'$values[$n]'">'$values[$n]'</a></span>'
- done
- [ -n "$values[IMPP]" ] && \
- echo ' <span class="sectitle">'$(l10n IMPP)'</span>'
- for n in IMPP IMPP{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <span class="item IMPP">'$tags[${n}_TYPE]' <a href="'$values[$n]'">'$values[$n]'</a></span>'
- done
- echo ' </div>'
- echo ''
- echo ' <div class="section address">'
- echo ' <span class="sectitle">'$(l10n ADR)'</span>'
- for n in ADR ADR{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <span class="item ADR">'$values[$n]'</span>'
- done
- [ -n "$values[URL]" ] && \
- echo ' <span class="sectitle">'$(l10n URL)'</span>'
- for n in URL URL{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <span class="item URL"><a href="'$values[$n]'">'$values[$n]'</a></span>'
- done
- echo ' </div>'
- echo ''
- echo ' <div class="section note">'
- echo ' <span class="sectitle">'$(l10n NOTE)'</span>'
- for n in NOTE NOTE{0..10}; do [ -n "$values[$n]" ] &&\
- echo ' <span class="item NOTE">'$values[$n]'</span>'
- done
- echo ' </div>'
- echo ''
- echo ' <div class="section control">'
- echo ' <a class="item control" href="?page=attendees&edit='${id}'#'${id}'">'$(l10n edit)'</a>'
- echo ' <a class="item control" href="?export=vcard&card='${id}'">'$(l10n vcf_export)'</a>'
- echo ' </div>'
-}
-
-view_attendee() { #Parameter: Cardfile
- id="$1"
- cardfile="vcard/$id"
- cachefile="cache/${id}.cache"
- unset key
- if [ "$cachefile" -nt "$cardfile" ]; then
- cat "$cachefile"
- else
- declare -A tags
- declare -A values
- vcf_parse "$cardfile" |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
- values[$key]="$value"
- for t in ${(k)tag}; do
- tags[${key}_$t]="$tag[$t]"
- done
- eval "$line"
- if [ -n "$values[$key]" ]; then
- n=0
- while [ -n "$values[$key$n]" ]; do n=$(($n + 1)); done
- key=$key$n
- fi
- unset value
- unset tag
- fi
- ;;
- esac
- done
- print_card |tee "$cachefile"
- fi
-}
+echo '<div id="'${id}'" class="card">'
+echo ' <div class="section basic">'
+echo ' <span class="item FN">'$values[FN]'</span>'
+[ -n "$value[GENDER]" ] && \
+ echo ' <span class="item GENDER">'$(l10n $values[GENDER])'</span>'
+for n in NICKNAME NICKNAME{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <span class="item NICKNAME">aka. '$values[$n]'</span>'
+done
+[ -n "$values[BDAY]" ] &&\
+ echo ' <span class="item BDAY"><b>*:</b> '$values[BDAY]'</span>'
+if [ -n "$values[SOUND]" ]; then
+ echo ' <audio controls="controls" class="item SOUND">'
+ echo ' <source type="audio/ogg" src="data:audio/ogg;base64,'$values[SOUND]'" />'
+ echo ' </audio>'
+fi
+[ -n "$values[PHOTO]" ] &&\
+ echo ' <img class="item PHOTO" src="data:image/'$tags[PHOTO_TYPE]';base64,'$values[PHOTO]'" />'
+[ -n "$values[LOGO]" ] &&\
+ echo ' <img class="item LOGO" src="data:image/'$tags[LOGO_TYPE]';base64,'$values[LOGO]'" />'
+echo ' </div>'
+echo ''
+echo ' <div class="section phone">'
+echo ' <span class="sectitle">'$(l10n TEL)'</span>'
+for n in TEL TEL{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <span class="item TEL">'$tags[${n}_TYPE]' '$values[$n]'</span>'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section message">'
+[ -n "$values[EMAIL]" ] && \
+ echo ' <span class="sectitle">'$(l10n EMAIL)'</span>'
+for n in EMAIL EMAIL{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <span class="item EMAIL"><a href="mailto:'$values[$n]'">'$values[$n]'</a></span>'
+done
+[ -n "$values[IMPP]" ] && \
+ echo ' <span class="sectitle">'$(l10n IMPP)'</span>'
+for n in IMPP IMPP{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <span class="item IMPP">'$tags[${n}_TYPE]' <a href="'$values[$n]'">'$values[$n]'</a></span>'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section address">'
+echo ' <span class="sectitle">'$(l10n ADR)'</span>'
+for n in ADR ADR{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <span class="item ADR">'$values[$n]'</span>'
+done
+[ -n "$values[URL]" ] && \
+ echo ' <span class="sectitle">'$(l10n URL)'</span>'
+for n in URL URL{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <span class="item URL"><a href="'$values[$n]'">'$values[$n]'</a></span>'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section note">'
+echo ' <span class="sectitle">'$(l10n NOTE)'</span>'
+for n in NOTE NOTE{0..10}; do [ -n "$values[$n]" ] &&\
+ echo ' <span class="item NOTE">'$values[$n]'</span>'
+done
+echo ' </div>'
+echo ''
+echo ' <div class="section control">'
+echo ' <a class="item control" href="?page=attendees&edit='${id}'">'$(l10n edit)'</a>'
+echo ' <a class="item control" href="?export=vcard&card='${id}'">'$(l10n vcf_export)'</a>'
+echo ' </div>'
+echo '</div>'