From 29be3bef3870c3515f0c933a3a97479bf98f9cd4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 14 May 2019 14:20:23 +0200 Subject: [PATCH] cleanup --- cards/cards.sh | 129 ----------------------- cards/edit_card.sh | 27 ----- cards/edit_card.template.sh | 199 ------------------------------------ 3 files changed, 355 deletions(-) delete mode 100755 cards/cards.sh delete mode 100755 cards/edit_card.sh delete mode 100755 cards/edit_card.template.sh diff --git a/cards/cards.sh b/cards/cards.sh deleted file mode 100755 index a26b1fc..0000000 --- a/cards/cards.sh +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 - 2017 Paul Hänsch -# -# This file is part of Confetti. -# -# Confetti is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Confetti is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Confetti. If not, see . - -BR=' -' - -force_items(){ - for each in "$@"; do - [ -z "${values[$each]+x}" ] && values[${each}]='' - done -} - -case $PROFILE in -medical) - SUP_FIELDS=(N NICKNAME GENDER BDAY ADR TEL EMAIL X-HEALTH-INSURANCE X-HEALTH-INSURANCE-NOCONTRIB IMPP URL NOTE X-CLIENT-REFERRAL) - FORCE_ITEMS=(ADR TEL EMAIL NOTE X-CLIENT-REFERRAL) - _GET[order]="${_GET[order]:-lastname}" - _GET[filtertype]="${_GET[filtertype]:-name}" - profile_medical=x -;; -circus) - SUP_FIELDS=(N NICKNAME GENDER BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE EMAIL TEL IMPP ADR URL NOTE) - FORCE_ITEMS=(BDAY X-ZACK-JOINDATE TEL EMAIL ADR NOTE) - _GET[order]="${_GET[order]:-firstname}" - _GET[filtertype]="${_GET[filtertype]:-any}" - profile_circus=x -;; -esac - -edit="${_GET[edit]}" -[ \! -f "vcard/$edit" -a \! -f "temp/$edit" ] && edit='' - -listcourses() { - ls -1 ${_DATA}/ical/*ics |while read file; do - icstime="$(sed -rn 's:^DTSTART\:(TZID=.*\:)?([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2})([0-9]{2})([0-9]{2})Z?\r$:\2-\3-\4 \5\:\6\:\7:p' "$file")" - echo "$(date -d "$icstime" "+%u %H%M%S")\t$file" - done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:' -} - -list_hi_companies(){ - sed -rn 's;^X-HEALTH-INSURANCE:([^\;]+)\;.*$;\1;p' ${_DATA}/vcard/*vcf \ - | sort -u -} - -list_categories() { - catfile="${_DATA}/mappings/categories" - sort -u "$catfile" \ - | sed -r '/^[\t ]*$/d' -} - -listcards() { - filterex='s;^([^\n]+)\n.*$;\1;p' - printf '%s\n' "${_GET[filter]}" |tr '^' '\n' \ - | sed -r 's;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\\\&;g' \ - | while read each; do - case $each in - name:*) expr='(FN|NICKNAME|N)(\;[^\n]+)*:[^\n]*'"(${each#*:})";; - street:*) expr='ADR(\;[^\n]+)*:([^\;]*;){2}[^\;\n]*'"(${each#*:})";; - zip:*) expr='ADR(\;[^\n]+)*:([^\;]*;){5}[^\;\n]*'"(${each#*:})";; - any:*|:*) expr="[^\n]*"'(\;[^\n]+)*:[^\n]*'"(${each#*:})";; - *:*) expr="${each%%:*}"'(\;[^\n]+)*:[^\n]*'"(${each#*:})";; - *) expr="(${each})";; - esac - filterex='/(^|\n)'"${expr}"'/I{'"${filterex}"'}' - done - - for file in "${_DATA}/vcard/"*.vcf; do - case "${_GET[order]}" in - firstname) - printf '%s\t%s\n' "$(sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$file")" "$file" - ;; - lastname) - printf '%s\t%s\n' "$(sed -rn 's:^N(;.+)*\:([^;]*;){0} *([^;]*).*$:\3:p' "$file")" "$file" - ;; - bdate) - printf '%s\t%s\n' "$(sed -rn 's:^BDAY(;.+)*\:(.*)$:\2:p' "$file")" "$file" - ;; - *) printf 'x\t%s\n' "$file" - ;; - esac - done \ - | sort -u |sed -r 's;^.*\t;;' \ - | while read n; do - { printf '%s\n' "$n"; cat "$n"; } \ - | sed -rn ':X;N;$!bX; {'"$filterex"'}' - done \ - | sed -r 's;^(.*/)*;;;' -} - -view_card() { #Parameter: Cardfile - id="$1" - cardfile="$_DATA/vcard/${id}" - cachefile="$_DATA/cache/${id}.cache" - if [ "$cachefile" -nt "$cardfile" ]; then - cat "$cachefile" - else - declare -A values - vcf_parse "$cardfile" - . "$_EXEC/templates/view_card.sh" |tee "$cachefile" - fi -} - -edit_card() { #Parameter: Cardfile - id="$1" - cardfile="$_DATA/vcard/$id" - tempfile="$_DATA/temp/$id" - [ -f "$tempfile" ] && cardfile="$tempfile" - - declare -A values - vcf_parse "$cardfile" - force_items $FORCE_ITEMS - . "$_EXEC/templates/edit_card.sh" -} diff --git a/cards/edit_card.sh b/cards/edit_card.sh deleted file mode 100755 index f90b326..0000000 --- a/cards/edit_card.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/zsh - -# Copyright 2014 Paul Hänsch -# -# This file is part of Confetti. -# -# Confetti is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Confetti is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Confetti. If not, see . - -cgi_refdata - -card="${_GET[card]}" -filter="&filter=${_REF[filter]}" -filtertype="&filtertype=${_REF[filtertype]}" -order="&order=${_REF[order]}" - -echo -n "Location: ?p=cards${filter}${filtertype}${order}&edit=$card\n\n" diff --git a/cards/edit_card.template.sh b/cards/edit_card.template.sh deleted file mode 100755 index bc71db2..0000000 --- a/cards/edit_card.template.sh +++ /dev/null @@ -1,199 +0,0 @@ -# Copyright 2014 - 2017 Paul Hänsch -# -# This file is part of Confetti. -# -# Confetti is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Confetti is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with Confetti. If not, see . - -setchecked() { - printf 'checked="checked"' -} -setselected() { - printf 'selected="selected"' -} -check_gen() { - [ "$values[GENDER]" = "$1" ] && setselected -} -check_a() { - egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked -} -check_c() { - for n in CATEGORIES CATEGORIES{0..100}; do - if [ -n "${values[$n]+x}" ]; then - [ "${values[$n]}" = "$1" ] && setchecked && break - else - break - fi - done -} - -teltype() { - cat <<-EOF - - EOF -} - -list_items(){ - item="$1" - placeholder="$2" - [ -n "${values[$item]+x}" ] && printf '

