From: Paul Hänsch Date: Thu, 7 Feb 2019 09:15:20 +0000 (+0100) Subject: mailto: function in card listing X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=90288ab07bb1ec83a91581fadc674a87a250a853;p=confetti mailto: function in card listing --- diff --git a/pages/cards.sh b/pages/cards.sh index a90981c..538146d 100755 --- a/pages/cards.sh +++ b/pages/cards.sh @@ -64,7 +64,26 @@ list_categories() { | 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' \ @@ -80,27 +99,24 @@ listcards() { 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() { diff --git a/static/cards.css b/static/cards.css index 981a667..039bd99 100644 --- a/static/cards.css +++ b/static/cards.css @@ -106,6 +106,16 @@ background: #EFF; } +.dash { + display: block; + border: solid 1px; + border-radius: 4px 4px 0 0; + margin: .25em 2em .25em 2em; + padding: .25em 2ex .25em 2ex; + background: #EFF; + text-align: right; +} + .card { display: block; position: relative; diff --git a/templates/cards.html.sh b/templates/cards.html.sh index bf84eee..e486317 100755 --- a/templates/cards.html.sh +++ b/templates/cards.html.sh @@ -109,6 +109,10 @@ cat < ${edit:+$(edit_card "$edit")} + + EOF listcards |grep ${edit:+-v} "$edit" \ diff --git a/templates/text_cards.sh b/templates/text_cards.sh index aaa6832..3168a69 100755 --- a/templates/text_cards.sh +++ b/templates/text_cards.sh @@ -92,6 +92,7 @@ item_name[X-ZACK-LEAVEDATE]="Ab­mel­de­da­tum" 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"