]> git.plutz.net Git - lobster/blobdiff - cards/new_card.sh
quick fix: put temp file into lock, should switch to session_lock functions
[lobster] / cards / new_card.sh
index db353e1a1943b4eb00c5daa6dfd36cd9815e6679..a8afc7a4f88b986321f993367ffbb04d53e31a63 100755 (executable)
@@ -23,6 +23,22 @@ order="$(REF o)"
 uid="$(timeid)$(randomid)"  # 32 Octets UID, starting with timestamp
 card="${uid}.vcf"
 
+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"
+
+mn=""
+case $fn in
+  *\ *)
+    mn="${fn#* }"
+    fn="${fn%% *}"
+    ;;
+esac
+
 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:$(pdi_escape "$ln" "$fn" "$mn" "" "")
+       FN:$(pdi_escape "${fn}${mn:+ }${mn} ${ln}")
+       BDAY:$(parse_date "${byear}-${bmonth}-01")
+       TEL:$(pdi_escape "$tel")
+       TEL;TYPE=CELL:$(pdi_escape "$tcell")
+       EMAIL:$(pdi_escape "$email")
+       X-ZACK-JOINDATE:$(parse_date "$date")
        ADR:
-       NOTE:
+       NOTE:$(pdi_escape "$note")
        UID:${uid}
        END:VCARD
        EOF