]> git.plutz.net Git - confetti/commitdiff
mailto: function in card listing
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 a90981c6a16d02ec265bc80653aed9b29b90eca4..538146d83749fdc2b1c24d403c1a69e51487b090 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 981a667e217e69876d4f24170ddabedefff137c4..039bd995ab52c7de51a007f56adf5f5b9d2c6030 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 bf84eee2eb4109452354c111421c817eef84a495..e486317117b908fd90fab8ace14555924bc8fa85 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 aaa68324160b99054317eb5ba98590c56b3718ee..3168a69f5cdd2349e1972515d5ca14b090a79ed2 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"