]> git.plutz.net Git - lobster/blobdiff - cards/widgets.sh
Improved line breaking hack for addresses
[lobster] / cards / widgets.sh
index 5fbf125b746b06fdc7c58868a2f0ffc5470abef7..35086eb6abb4e7cd3d8c857840f9337502ed9214 100755 (executable)
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-list_categories() {
-  grep -vxE '^[        ]*$' "${_DATA}/mappings/categories"
-}
-
 w_filter_item() {
 n=$3
 cat <<EOF
@@ -32,15 +28,6 @@ cat <<EOF
               "$field" "$n" "$(l10n filter_$field)"
     done)
     [input type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
-    [fieldset .categories
-      $(list_categories | while read cat; do
-          printf '[label [checkbox "filter_cat%i" "|%s" %s] %s ]' \
-                 "$n" "$(HTML "$cat")" \
-                 "$(printf %s "$cat" |grep -qxEe "$2" && printf checked )" \
-                 "$(HTML "$cat")"
-      done)
-      [a href="/cards/categories.sh" $(l10n edit_categories)]
-    ]
   ]
 EOF
 }
@@ -72,21 +59,6 @@ w_filter_diag(){
 EOF
 }
 
-# listcards |grep ${edit:+-v} "$edit" \
-# | while read card; do
-#   "${_EXEC}"/cgilite/html-sh.sed <<-ENDCARD
-#      [div #${card} .card
-#        $(view_card "$card")[!--
-#        --][div .control
-#          [a "?action=edit_card&card=${card}" .item $(l10n edit)]
-#          [a "?action=export_vcard&card=${card}".item $(l10n vcf_export)]
-#          ${profile_medical:+[a "?action=new_prescription&client=${card}" .item $(l10n new_prescription)]}
-#      ]]
-#      ENDCARD
-# done
-
-#!/bin/sh
-
 card_item(){
   local card="$1"
   local item cnt c
@@ -96,12 +68,12 @@ card_item(){
     cnt="$(pdi_count "$card" "$item")"
 
     case $item in
-      FN) printf '[h2 .item .FN &shy;%s]' "$(pdi_value "$card" FN |unescape |HTML)"
+      FN) printf '[h2 .item .FN %s]' "$(pdi_value "$card" FN |unescape |HTML)"
         ;;
-      GENDER) printf '[span .item .GENDER &shy;%s]' "$(pdi_value "$card" GENDER |l10n)"
+      GENDER) printf '[span .item .GENDER %s]' "$(pdi_value "$card" GENDER |l10n)"
         ;;
       NICKNAME) seq 1 $cnt |while read c; do
-          printf '[span .item .NICKNAME &shy;aka. "%s"]' \
+          printf '[span .item .NICKNAME aka. "%s"]' \
                  "$(pdi_value "$card" NICKNAME $c |unescape |HTML)"
         done
         ;;
@@ -129,7 +101,7 @@ card_item(){
       EMAIL) 
         [ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n EMAIL)"
         seq 1 $cnt |while read c; do
-          printf '[a .item .EMAIL href="mailto:%s" &shy;%s]' \
+          printf '[a .item .EMAIL href="mailto:%s" %s]' \
                  "$(pdi_value "$card" EMAIL $c |unescape |HTML)" \
                  "$(pdi_value "$card" EMAIL $c |unescape |HTML)"
         done
@@ -139,17 +111,32 @@ card_item(){
         seq 1 $cnt |while read c; do
           teltype="$(pdi_attrib "$card" TEL $c TYPE)"
           [ "$teltype" ] \
-          && printf '[span .item .TEL [span .type &shy;%s:] %s]' \
+          && printf '[span .item .TEL [span .type %s:] %s]' \
                     "$(l10n "TYPE=$teltype" |HTML)" \
                     "$(pdi_value "$card" TEL $c |unescape |HTML)" \
-          || printf '[span .item .TEL &shy;%s]' \
+          || printf '[span .item .TEL %s]' \
                     "$(pdi_value "$card" TEL $c |unescape |HTML)"
         done
         ;;
+      X-HEALTH-INSURANCE)
+        [ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n X-HEALTH-INSURANCE)"
+        seq 1 $cnt |while read c; do
+          IFS=\; read -r hi_name hi_number hi_status <<-EOF
+               $(pdi_value "$card" X-HEALTH-INSURANCE $c)
+               EOF
+          printf '[span .item .hi_company . %s]
+                  [span .item .hi_number [label %s:] %s]
+                  [span .item .hi_status [label %s:] %s]
+                 ' "$(unescape "$hi_name" |HTML)" \
+                   "$(l10n hi_number)" "$(unescape "$hi_number" |HTML)" \
+                   "$(l10n hi_status)" "$(unescape "$hi_status" |HTML)"
+        done
+        ;;
       *)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")"
+        shy="$(printf '\302\255')"
         seq 1 $cnt |while read c; do
-          printf '[span .item .%s &shy;%s]' "$item" \
-                 "$(pdi_value "$card" "$item" $c |unescape |HTML)"
+          printf '[span .item .%s %s]' "$item" \
+                 "$(pdi_value "$card" "$item" $c |sed -r "s;(straße|weg|damm|allee|ufer);${shy}\1;g" |unescape |HTML)"
         done
         ;;
     esac