2 # Copyright 2015, 2017, 2018, 2021 Paul Hänsch
4 # This file is part of Confetti.
6 # Confetti is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Confetti is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Confetti. If not, see <http://www.gnu.org/licenses/>.
20 . $_EXEC/categories/l10n.sh
22 catfile="${_DATA}/mappings/categories"
25 grep -vxE '[ ]*' "$catfile" |sort -u
29 local vcf="$1" card="$2" n=1 cats="${BR}"
30 while cats="${cats}${BR}$(pdi_value "$vcf" CATEGORIES $n)"; do n=$((n + 1)); done
32 list_categories |while read cat; do
33 printf '[li [label [input %s type="checkbox" name="%s" value="%s"] %s]]' \
34 "$([ "${cats%*${BR}${cat}${BR}*}" != "$cats" ] && printf checked=checked)" \
35 "$(HTML "$card")" "$(HTML "$cat")" "$(HTML "$cat")"
39 cat <<EOF |yield_page categories
40 [form .categories action="edit_categories.sh" method="POST"
41 [h1 $(l10n categories_label)]
42 [input type="hidden" name="page" value="categories"]
44 $(list_categories | while read cat; do
45 printf '[li . %s [button type="submit" name="remove" value="%s" . %s]]\n' \
46 "$(HTML "$cat")" "$(HTML "$cat")" "$(l10n cat_remove)"
49 [input type="text" name="newcat" placeholder="$(l10n cat_newlabel)"]
50 [button type="submit" name="add" value="add" . $(l10n cat_add)]
55 [form .namelist action="update_categories.sh" method="POST"
57 [button type="submit" name="submit" value="submit" . $(l10n cat_update)]
60 $(for vcffile in "$_DATA"/vcard/*vcf; do
61 vcf="$(pdi_load "$vcffile")"
62 printf ' [li [h2 . %s][ul ' "$(pdi_value "$vcf" FN)"
63 list_catsel "$vcf" "${vcffile##*/}"
68 [button type="submit" name="submit" value="submit" . $(l10n cat_update)]