]> git.plutz.net Git - confetti/commitdiff
refactoring card display
authorPaul Hänsch <paul@plutz.net>
Fri, 18 Jan 2019 12:49:53 +0000 (13:49 +0100)
committerPaul Hänsch <paul@plutz.net>
Fri, 18 Jan 2019 12:49:53 +0000 (13:49 +0100)
cards/cards.html.sh [deleted file]
cards/cards.sh
cards/filter_card.sh
cards/l10n.sh [new file with mode: 0755]
cards/main.cgi [new file with mode: 0755]
cards/text_cards.sh [deleted file]
cards/widgets.sh [new file with mode: 0755]
frame.html.sh
index.cgi
style.css [moved from common.css with 100% similarity]

diff --git a/cards/cards.html.sh b/cards/cards.html.sh
deleted file mode 100755 (executable)
index bf84eee..0000000
+++ /dev/null
@@ -1,130 +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 <http://www.gnu.org/licenses/>. 
-
-setchecked() {
-  printf 'checked="checked"'
-}
-check_type(){
-  [ "${_GET[filter]%%:*}" = "$1" ] && setchecked
-}
-check_order(){
-  [ "${_GET[order]}" = "$1" ] && setchecked
-}
-
-filter_item() {
-cat <<EOF
-  <fieldset class="item">
-    <legend>$(l10n filter_item):</legend>
-    <input type="hidden" name="filter${n}" value="^"/>
-
-    <input  id="any$n" type="radio" name="filter$((n + 1))" value="any:" $([ "$1" = any ] && setchecked)>
-    <label for="any$n" >$(l10n filter_all)</label>
-
-    <input  id="name$n" type="radio" name="filter$((n + 1))" value="name:" $([ "$1" = name ] && setchecked)>
-    <label for="name$n">$(l10n filter_name)</label>
-
-    <!--
-    <input  id="adr$n" type="radio" name="filter$((n + 1))" value="ADR:" $([ "$1" = ADR ] && setchecked)>
-    <label for="adr$n">$(l10n ADR)</label>
-    -->
-
-    <input  id="street$n" type="radio" name="filter$((n + 1))" value="street:" $([ "$1" = street ] && setchecked)>
-    <label for="street$n">$(l10n filter_street)</label>
-
-    <input  id="zip$n" type="radio" name="filter$((n + 1))" value="zip:" $([ "$1" = zip ] && setchecked)>
-    <label for="zip$n">$(l10n filter_zip)</label>
-
-    <input  id="telephone$n" type="radio" name="filter$((n + 1))" value="TEL:" $([ "$1" = TEL ] && setchecked)>
-    <label for="telephone$n">$(l10n filter_phone)</label>
-
-    <input  id="birth$n" type="radio" name="filter$((n + 1))" value="BDAY:" $([ "$1" = BDAY ] && setchecked)>
-    <label for="birth$n">$(l10n filter_birthyear)</label>
-
-    <input  id="cat$n" type="radio" name="filter$((n + 1))" value="CATEGORIES:" $([ "$1" = CATEGORIES ] && setchecked)>
-    <label for="cat$n">$(l10n CATEGORIES)</label>
-    <input type="text" name="filter$((n + 2))" value="$([ "$1" = CATEGORIES ] || attribsafe "$2")" placeholder="$(l10n filter_placeholder)"/>
-    <fieldset class="categories">
-      $(m=3
-        list_categories \
-        | while read cat; do
-          printf '<label><input type="checkbox" name="filter%i" value="|%s" %s/>%s</label>' \
-                 "$((n + m))" "$(attribsafe "$cat")" "$(printf %s "$cat" |grep -qEx "$2" && setchecked)" "$(htmlsafe "$cat")"
-          m=$((m + 1))
-        done
-      )
-      <a href="?p=categories">$(l10n edit_categories)</a>
-    </fieldset>
-
-    <!--
-    ${profile_circus:+
-    <input  id="course" type="radio" name="filtertype" value="course" $(check_type course)>
-    <label for="course">$(l10n filter_course)</label>
-    }
-    -->
-  </fieldset>
-EOF
-}
-
-cat <<EOF
-<form class="filter" action="?action=filter_card" method="POST">
-  <h1>$(l10n filter_label)</h1>
-  <input type="hidden" name="page" value="cards"/>
-
-  $(
-  n=0; m="$(list_categories |wc -l)"
-  printf '%s\n' "${_GET[filter]}" |tr '^' '\n' \
-  | while read filter; do
-    [ -n "$filter" ] && filter_item "${filter%%:*}" "${filter#*:}" "$n"
-    n=$((n + 3 + m))
-  done
-  filter_item any '' "$n"
-  )
-
-  <fieldset class="order">
-    <legend>$(l10n filter_order):</legend>
-    <label><input type="radio" name="order" value="firstname" $(check_order firstname)>$(l10n filter_firstname)</label>
-    <label><input type="radio" name="order" value="lastname"  $(check_order lastname) >$(l10n filter_lastname)</label>
-    <label><input type="radio" name="order" value="bdate"     $(check_order bdate)    >$(l10n filter_bdate)</label>
-  </fieldset>
-  <button type="submit" name="choice" value="new_filter">$(l10n filter_apply)</button>
-  <button type="submit" name="choice" value="del_filter">$(l10n filter_cancel)</button>
-</form>
-
-<form class="newcard" action="?action=new_card" method="POST">
-  <button type="submit">$(l10n newcard)</button>
-</form>
-
-${edit:+$(edit_card "$edit")}
-EOF
-
-listcards |grep ${edit:+-v} "$edit" \
-| while read card; do
-  cat <<-ENDCARD
-       <div id="${card}" class="card">
-         $(view_card "$card")<!--
-         --><div class="control">
-           <a class="item" href="?action=edit_card&card=${card}">$(l10n edit)</a>
-           <a class="item" href="?action=export_vcard&card=${card}">$(l10n vcf_export)</a>
-            ${profile_medical:+
-           <a class="item" href="?action=new_prescription&client=${card}">$(l10n new_prescription)</a>
-           }
-         </div>
-       </div>
-       ENDCARD
-done
-
-# vi:set filetype=html:
index a90981c6a16d02ec265bc80653aed9b29b90eca4..a26b1fcc318a15b2e80e351a7f2272786a68affb 100755 (executable)
@@ -103,142 +103,6 @@ listcards() {
   | sed -r 's;^(.*/)*;;;'
 }
 
