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
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}
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
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 ============= */