| sed -r '/^[\t ]*$/d'
}
-listcards() {
+listcards_order(){
+ while read file; do
+ case "${_GET[order]}" in
+ firstname)
+ printf '%s\t%s\n' "$(sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$file")" "$file"
+ ;;
+ lastname)
+ printf '%s\t%s\n' "$(sed -rn 's:^N(;.+)*\:([^;]*;){0} *([^;]*).*$:\3:p' "$file")" "$file"
+ ;;
+ bdate)
+ printf '%s\t%s\n' "$(sed -rn 's:^BDAY(;.+)*\:(.*)$:\2:p' "$file")" "$file"
+ ;;
+ *) printf 'x\t%s\n' "$file"
+ ;;
+ esac
+ done \
+ | sort -u |sed -r 's;^.*\t;;'
+}
+
+listcards_filter(){
filterex='s;^([^\n]+)\n.*$;\1;p'
printf '%s\n' "${_GET[filter]}" |tr '^' '\n' \
| sed -r 's;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\\\&;g' \
filterex='/(^|\n)'"${expr}"'/I{'"${filterex}"'}'
done
- for file in "${_DATA}/vcard/"*.vcf; do
- case "${_GET[order]}" in
- firstname)
- printf '%s\t%s\n' "$(sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$file")" "$file"
- ;;
- lastname)
- printf '%s\t%s\n' "$(sed -rn 's:^N(;.+)*\:([^;]*;){0} *([^;]*).*$:\3:p' "$file")" "$file"
- ;;
- bdate)
- printf '%s\t%s\n' "$(sed -rn 's:^BDAY(;.+)*\:(.*)$:\2:p' "$file")" "$file"
- ;;
- *) printf 'x\t%s\n' "$file"
- ;;
- esac
- done \
- | sort -u |sed -r 's;^.*\t;;' \
- | while read n; do
+ while read n; do
{ printf '%s\n' "$n"; cat "$n"; } \
- | sed -rn ':X;N;$!bX; {'"$filterex"'}'
- done \
- | sed -r 's;^(.*/)*;;;'
+ | sed -En ':X;N;$!bX; {'"$filterex"'}'
+ done
+
+}
+
+listcards() {
+ printf %s\\n "${_DATA}/vcard/"*.vcf \
+ | listcards_filter \
+ | listcards_order \
+ | sed -E 's;^(.*/)*;;;'
+}
+
+listcards_mail() {
+ printf %s\\n "${_DATA}/vcard/"*.vcf \
+ | listcards_filter \
+ | xargs -r -d\\n sed -En 's:^EMAIL(;.+)*\:(.+)\r$:\2,:p'
}
vcf_parse() {
item_name[label_join]="Anm."
item_name[label_leave]="Abm."
+item_name[mail_all]="Mail an alle gelisteten"
item_name[edit]="Bearbeiten"
item_name[edit_categories]="Kategorien Bearbeiten"
item_name[vcf_export]="Vcard Exportieren"