From 8e3f9e69a0f01d1aa0871901ee06ffa90dadc8bc Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 20 Aug 2013 12:55:44 +0000 Subject: [PATCH] rudimentary vcard display svn path=/trunk/; revision=7 --- index.cgi | 10 ++++----- pages/attendees.sh | 11 ++++++++++ templates/attendees.css.sh | 0 templates/attendees.html.sh | 44 +++++++++++++++++++++++++++++++++++++ templates/frame.html.sh | 2 +- 5 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 templates/attendees.css.sh create mode 100644 templates/attendees.html.sh diff --git a/index.cgi b/index.cgi index ec358c8..f012782 100755 --- 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 diff --git a/pages/attendees.sh b/pages/attendees.sh index e4b8cd9..c1e0eb2 100755 --- a/pages/attendees.sh +++ b/pages/attendees.sh @@ -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 index 0000000..e69de29 diff --git a/templates/attendees.html.sh b/templates/attendees.html.sh new file mode 100644 index 0000000..87d46fb --- /dev/null +++ b/templates/attendees.html.sh @@ -0,0 +1,44 @@ +cat < +
+ +
+ + +
+

Neuer Eintrag

+
+ Name: + + +
+
+ +
+ $(listcards |while read card; do + echo '
' + vcf_parse "$card" |sed -r ' + s:^key=(.+)$: \1:g + s:^value=(.*)$:\1:g + s:^tag=(.*)$: \1:g + ' + echo '
' + done) +
+ +EOF + +# vi:set filetype=html: diff --git a/templates/frame.html.sh b/templates/frame.html.sh index bac2871..4ad59c3 100755 --- a/templates/frame.html.sh +++ b/templates/frame.html.sh @@ -17,7 +17,7 @@ cat <\2:g')
- $($PAGE body) + $(. $PAGE body)
-- 2.39.2