-vcf_parse() {
-  unset key
-  sed -r ':X;N;$!bX; s;\r\n[ \t];;g; s;\r\n;\n;g;' "$1" \
-  | sed -rn '
-    # === turn property names to upper case, strip group names ===
-    h; s;^([^;:]+);;;
-    x; s;^([^;:\.]+\.)?([^;:]+).*$;\2;;
-    y;abcdefghijklmnopqrstuvwxyz;ABCDEFGHIJKLMNOPQRSTUVWXYZ;
-    G; s;\n;;;
-
-    # === strip trailing CR (but keep CRs in property value) ===
-    s;\r$;;;
-
-    # === Normalise various known vendor properties ===
-                s;^X-MS-CARDPICTURE(\;|:);PHOTO\1;;
-                        s;^X-GENDER(\;|:);GENDER\1;;
-                   s;^X-ANNIVERSARY(\;|:);ANNIVERSARY\1;;
-         s;^X-EVOLUTION-ANNIVERSARY(\;|:);ANNIVERSARY\1;;
-    s;^X-KADDRESSBOOK-X-ANNIVERSARY(\;|:);ANNIVERSARY\1;;
-            s;^X-EVOLUTION-BLOG-URL(\;|:);URL\1;;
-                              s;^AGENT(\;|:);RELATED\;VALUE=text\;TYPE=agent\1;;
-                        s;^X-ASSISTANT(\;|:);RELATED\;VALUE=text\;TYPE=assistant\1;;
-              s;^X-EVOLUTION-ASSISTANT(\;|:);RELATED\;VALUE=text\;TYPE=assistant\1;;
-    s;^X-KADDRESSBOOK-X-ASSISTANTSNAME(\;|:);RELATED\;VALUE=text\;TYPE=assistant\1;;
-                          s;^X-MANAGER(\;|:);RELATED\;VALUE=text\;TYPE=manager\1;;
-                s;^X-EVOLUTION-MANAGER(\;|:);RELATED\;VALUE=text\;TYPE=manager\1;;
-      s;^X-KADDRESSBOOK-X-MANAGERSNAME(\;|:);RELATED\;VALUE=text\;TYPE=manager\1;;
-                           s;^X-SPOUSE(\;|:);RELATED\;VALUE=text\;TYPE=spouse\1;;
-                 s;^X-EVOLUTION-SPOUSE(\;|:);RELATED\;VALUE=text\;TYPE=spouse\1;;
-        s;^X-KADDRESSBOOK-X-SPOUSENAME(\;|:);RELATED\;VALUE=text\;TYPE=spouse\1;;
-
-    # === Normalise obsolete vendor IM properties ===
-            s;^X-AIM((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):;IMPP\1:aim:;;
-            s;^X-ICQ((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):;IMPP\1:aim:;;
-    s;^X-GOOGLE-TALK((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):;IMPP\1:xmpp:;;
-         s;^X-JABBER((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):;IMPP\1:xmpp:;;
-            s;^X-MSN((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):;IMPP\1:msn:;;
-          s;^X-YAHOO((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):;IMPP\1:ymsgr:;;
-            s;^X-SIP((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):(sip:)?;IMPP\1:sip:;;
-
-    # === Update obsolete LABEL property ===
-    s;^LABEL((\;[A-z0-9-]+|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):(.*)$;ADR\1\;LABEL="\5":;;
-
-    /^([A-Z0-9-]+)((\;[A-z0-9-]+=?|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):(.*)$/{
-      h;
-      s;^([A-Z0-9-]+)((\;[A-z0-9-]+=?|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):(.*)$;key='\''\1'\'';;
-      H; g;
-
-      s;^([A-Z0-9-]+)((\;[A-z0-9-]+=?|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):([^\n]*)\n.*$;\2;;
-      s;'\'';'\'\\\\\'\'';g
-      s;\;([A-Z0-9-]+)(=|=(([^\;,:"]+|"[^"]+")(,[^\;,:"]+|,"[^"]+")*))?;\ntag[\1]='\''\3'\'';g
-      s;^\n+;;; s;\n+$;;;
-      /^.+$/H; g;
-
-      s;^([A-Z0-9-]+)((\;[A-z0-9-]+=?|\;[A-z0-9-]+=([^;,:"]+|"[^"]+")(,[^;,:"]+|,"[^"]+")*)*):([^\n]*)\n.*$;\6;;
-      # :X s;((^|[^\\])(\\\\)*)[;,];\1\n;g; s;((^|[^\\])(\\\\)*)\\([;,]);\4;g; tX;
-      s;'\'';'\'\\\\\'\'';g
-      s;^.*$;value='\''&'\'';
-      H; g;
-
-      s;^[^\n]*[\n ]+;;
-      s;\n+$;;;
-
-      p;
-    }
-    ' \
-  | while read -r line; do
-    declare -A tag
-    case "$line" in
-      value*) eval "$line";;
-      tag*)   eval "$line";;
-      key*)
-        if [ -z "$key" ]; then
-          eval "$line"
-        else
-          printf '%s\n' "$value" |sed -rn '
-            :X
-            s;((^|[^\\])(\\\\)*),;\1\n;g; 
-            tX;
-            s;\\,;,;g;
-            p
-          ' \
-          | while read -r val; do
-            while [ -n "${values[$key$n]+x}" ]; do n=$((${n=-1} + 1)); done
-            if printf '%s\n' "$val" |grep -qE '((^|[^\\])(\\\\)*)\;'; then
-              m=0
-              values[${key}${n}]="${val}"
-              printf '%s\n' "$val" |sed -rn '
-                :X
-                s;((^|[^\\])(\\\\)*)\;;\1\n;g; 
-                tX;
-                s;\\\;;\;;g;
-                p
-              ' \
-              | while read -r v; do
-                values[${key}${n}+${m}]="$(
-                  printf %s\\n "${v}" \
-                  | sed -rn '
-                    :X
-                    s;((^|[^\\])(\\\\)*)\\n;\1\n;g; 
-                    tX;
-                    s;\\\\;\\;g;
-                    p
-                  '
-                )"
-                m=$(($m + 1))
-              done
-            else
-              values[${key}${n}]="$(
-                printf %s\\n "${val}" \
-                | sed -rn '
-                  :X
-                  s;((^|[^\\])(\\\\)*)\\n;\1\n;g; 
-                  tX;
-                  s;\\\;;\;;g;
-                  s;\\\\;\\;g;
-                  p
-                '
-              )"
-            fi
-            for t in ${(k)tag}; do
-              values[${key}${n}_${t}]="${tag[$t]}"
-            done
-          done
-
-          eval "$line"
-          unset n
-          while [ -n "${values[$key$n]+x}" ]; do n=$((${n=-1} + 1)); done
-          unset value
-          unset tag
-        fi
-      ;;
-    esac
-  done
-}
-
 view_card() {  #Parameter: Cardfile
   id="$1"
   cardfile="$_DATA/vcard/${id}"
index cc0f9127e404fbbaf52ba752ad97d4545dc70ddc..d09adabc07cf5f23c8b9d5925cf296835f3cb09a 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/zsh
 
-# Copyright 2014, 2017 Paul Hänsch
+# Copyright 2014, 2017, 2019 Paul Hänsch
 #
 # This file is part of Confetti.
 # 
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-cgi_post
-
-if [ "${_POST[choice]}" = new_filter ]; then
+if [ "$(POST choice)" = new_filter ]; then
   filter="$(
-    for n in filter{0..100}; do
-      # [ -z "${_POST[$n]:+x}" ] && break
-      printf %s "${_POST[$n]}"
-    done \
-    | sed -r 's;\|+;\|;g; s;\^+;\^;g; s;:\|;:;g; :X; s;\^[^:]*:\^;\^;g; /\^[^:]*:\^/bX; s;^\^;;; s;\^[^:]*:$;;;'
+    seq 0 100 |while read n; do
+      printf %s "$(POST filter$n)"
+    done | sed -r \
+           's;\|+;\|;g;   s;\^+;\^;g;   s;:\|;:;g;
+            :X;   s;\^[^:]*:\^;\^;g;   /\^[^:]*:\^/bX;
+            s;^\^;;;   s;\^[^:]*:$;;;'
   )"
-  printf 'Location: ?p=cards&order=%s&filter=%s\n\n' "${_POST[order]}" "$filter"
+  REDIRECT "/cards/?order=$(POST order)&filter=${filter}"
 else
-  printf 'Location: ?p=cards\n\n'
+  REDIRECT '/cards/'
 fi
diff --git a/cards/l10n.sh b/cards/l10n.sh
new file mode 100755 (executable)
index 0000000..c916173
--- /dev/null
@@ -0,0 +1,139 @@
+# Copyright 2014, 2016, 2019 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 <http://www.gnu.org/licenses/>. 
+
+l10n(){
+  case $1 in
+    PHOTO) printf %s "Foto";;
+    LOGO) printf %s "Logo";;
+    FN) printf %s "Voller Name";;
+    N) printf %s "Name";;
+    n_pre) printf %s "Titel";;
+    n_first) printf %s "Vorname";;
+    n_middle) printf %s "Mittelnamen";;
+    n_last) printf %s "Nachname";;
+    n_post) printf %s "Zusätze";;
+    NICKNAME) printf %s "Spitzname";;
+    SOUND) printf %s "Aussprache";;
+    GENDER) printf %s "Geschlecht";;
+    KIND) printf %s "Typ";;
+    TITLE) printf %s "Beruf";;
+    ROLE) printf %s "Position";;
+    ORG) printf %s "Organisation";;
+    MEMBER) printf %s "Mitglied";;
+    CATEGORIES) printf %s "Kategorien";;
+    ANNIVERSARY) printf %s "Jubiläum";;
+    BDAY) printf %s "Geburtstag";;
+    EMAIL) printf %s "E-Mail";;
+    TEL) printf %s "Telefon";;
+    phone_typeselect) printf %s "Typ";;
+    phone_home) printf %s "Privat";;
+    phone_cell) printf %s "Mobil";;
+    phone_work) printf %s "Büro";;
+    phone_fax) printf %s "Fax";;
+    tHOME) printf %s "Privat:";;
+    tWORK) printf %s "Büro:";;
+    tCELL) printf %s "Mobil:";;
+    tFAX) printf %s "Fax:";;
+    tVOICE) printf %s "";;
+    IMPP) printf %s "Chat";;
+    ADR) printf %s "Anschrift";;
+    URL) printf %s "Webseite";;
+    LANG) printf %s "Sprache";;
+    NOTE) printf %s "Notiz";;
+  
+    RELATED) printf %s "Kontakte";;
+  
+    BEGIN) printf %s "";;
+    CALADRURI) printf %s "";;
+    CALURI) printf %s "";;
+    CLASS) printf %s "";;
+    CLIENTPIDMAP) printf %s "";;
+    END) printf %s "";;
+    FBURL) printf %s "";;
+    GEO) printf %s "";;
+    MAILER) printf %s "";;
+    NAME) printf %s "";;
+    PRODID) printf %s "";;
+    PROFILE) printf %s "";;
+    REV) printf %s "";;
+    SORT-STRING) printf %s "";;
+    SOURCE) printf %s "";;
+    TZ) printf %s "";;
+    UID) printf %s "";;
+    VERSION) printf %s "";;
+    XML) printf %s "";;
+  
+    X-HEALTH-INSURANCE) printf %s "Kran&shy;ken&shy;ver&shy;sich&shy;er&shy;ung";;
+    hi_from_list) printf %s "Aus Liste";;
+    hi_other) printf %s "Andere";;
+    hi_company) printf %s "Ver&shy;sich&shy;er&shy;ungs&shy;ge&shy;sell&shy;schaft";;
+    hi_number) printf %s "Ver&shy;sich&shy;er&shy;ten&shy;num&shy;mer";;
+    hi_status) printf %s "Ver&shy;sich&shy;er&shy;ten&shy;sta&shy;tus";;
+    X-HEALTH-INSURANCE-NOCONTRIB) printf %s "Zu&shy;zahl&shy;ungs&shy;be&shy;frei&shy;ung";;
+    X-CLIENT-REFERRAL) printf %s "Empfehl&shy;ung durch";;
+    prescriptions) printf %s "Verordnungen";;
+    new_prescription) printf %s "Neue Verordnung";;
+    no_icd) printf %s "Kein ICD Code";;
+  
+    X-ZACK-JOINDATE) printf %s "An&shy;mel&shy;de&shy;da&shy;tum";;
+    X-ZACK-LEAVEDATE) printf %s "Ab&shy;mel&shy;de&shy;da&shy;tum";;
+    label_join) printf %s "Anm.";;
+    label_leave) printf %s "Abm.";;
+  
+    edit) printf %s "Bearbeiten";;
+    edit_categories) printf %s "Kategorien Bearbeiten";;
+    vcf_export) printf %s "Vcard Exportieren";;
+    control) printf %s "Aktionen";;
+    edit_update) printf %s "Daten übernehmen";;
+    edit_cancel) printf %s "Abbrechen";;
+    edit_delete) printf %s "Eintrag löschen";;
+    edit_addfieldtext) printf %s "Neues Feld";;
+    edit_addfield) printf %s "+";;
+    edit_deletefield) printf %s "X";;
+    filter_label) printf %s "Filter";;
+    filter_placeholder) printf %s "Begriffe zur Eingrenzung eingeben";;
+    filter_type) printf %s "Filtertyp";;
+    filter_order) printf %s "Sortierung";;
+    filter_any) printf %s "Alles";;
+    filter_name) printf %s "Name";;
+    filter_firstname) printf %s "Vorname";;
+    filter_lastname) printf %s "Nachname";;
+    filter_street) printf %s "Straße";;
+    filter_zip) printf %s "PLZ.";;
+    filter_TEL) printf %s "Telefon";;
+    filter_BDAY) printf %s "Geburtsjahr";;
+    filter_bdate) printf %s "Geburtsdatum";;
+    filter_course) printf %s "Kurs";;
+    filter_CATEGORIES) printf %s "Kategorien";;
+    filter_apply) printf %s "Filtern";;
+    filter_cancel) printf %s "Filter löschen";;
+    newcard) printf %s "Neuen Eintrag anlegen";;
+    course_attendance) printf %s "Kursteilnahme";;
+  
+    gender_none) printf %s "keine Angabe";;
+    gender_female) printf %s "Weiblich";;
+    gender_male) printf %s "Männlich";;
+    gender_other) printf %s "Sonstiges";;
+  
+    female) printf %s "&#x2640;";;
+    male) printf %s "&#x2642;";;
+    other) printf %s "&#x26A5;";;
+    none) printf %s "&#x26AA;";;
+    *) printf %s "$1";;
+  esac
+}
+
diff --git a/cards/main.cgi b/cards/main.cgi
new file mode 100755 (executable)
index 0000000..6cdc8f2
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+if [ "$ITEM" = "cards/cards.css" ]; then
+  . $_EXEC/cgilite/file.sh
+  FILE $_EXEC/cards/cards.css
+  return 0
+elif [ "$(GET action)" = filter_card ]; then
+  . $_EXEC/cards/filter_card.sh
+  exit 0
+fi
+
+. $_EXEC/pdiread.sh
+. $_EXEC/cards/l10n.sh
+. $_EXEC/cards/widgets.sh
+
+filter="$(GET filter)"
+order="$(GET order)"
+
+printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
+
+$_EXEC/cgilite/html-sh.sed <<EOF
+[!DOCTYPE HTML]
+[html [head
+  [title Cards]
+  [link rel="stylesheet" type="text/css" href="/style.css"]
+  [link rel="stylesheet" type="text/css" href="/cards/cards.css"]
+][body
+  $(W_NAVIGATION)
+  $(w_filter_diag)
+
+  [form class="newcard" action="?action=new_card" method="POST"
+    [button type="submit" $(l10n newcard)]
+  ]
+
+]]
+EOF
diff --git a/cards/text_cards.sh b/cards/text_cards.sh
deleted file mode 100755 (executable)
index aaa6832..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-# Copyright 2014, 2016 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 <http://www.gnu.org/licenses/>. 
-
-item_name[PHOTO]="Foto"
-item_name[LOGO]="Logo"
-item_name[FN]="Voller Name"
-item_name[N]="Name"
-item_name[n_pre]="Titel"
-item_name[n_first]="Vorname"
-item_name[n_middle]="Mittelnamen"
-item_name[n_last]="Nachname"
-item_name[n_post]="Zusätze"
-item_name[NICKNAME]="Spitzname"
-item_name[SOUND]="Aussprache"
-item_name[GENDER]="Geschlecht"
-item_name[KIND]="Typ"
-item_name[TITLE]="Beruf"
-item_name[ROLE]="Position"
-item_name[ORG]="Organisation"
-item_name[MEMBER]="Mitglied"
-item_name[CATEGORIES]="Kategorien"
-item_name[ANNIVERSARY]="Jubiläum"
-item_name[BDAY]="Geburtstag"
-item_name[EMAIL]="E-Mail"
-item_name[TEL]="Telefon"
-item_name[phone_typeselect]="Typ"
-item_name[phone_home]="Privat"
-item_name[phone_cell]="Mobil"
-item_name[phone_work]="Büro"
-item_name[phone_fax]="Fax"
-item_name[tHOME]="Privat:"
-item_name[tWORK]="Büro:"
-item_name[tCELL]="Mobil:"
-item_name[tFAX]="Fax:"
-item_name[tVOICE]=""
-item_name[IMPP]="Chat"
-item_name[ADR]="Anschrift"
-item_name[URL]="Webseite"
-item_name[LANG]="Sprache"
-item_name[NOTE]="Notiz"
-
-item_name[RELATED]="Kontakte"
-
-item_name[BEGIN]=""
-item_name[CALADRURI]=""
-item_name[CALURI]=""
-item_name[CLASS]=""
-item_name[CLIENTPIDMAP]=""
-item_name[END]=""
-item_name[FBURL]=""
-item_name[GEO]=""
-item_name[MAILER]=""
-item_name[NAME]=""
-item_name[PRODID]=""
-item_name[PROFILE]=""
-item_name[REV]=""
-item_name[SORT-STRING]=""
-item_name[SOURCE]=""
-item_name[TZ]=""
-item_name[UID]=""
-item_name[VERSION]=""
-item_name[XML]=""
-
-item_name[X-HEALTH-INSURANCE]="Kran&shy;ken&shy;ver&shy;sich&shy;er&shy;ung"
-item_name[hi_from_list]="Aus Liste"
-item_name[hi_other]="Andere"
-item_name[hi_company]="Ver&shy;sich&shy;er&shy;ungs&shy;ge&shy;sell&shy;schaft"
-item_name[hi_number]="Ver&shy;sich&shy;er&shy;ten&shy;num&shy;mer"
-item_name[hi_status]="Ver&shy;sich&shy;er&shy;ten&shy;sta&shy;tus"
-item_name[X-HEALTH-INSURANCE-NOCONTRIB]="Zu&shy;zahl&shy;ungs&shy;be&shy;frei&shy;ung"
-item_name[X-CLIENT-REFERRAL]="Empfehl&shy;ung durch"
-item_name[prescriptions]="Verordnungen"
-item_name[new_prescription]="Neue Verordnung"
-item_name[no_icd]="Kein ICD Code"
-
-item_name[X-ZACK-JOINDATE]="An&shy;mel&shy;de&shy;da&shy;tum"
-item_name[X-ZACK-LEAVEDATE]="Ab&shy;mel&shy;de&shy;da&shy;tum"
-item_name[label_join]="Anm."
-item_name[label_leave]="Abm."
-
-item_name[edit]="Bearbeiten"
-item_name[edit_categories]="Kategorien Bearbeiten"
-item_name[vcf_export]="Vcard Exportieren"
-item_name[control]="Aktionen"
-item_name[edit_update]="Daten übernehmen"
-item_name[edit_cancel]="Abbrechen"
-item_name[edit_delete]="Eintrag löschen"
-item_name[edit_addfieldtext]="Neues Feld"
-item_name[edit_addfield]="+"
-item_name[edit_deletefield]="X"
-item_name[filter_label]="Filter"
-item_name[filter_placeholder]="Begriffe zur Eingrenzung eingeben"
-item_name[filter_type]="Filtertyp"
-item_name[filter_order]="Sortierung"
-item_name[filter_all]="Alles"
-item_name[filter_name]="Name"
-item_name[filter_firstname]="Vorname"
-item_name[filter_lastname]="Nachname"
-item_name[filter_street]="Straße"
-item_name[filter_zip]="PLZ."
-item_name[filter_phone]="Telefon"
-item_name[filter_birthyear]="Geburtsjahr"
-item_name[filter_bdate]="Geburtsdatum"
-item_name[filter_course]="Kurs"
-item_name[filter_apply]="Filtern"
-item_name[filter_cancel]="Filter löschen"
-item_name[newcard]="Neuen Eintrag anlegen"
-item_name[course_attendance]="Kursteilnahme"
-
-item_name[gender_none]="keine Angabe"
-item_name[gender_female]="Weiblich"
-item_name[gender_male]="Männlich"
-item_name[gender_other]="Sonstiges"
-
-item_name[female]="&#x2640;"
-item_name[male]="&#x2642;"
-item_name[other]="&#x26A5;"
-item_name[none]="&#x26AA;"
-
diff --git a/cards/widgets.sh b/cards/widgets.sh
new file mode 100755 (executable)
index 0000000..5a80ae7
--- /dev/null
@@ -0,0 +1,85 @@
+# Copyright 2014 - 2019 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 <http://www.gnu.org/licenses/>. 
+
+w_filter_item() {
+cat <<EOF
+  [fieldset .item
+    [legend $(l10n filter_item):]
+    [input type="hidden" name="filter${n}" value="^"]
+
+    $(for field in any name street zip TEL BDAY CATEGORIES; do
+      printf '[input id="%s%i" type="radio" name="filter%i" value="%s" %s]
+              [label for="%s%i" %s]' \
+              "$field" "$n" "$((n + 1))" "$field" "$([ "$1" = "$field" ] && printf checked )" \
+              "$field" "$n" "$(l10n filter_$field)"
+    done)
+    [input type="text" name="filter$((n + 2))" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
+    [fieldset .categories
+      $(m=3; list_categories | while read cat; do
+          printf '[label [checkbox "filter%i" "|%s" %s] %s ]' \
+                 "$((n + m))" "$(HTML "$cat")" \
+                 "$(printf %s "$cat" |grep -qEx "$2" && printf checked )" \
+                 "$(HTML "$cat")"
+          m=$((m + 1))
+      done)
+      [a href="?p=categories" $(l10n edit_categories)]
+    ]
+  ]
+EOF
+}
+
+w_filter_diag(){
+  cat <<EOF
+  [form .filter action="?action=filter_card" method="POST"
+    [h1 $(l10n filter_label)]
+    [input type="hidden" name="page" value="cards"]
+  
+    $(
+    n=0; m="$(list_categories |wc -l)"
+    printf '%s\n' "$filter" |tr '^' '\n' \
+    | while read filter; do
+      [ -n "$filter" ] && w_filter_item "${filter%%:*}" "${filter#*:}" "$n"
+      n=$((n + 3 + m))
+    done
+    w_filter_item any '' "$n"
+    )
+  
+    [fieldset class="order"
+      [legend $(l10n filter_order):]
+      [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
+      [label [radio "order" "lastname"  $( [ "$order" = lastname  ] && printf checked )] $(l10n filter_lastname)]
+      [label [radio "order" "bdate"     $( [ "$order" = bdate     ] && printf checked )] $(l10n filter_bdate)]
+    ]
+    [button type="submit" name="choice" value="new_filter" $(l10n filter_apply)]
+    [button type="submit" name="choice" value="del_filter" $(l10n filter_cancel)]
+  ]
+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
+
index b8128a34d6d112fb52474e5ce6041c6ec7e8635a..6ba48b5dd5f424cb452f5bbdb6b8e825edb4f568 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/>. 
 
-. "${_EXEC}/templates/text_frame.sh"
-[ -x "${_EXEC}/templates/text_${PAGE}.sh" ] && . "${_EXEC}/templates/text_${PAGE}.sh"
-
-bmfile="${_DATA}/mappings/bookmarks"
-
-cat <<EOF
-<!Doctype HTML>
-
-<html>
-  <head>
-    <title>$(l10n p_${PAGE})</title>
-    <meta name="viewport" content="width=device-width">
-    <link rel="stylesheet" href="?static=common.css">
-    <link rel="stylesheet" href="?static=${PAGE}.css">
-  </head>
-  <body class="$PAGE" id="CONFIGURE">
-    <div class="NAVIGATION">
-      $(sed -rn '/^[^ ]+\t[^ ]+$/p' "$bmfile" \
-        | while read page name; do
-        printf '<a href="%s">%s</a>' "${page}" "${name}"
-      done)
-      <label for="navigationconfig">$(l10n nc_edit)</label>
-      <input  id="navigationconfig" class="config" type="checkbox" />
-      <form class="config" method="POST" action="?action=update_bookmarks">
-        $(for page in "${_EXEC}/pages/"*.sh; do
-          page="${page##*/}"
-          page="${page%.sh}"
-          printf '<a href="?p=%s">%s</a>\n' "${page}" "$(l10n "p_${page}")"
-        done |grep -E '^<a href="\?p='"${page_filter}" )
-        $(if grep -qF "$REQUEST_URI" "$bmfile"; then
-          printf '<input type="hidden" name="bm_url" value="%s" />
-                  <input type="text" name="bm_name" value="%s" readonly="readonly" /
-                  ><button type="submit" name="submit" value="del">%s</button>' \
-                  "$(attribsafe ${REQUEST_URI})" \
-                  "$(attribsafe $(grep -m1 -F "$REQUEST_URI    " "$bmfile" |sed -r 's;.*\t;;'))" \
-                  "$(l10n bm_del)"
-        else
-          printf '<input type="hidden" name="bm_url" value="%s" />
-                  <input type="text" name="bm_name" placeholder="%s" /
-                  ><button type="submit" name="submit" value="add">%s</button>' \
-                  "$(attribsafe ${REQUEST_URI})" "$(l10n Bookmark)" "$(l10n bm_add)"
-        fi)
-      </form>
-    </div>
-EOF
-
-debug BODY; [ -x "${BODY}" ] && . "${BODY}" || printf %s 'Error'
-
 cat <<EOF
-  <div id="footer">
-    <a href="#CONFIGURE">$(l10n configure)</a>
-  </div>
-</body></html>'
+[!DOCTYPE HTML]
+
+[html [head [title $(l10n p_${PAGE}) ]
+  [meta name="viewport" content="width=device-width"]
+  [link rel="stylesheet" href="/common.css"]
+  [link rel="stylesheet" href="?static=${PAGE}.css"]
+] [body class="$PAGE" id="CONFIGURE"
+  [div class="NAVIGATION"
+    [a "/cards/" Cards]
+  ]
+]]'
 EOF
-
-# vi:set filetype=html:
index e0bf125ec5c1ad6f4d7501d76cb5c3aaa09ae0f2..cf70a45297a8c8c1afaeb4967ddb25a8d86dcc30 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -14,18 +14,18 @@ esac; done
 FILTER="$(GET filter)"
 ORDER="$(GET o |grep -m1 -axE 'firstname|lastname|bdate' || printf firstname)"
 # LISTSIZE="$(COOKIE pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
-ITEM="$(PATH "${PATH_INFO#/}")"
+ITEM="$(PATH "${PATH_INFO#/}")"; ITEM="${ITEM#/}"
 ACTION="$(GET a)"
 
-if [ -d "${_EXEC}/${ITEM%%/*}/main.cgi" ]
+if [ -d "${_EXEC}/${ITEM%%/*}" -a -x "${_EXEC}/${ITEM%%/*}/main.cgi" ]; then
   . "${_EXEC}/${ITEM%%/*}/main.cgi"
-elif [ "$ITEM" = "/style.css" ]; then
+elif [ "$ITEM" = "style.css" ]; then
   . "$_EXEC/cgilite/file.sh"
   [ -r "$_DATA/$ITEM" ] && FILE "$_DATA/$ITEM" \
                         || FILE "$_EXEC/style.css"
-elif [ -d "${_EXEC}/${ITEM%%/*}" -a ! -x "${_EXEC}/$ITEM" ]
-  . "$_EXEC/cgilite/file.sh"
-  FILE "${_EXEC}/$ITEM"
+# elif [ -d "${_EXEC}/${ITEM%%/*}" -a ! -x "${_EXEC}/$ITEM" ]; then
+  . "$_EXEC/cgilite/file.sh"
+  FILE "${_EXEC}/$ITEM"
 else
   printf 'Status: 404 Not Found\r\nContent-Length: 0\r\n\r\n'
 fi
similarity index 100%
rename from common.css
rename to style.css