From: paul Date: Thu, 25 Feb 2016 17:52:28 +0000 (+0000) Subject: page to categorize vcards into groups X-Git-Url: https://git.plutz.net/?p=confetti;a=commitdiff_plain;h=5414898a3baef825844eda3f4416bfea5ecc9555 page to categorize vcards into groups svn path=/trunk/; revision=83 --- diff --git a/actions/edit_categories.sh b/actions/edit_categories.sh new file mode 100755 index 0000000..7f767e9 --- /dev/null +++ b/actions/edit_categories.sh @@ -0,0 +1,32 @@ +#!/bin/zsh + +# Copyright 2015 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 . + +catfile="${_DATA}/mappings/categories" +cgi_post + +remove="${_POST[remove]}" +newcat="${_POST[newcat]}" + +if [ "${_POST[add]}" = "add" ]; then + printf %s\\n "$newcat" >>"$catfile" +elif [ -n "$remove" ]; then + sed -ri '/^'"${remove}"'$/d' $catfile +fi + +redirect "?p=categories" diff --git a/pages/categories.sh b/pages/categories.sh new file mode 100755 index 0000000..88d78c2 --- /dev/null +++ b/pages/categories.sh @@ -0,0 +1,44 @@ +#!/bin/zsh + +# Copyright 2015 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 . + +catfile="${_DATA}/mappings/categories" + +listcards() { + ls -1 ${_DATA}/vcard/*vcf 2>/dev/null |while read file; do + fn=$(sed -rn 's:^N(;.+)*\:([^;]*;){1} *([^;]*).*$:\3:p' "$file") + echo "$fn\t$file" + done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:' +} + +get_name() { + cfile="${_DATA}/vcard/$1" + sed -rn 's:^N(;[^"\:]+|;"[^"]+")*\:([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?\r?$:\5 \3 \4 \2 \6:p' "$cfile" \ + |sed -r 's:,: :;s:\;: :g;s: +: :g' \ +} + +get_categories(){ + cfile="${_DATA}/vcard/$1" + sed -rn 's:^CATEGORIES(;[^"\:]+|;"[^"]+")*\:(.+)\r?$:\2:p' "$cfile" \ + | sed -r 's;(^|[^\\]+)((\\\\)+),;\1\2\n;g; s;(^|[^\\]),;\1\n;g; s;(^|[^\\]+)((\\\\)+),;\1\2\n;g; s;(^|[^\\]),;\1\n;g; s;\\,;,;g' \ + | sort -u +} + +list_categories() { + sort -u "$catfile" +} diff --git a/templates/categories.css.sh b/templates/categories.css.sh new file mode 100755 index 0000000..31381a5 --- /dev/null +++ b/templates/categories.css.sh @@ -0,0 +1,98 @@ +# Copyright 2014, 2015 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 . + +cat < fieldset { + display: block; + border: solid 1px; + border-radius: 4px 4px 0 0; + margin: 0; padding: .25em 2ex; + background: #EFF; + text-align: right; +} +form.namelist > fieldset:last-of-type { + border-radius: 0 0 4px 4px; +} +ul.namelist { margin: 0; padding: 0;} +ul.namelist > li { + display: block; + border: solid 1px; + margin: -1px 0; + background: #FFF; +} +ul.namelist > li:nth-of-type(2n){ background: #EEE;} + +ul.namelist h2 { + font-size: 1em; + display: inline-block; + margin: 0; + padding: 0 1ex; + min-width: 30ex; +} +ul.namelist ul { margin: 0; padding: 0; display: inline-block;} +ul.namelist ul li { + display: inline-block; + margin: 0 1ex 0 0; +} +EOF + +# vi:set filetype=css: diff --git a/templates/categories.html.sh b/templates/categories.html.sh new file mode 100755 index 0000000..5375965 --- /dev/null +++ b/templates/categories.html.sh @@ -0,0 +1,71 @@ +# Copyright 2015 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 . + +cat_listing(){ + list_categories | while read cat; do + cat <<-END +
  • ${cat}
  • + END + done +} + +list_catsel(){ + card="$1" + cats="$(get_categories $card)" + + list_categories |while read cat; do + cat <<-END +
  • + END + done +} + +display_catsel(){ + card="$1" + cat <<-END +
  • $(get_name "$card")

      $(list_catsel "$card")
  • + END +} + +cat < +

    $(l10n categories_label)

    + +
      + $(cat_listing) +
    • + + +
    • +
    + + +
    +
    + +
    +
      + $(listcards |while read card; do display_catsel "$card"; done ) +
    +
    + +
    +
    + +EOF + diff --git a/templates/text_categories.sh b/templates/text_categories.sh new file mode 100755 index 0000000..00c61ce --- /dev/null +++ b/templates/text_categories.sh @@ -0,0 +1,22 @@ +# Copyright 2014, 2015 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 . + +item_name[cat_remove]="-" +item_name[cat_add]="+" +item_name[cat_newlabel]="neue Kategorie" +item_name[cat_update]="Zuweisungen übernehmen" +item_name[categories_label]="Kategorien" diff --git a/templates/text_frame.sh b/templates/text_frame.sh index 813410c..470ced4 100755 --- a/templates/text_frame.sh +++ b/templates/text_frame.sh @@ -18,6 +18,7 @@ item_name[p_courses]="Kurse" item_name[p_email]="Email" item_name[p_error]="Fehler" +item_name[p_categories]="Kategorien" case $PROFILE in medical)