]> git.plutz.net Git - lobster/commitdiff
seed field for entering card record from spreadsheet
authorPaul Hänsch <paul@plutz.net>
Tue, 2 Feb 2021 13:06:22 +0000 (14:06 +0100)
committerPaul Hänsch <paul@plutz.net>
Tue, 2 Feb 2021 13:06:22 +0000 (14:06 +0100)
cards/index.cgi
cards/new_card.sh
style.css

index 933b1d188c1a5aea53876e77c40139ea00681ef1..e25843c54d68e8019fad4977382e31d4fdc5ca85 100755 (executable)
@@ -18,8 +18,12 @@ edit="${edit##*/}"
   printf '
   [form class="newcard" action="/cards/new_card.sh" method="POST"
     [button type="submit" %s]
-  ]' "$(l10n newcard)"
-
+    [input name="seed" placeholder="%s %s      %s      %s      %s      %s      %s      ()      %s      ()      %s"]
+  ]' "$(l10n newcard)" \
+     "$(l10n X-ZACK-JOINDATE)" "$(l10n n_first)" "$(l10n n_last)" \
+     "$(l10n BDAY) $(l10n month)" "$(l10n BDAY) $(l10n year)" \
+     "$(l10n TEL)" "$(l10n TEL) $(l10n 'TYPE=CELL')" "$(l10n EMAIL)" \
+     "$(l10n NOTE)"
   [ "$edit" ] && edit_card "$edit"
   list_cards
 } | yield_page cards #/cards/cards.css
index db353e1a1943b4eb00c5daa6dfd36cd9815e6679..1e37b7001af3c84a86d25409cdc8e81bc3e272ed 100755 (executable)
@@ -23,6 +23,22 @@ order="$(REF o)"
 uid="$(timeid)$(randomid)"  # 32 Octets UID, starting with timestamp
 card="${uid}.vcf"
 
+vcf_escape(){
+  for each in "$@"; do
+    printf %s\\n "$each" \
+    | sed -E ':X;$!{N;bX}; s;\r\n;\n;g; s;([;,\\]);\\\1;g; s;\n;\\n;g;'
+  done \
+  | sed -E ':X;$!{N;bX}; s;\n;\;;g'
+}
+
+IFS='|' read -r date fn ln bmonth byear tel tcell junk1 email junk2 note <<-EOF
+       $(POST seed |tr \\t \|)
+       EOF
+
+[ ${#byear} = 1 ] && byear="200$byear"
+[ ${#byear} = 2 ] && byear="20$byear"
+[ ${#bmonth} = 1 ] && bmonth="0$bmonth"
+
 mkdir -p "${_DATA}/lock/vcard/"
 lockdir="${_DATA}/lock/vcard/${card}/"
 lockfile=${lockdir}/${SESSION_ID}
@@ -31,12 +47,15 @@ if mkdir "$lockdir"; then
   cat >"$lockfile" <<-EOF
        BEGIN:VCARD
        VERSION:4.0
-       N:;;;;
-       BDAY:
-       TEL:
-       EMAIL:
+       N:$(vcf_escape "$ln");$(vcf_escape "$fn");;;
+       FN:$(vcf_escape "$fn $ln")
+       BDAY:$(vcf_escape "${byear}-${bmonth}-01")
+       TEL:$(vcf_escape "$tel")
+       TEL;TYPE=CELL:$(vcf_escape "$tcell")
+       EMAIL:$(vcf_escape "$email")
+       X-ZACK-JOINDATE:$(vcf_escape "$date")
        ADR:
-       NOTE:
+       NOTE:$(vcf_escape "$note")
        UID:${uid}
        END:VCARD
        EOF
index 83ceae7ee39f6dd2b463bebd6f324a75b7bf0140..e02a695bb0cab9dfdea2c36cc2e00b31dc830320 100644 (file)
--- a/style.css
+++ b/style.css
@@ -171,6 +171,9 @@ form.filter button[type=submit] {
 
 body.courses form .order { display: inline-block; margin-right: 2em;}
 
+body.cards form.newcard { display: flex; }
+body.cards form.newcard input[name=seed] { flex: 1; }
+
 
 /* ============ LIST ITEMS, Generic ============= */