From: Paul Hänsch Date: Tue, 2 Feb 2021 13:06:22 +0000 (+0100) Subject: seed field for entering card record from spreadsheet X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=1227cb42309bc7edd296e8fea288f68968b1e003;p=lobster seed field for entering card record from spreadsheet --- diff --git a/cards/index.cgi b/cards/index.cgi index 933b1d1..e25843c 100755 --- a/cards/index.cgi +++ b/cards/index.cgi @@ -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 diff --git a/cards/new_card.sh b/cards/new_card.sh index db353e1..1e37b70 100755 --- a/cards/new_card.sh +++ b/cards/new_card.sh @@ -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 diff --git a/style.css b/style.css index 83ceae7..e02a695 100644 --- 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 ============= */