%s

\n' "$(l10n $item)" - for n in "$item" "$item"{0..100}; do - if [ -n "${values[$n]+x}" ]; then - case "$item" in - (ADR|NOTE) - printf '\n' \ - "$item" "$item" "$(htmlsafe ${values[$n]})" - ;; - (TEL) - teltype "${values[${n}_TYPE]}" - printf '\n' \ - "$item" "$item" "$(attribsafe ${values[$n]})" - ;; - (*) - printf '\n' \ - "$item" "$item" "$(attribsafe ${values[$n]})" "$placeholder" - ;; - esac - else - break - fi - done -} - -list_section(){ - printf '
' "$1" - shift 1 - for each in $@; do - list_items "$each" - done - printf '
' -} - -hi_company="${values[X-HEALTH-INSURANCE+0]}" - hi_number="${values[X-HEALTH-INSURANCE+1]}" - hi_status="${values[X-HEALTH-INSURANCE+2]}" - -[ -z "$values[UID]" ] && values[UID]="$(uuidgenerator)" - -cat < - -
-

$(l10n N)

- - - - - - - -END_HTML - - for n in NICKNAME NICKNAME{0..100}; do - [ -z "${values[$n]+x}" ] && break \ - || printf ' - - ' "$(attribsafe ${values[$n]})" "$(l10n NICKNAME)" - done - - list_items BDAY YYYY-MM-DD - list_items X-ZACK-JOINDATE YYYY-MM-DD - list_items X-ZACK-LEAVEDATE YYYY-MM-DD - - [ -n "$values[SOUND]" ] && printf ' - ' "$values[SOUND]" - - [ -n "$values[PHOTO]" ] && printf ' - - ' "${values[PHOTO_TYPE]}" "${values[PHOTO]}" - - [ -n "$values[LOGO]" ] && printf ' - - ' "${values[LOGO_TYPE]}" "${values[LOGO]}" - -printf '
' - -if [ "$PROFILE" = circus ]; then - list_section phone TEL - list_section message EMAIL IMPP URL - list_section address ADR - list_section note NOTE X-CLIENT-REFERRAL - cat <<-END_HTML -
-

$(l10n course_attendance)

- $(listcourses |while read each; do - cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")" - printf '' \ - "$(attribsafe "$each")" "$(check_a "$each")" "$(htmlsafe "$cname")" - done) -

$(l10n CATEGORIES)

- $(list_categories |while read each; do - printf '' \ - "$(attribsafe "$each")" "$(check_c "$each")" "$(htmlsafe "$each")" - done) -
- END_HTML -elif [ "$PROFILE" = medical ]; then - list_section address ADR - list_section phone TEL EMAIL IMPP URL - cat <<-END_HTML -
-

$(l10n X-HEALTH-INSURANCE)

- - - - - -
- END_HTML - list_section note NOTE X-CLIENT-REFERRAL -fi - - -cat < - - - - - - - - -END_HTML -- 2.39.2