]> git.plutz.net Git - confetti/commitdiff
rudimentary vcard display
authorpaul <paul@plutz.net>
Tue, 20 Aug 2013 12:55:44 +0000 (12:55 +0000)
committerpaul <paul@plutz.net>
Tue, 20 Aug 2013 12:55:44 +0000 (12:55 +0000)
svn path=/trunk/; revision=7

index.cgi
pages/attendees.sh
templates/attendees.css.sh [new file with mode: 0644]
templates/attendees.html.sh [new file with mode: 0644]
templates/frame.html.sh

index ec358c8cbd9aced5c135d1a597d0e597d4be88a1..f0127826c0eb8f7210d5b7a9d54a0f19e91ca632 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -13,7 +13,7 @@ debug() { #change to false to disable debugging
 # this program is supposed to be symlinked into a http root directory
 # we will use the http root as object storage (data directory) and call sub
 # programs from the directory in which the real executable resides
-# therefore we need to identify the code and data directories _EXEC and _STOR
+# therefore we need to identify the code and data directories _EXEC and _DATA
 call=$0
 real=$call
 while [ -L "$real" ]; do
@@ -21,15 +21,15 @@ while [ -L "$real" ]; do
 done
 
 _EXEC="$(dirname "$real")"  #execution directory
-_STOR="$(dirname "$call")"  #storage directory
+_DATA="$(dirname "$call")"  #storage directory
 
 debug "Execution dir: $_EXEC"
-debug "Storage dir: $_STOR"
+debug "Storage dir: $_DATA"
 
-[ -w "$_EXEC" ] && [ -d "$_EXEC" ] || die "storage directory must be writable"
+[ -w "$_DATA" ] && [ -d "$_DATA" ] || die "storage directory must be writable"
 
 # create directories for object storage
-for each in "$_STOR"/{vcard,mappings,courses}; do
+for each in "$_DATA"/{vcard,mappings,courses}; do
   [ ! -e "$each" ] && mkdir "$each"
   [ -w "$each" ] && [ -d "$each" ] || die "storage $each must be a writable directory"
 done
index e4b8cd9d2168758a1ddd73daab5f7fe6886811f8..c1e0eb25a80bd95e19e739d3149ade8a767b1acf 100755 (executable)
@@ -1,12 +1,23 @@
 #!/bin/sh
 
+listcards() {
+  ls -1 ${_DATA}/vcard/*vcf
+}
+
+vcf_parse() {
+  tr -d '\n' <"$1" |sed -r 's:\r ::g;s:\r:\n:g' \
+  | sed -r 's:^([^;]+)(;[^"]+|;"[^"]+")*\:(.*)$:key=\1\nvalue=\3\ntag=\2:g'
+}
+
 case "$1" in
   title)
     echo "Teilnehmende"
   ;;
   css)
+    . ${_EXEC}/templates/attendees.css.sh
   ;;
   body)
+    . ${_EXEC}/templates/attendees.html.sh
   ;;
 esac
   
diff --git a/templates/attendees.css.sh b/templates/attendees.css.sh
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/templates/attendees.html.sh b/templates/attendees.html.sh
new file mode 100644 (file)
index 0000000..87d46fb
--- /dev/null
@@ -0,0 +1,44 @@
+cat <<EOF
+<div class="filter">
+<form action="/" method="GET">
+  <div class="search">
+    <span class="label">Filter:</span>
+    <input type="hidden" name="page" value="attendees"/>
+    <input type="text" name="filter"/>
+    <input type="radio" name="filtertype" value="any" checked="checked">Alles</input>
+    <input type="radio" name="filtertype" value="name">Name</input>
+    <input type="radio" name="filtertype" value="street">Straße</input>
+    <input type="radio" name="filtertype" value="zip">PLZ.</input>
+    <input type="radio" name="filtertype" value="telephone">Telefon</input>
+    <input type="radio" name="filtertype" value="birth">Geburtsjahr</input>
+    <input type="radio" name="filtertype" value="course">Kurs</input>
+    <button type="submit" name="action" value="new_filter">Filtern</button>
+    <button type="submit" name="action" value="del_filter">Filter löschen</button>
+  </div>
+</form>
+</div>
+
+<div class="newcard">
+<h2>Neuer Eintrag</h2>
+<form action="actions/newcard.cgi" method="POST">
+  <span class="label">Name:</span>
+  <input type="text" name="name"/>
+  <button type="submit">Anlegen</button>
+</form>
+</div>
+
+<div class="cardlist">
+  $(listcards |while read card; do
+    echo '<div class="card">'
+    vcf_parse "$card" |sed -r '
+      s:^key=(.+)$:  <span class="label">\1</span>:g
+      s:^value=(.*)$:<span class="value">\1</span>:g
+      s:^tag=(.*)$:  <span class="tag"  >\1</span>:g
+    '
+    echo '</div>'
+  done)
+</div>
+
+EOF
+
+# vi:set filetype=html:
index bac287180270d0f05c00f5dc531c3794fd908676..4ad59c36c4d65a4c0e8cacb8fe33db3fbef73af7 100755 (executable)
@@ -17,7 +17,7 @@ cat <<EOF
       $(NAVIGATION |sed -r 's:^([^ ]+) (.+)$:<a href="\1">\2</a>:g')
     </div>
     <div class="MAIN">
-      $($PAGE body)
+      $($PAGE body)
     </div>
   </body>
 </html>