mailto: function in card listing master
authorPaul Hänsch <paul@plutz.net>
Thu, 7 Feb 2019 09:15:20 +0000 (10:15 +0100)
committerPaul Hänsch <paul@plutz.net>
Thu, 7 Feb 2019 09:15:20 +0000 (10:15 +0100)
pages/cards.sh
static/cards.css
templates/cards.html.sh
templates/text_cards.sh

index a90981c..538146d 100755 (executable)
@@ -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() {
index 981a667..039bd99 100644 (file)
   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;
index bf84eee..e486317 100755 (executable)
@@ -109,6 +109,10 @@ cat <<EOF
 </form>
 
 ${edit:+$(edit_card "$edit")}
+
+<div class="dash">
+  <a href="mailto:zack@vuesch.org?bcc=$(attribsafe $(listcards_mail))">$(l10n mail_all)</a>
+</div>
 EOF
 
 listcards |grep ${edit:+-v} "$edit" \
index aaa6832..3168a69 100755 (executable)
@@ -92,6 +92,7 @@ item_name[X-ZACK-LEAVEDATE]="Ab&shy;mel&shy;de&shy;da&shy;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"