X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=cards%2Flist.sh;h=616d6abb1b966f90531937d1aa5a6938e5c5da5f;hb=f703db26c2ea1e49e7580452ef0ee89557b18525;hp=cd0d21f1e320aa958839b8fdbe75dec051286da9;hpb=79a7bb3560f305a48ecd2b2f2b9957c206fa6792;p=lobster diff --git a/cards/list.sh b/cards/list.sh index cd0d21f..616d6ab 100755 --- a/cards/list.sh +++ b/cards/list.sh @@ -13,47 +13,26 @@ edit_card(){ else card="$(pdi_load "$tempfile")" cat <<-EOF - [form .card #${cardfile##*/} action="/cards/update_card.sh" method="POST" + [span .card-anchor #${cardfile##*/}] + [form .card action="/cards/update_card.sh" method="POST" [input type="hidden" name="tid" value="$(transid ${tempfile})"] [div .section .basic $( edit_item "$card" N GENDER [ "$(pdi_count "$card" NICKNAME)" -gt 0 ] \ && edit_item "$card" NICKNAME edit_item "$card" BDAY - edit_item "$card" X-ZACK-JOINDATE - [ "$(pdi_count "$card" X-ZACK-LEAVEDATE)" -gt 0 ] \ - && edit_item "$card" X-ZACK-LEAVEDATE card_item "$card" SOUND PHOTO LOGO )] - [div .section .phone $(edit_item "$card" TEL)] - [div .section .message $( - edit_item "$card" EMAIL - [ $(pdi_count "$card" IMPP) -gt 0 ] && edit_item "$card" IMPP - [ $(pdi_count "$card" URL ) -gt 0 ] && edit_item "$card" URL - )] + [div .section .phone $( + edit_item "$card" TEL EMAIL + [ $(pdi_count "$card" IMPP) -gt 0 ] \ + && edit_item "$card" IMPP + [ $(pdi_count "$card" URL ) -gt 0 ] \ + && edit_item "$card" URL + )] [div .section .address $(edit_item "$card" ADR)] - [div .section .note $(edit_item "$card" NOTE)] - [div .section .attendance - [h3 $(l10n course_attendance) ] $( - for course in "$_DATA"/ical/*.ics; do - printf '[label [input type="checkbox" name="attendance" value="%s" %s] %s]' \ - "${course##*/}" \ - "$(grep -qF "${course##*/} ${cardfile##*/}" "$_DATA/mappings/attendance" \ - && printf 'checked="checked"' - )" \ - "$(pdi_value "$(pdi_load "$course")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)" - done) - [h3 $(l10n CATEGORIES) ] $( - grep -xE '[^ ]+' "$_DATA"/mappings/categories |while read -r cat; do - printf '[label [input type="checkbox" name="CATEGORIES" value="%s" %s] %s]' \ - "$(HTML "$cat")" \ - "$(seq 1 $(pdi_count "$card" CATEGORIES) |while read c; do - pdi_value "$card" CATEGORIES $c |grep -qxF "$cat" \ - && printf 'checked="checked"' && break - done)" \ - "$(HTML "$cat")" - done) - ] + [div .section .insurance $(edit_item "$card" X-HEALTH-INSURANCE)] + [div .section .note $(edit_item "$card" NOTE X-CLIENT-REFERRAL)] [div .control [div .item .delete label="$(l10n edit_delete)" [input type="checkbox" #delete] @@ -81,26 +60,27 @@ edit_card(){ print_card(){ local cardfile="$1" local card="$(pdi_load "$cardfile")" + local N1 N2 N3 N4 N5 + IFS=\; read N1 N2 N3 N4 N5 <<-EOF + $(pdi_value "$card" N |pdi_unescape |HTML) + EOF + cat <<-EOF [div .card #${cardfile##*/} - [div .section .basic . $( - card_item "$card" FN GENDER NICKNAME BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE SOUND PHOTO LOGO + [div .section .basic + [h2 .item .FN . $N4 $N1 $N5] + [span .item .firstname . $N2 $N3] + $( + card_item "$card" GENDER NICKNAME BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE SOUND PHOTO LOGO )] - [div .section .phone . $(card_item "$card" TEL)] - [div .section .message . $(card_item "$card" EMAIL IMPP URL)] - [div .section .address . $(card_item "$card" ADR)] - [div .section .note . $(card_item "$card" NOTE)] - [div .section .attendance [h3 $(l10n course_attendance) ] [ul - $(grep -F " ${cardfile##*/}" "$_DATA/mappings/attendance" |while read each discard; do - printf '[li [a .item .attendance href="/courses#%s" . %s]]' \ - "$each" \ - "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)" - done)] - $(card_item "$card" CATEGORIES) - ] + [div .section .address $(card_item "$card" ADR)] + [div .section .phone $(card_item "$card" TEL EMAL IMPP URL)] + [div .section .insurance $(card_item "$card" X-HEALTH-INSURANCE)] + [div .section .note $(card_item "$card" NOTE X-CLIENT-REFERRAL)] + [div .section .therapies $(card_item "$card" therapies)] [div .control - [a .item href="/cards/edit_card.sh?card=${cardfile##*/}" $(l10n edit)] - [a .item href="/cards/export_card.sh?card=${cardfile##*/}" $(l10n vcf_export)] + [a .item .button href="/cards/edit_card.sh?card=${cardfile##*/}" $(l10n edit)] + [a .item .button href="/cards/export_card.sh?card=${cardfile##*/}" $(l10n vcf_export)] ] ] EOF @@ -111,8 +91,6 @@ print_cards(){ while read cardfile; do cachefile="${_DATA}/cache/${cardfile##*/}.cache" - # if [ -s "$cachefile" -a "$cachefile" -nt "$cardfile" \ - # -a "$cachefile" -nt "${_EXEC}/cards" ]; then if [ -s "$cachefile" -a "$cachefile" -nt "$cardfile" ]; then cat "$cachefile" else @@ -121,31 +99,6 @@ print_cards(){ done } -filter_attendance(){ - fatt="$1" - attfile="$_DATA/mappings/attendance" - - if [ ! "$fatt" ]; then - # debug 'list all' - printf '%s\n' "$_DATA/vcard"/*.vcf - elif [ "${fatt#* }" = "${fatt}" ]; then - # debug "list $fatt" - grep -xiE "(${fatt}) .+vcf" "$attfile" \ - | while read vcf; do - printf '%s/vcard/%s\n' "$_DATA" "${vcf##* }" - done - else - # debug "filter ${fatt%% *}" - filter_attendance "${fatt#* }" \ - | while read vcf; do - grep -xiE "(${fatt%% *}) ${vcf##*/}" "$attfile" - done \ - | while read vcf; do - printf '%s/vcard/%s\n' "$_DATA" "${vcf##* }" - done - fi -} - filter_cards(){ local filter f fex='x;p;' @@ -156,11 +109,10 @@ filter_cards(){ while [ "$filter" ]; do f="${filter%%^*}" filter="${filter#*^}" + debug "Filter: $f" case $f in '') break ;; - COURSE:*) fatt="${fatt}${fatt:+ }${f#*:}" - ;; ANY:*) fex="/\n.*(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}" ;; NAME:*) fex="/\n(N|FN|NICKNAME)(\;[^:]*)?:[^\n]*(${f#*:})[^\n]*\r?\n/{${fex}}" @@ -172,12 +124,10 @@ filter_cards(){ esac done - # for cardfile in "${_DATA}"/vcard/*.vcf; do - filter_attendance "$fatt" |while read cardfile; do - printf '%s\n' "$cardfile" - cat "$cardfile" + for cardfile in "${_DATA}"/vcard/*.vcf; do + printf '%s\n' "$cardfile" "$(grep -vxE " *${CR}?" "$cardfile")" done \ - | sed -nE ':X; /\nEND\;?:VCARD\r?$/!{ N; bX; }; h; s;\n.*$;;; x; s;^[^\n]+\n;;; + | sed -En ':X; /\nEND;?:VCARD\r?$/!{ N; bX; }; h; s;\n.*$;;; x; s;^[^\n]+\n;;; '"$upcase""$fex" }