]> git.plutz.net Git - lobster/blob - therapies/index.cgi
functions for easyer tpy/mpx file parsing, deliver png overlays
[lobster] / therapies / index.cgi
1 #!/bin/sh
2
3 # Copyright 2016, 2020 Paul Hänsch
4 #
5 # This file is part of Lobster.
6
7 # Lobster is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11
12 # Lobster is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU Affero General Public License for more details.
16
17 # You should have received a copy of the GNU Affero General Public License
18 # along with Lobster.  If not, see <http://www.gnu.org/licenses/>. 
19
20 case "$_PATH" in
21   /therapies/therapy.css)
22     . $_EXEC/cgilite/file.sh
23     FILE $_EXEC/therapies/therapy.css
24     return 0
25     ;;
26   /therapies/*.*_session*.png)
27     if [ -r "$_DATA/$_PATH" ]; then
28       . $_EXEC/cgilite/file.sh
29       FILE "$_DATA/$_PATH"
30     fi
31     return 0
32     ;;
33 esac
34
35 . $_EXEC/pdiread.sh
36 . $_EXEC/therapies/l10n.sh
37 # . $_EXEC/cards/widgets.sh
38 # . $_EXEC/cards/list.sh
39
40 # unescape() { [ $# = 0 ] && sed -E 's;\\(.);\1;g' || printf %s "$*" |sed -E 's;\\(.);\1;g'; }
41 # upcase=' y;abcdefghijklmnopqrstuvwxyzäöüé;ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÜÉ;; '
42
43 BR='
44 '
45
46 id="${_PATH#/therapies/}"
47 id="${id%/*}.${id#*/}"
48
49 read junkx junky bg_dim junkz <<-E_READ
50         $(identify "$_EXEC/therapies/therapy_background.png")
51 E_READ
52
53 vcffile="${_DATA}/vcard/${id%.*}.vcf"
54 mpxfile="${_DATA}/prescriptions/${id}.mpx"
55 tpyfile="${_DATA}/therapies/${id}.tpy"
56
57 vcf="$(pdi_load "$vcffile")"
58 mpx="$(sed '1s;^;\n;; s/:/;:/' "$mpxfile")"
59 tpy="$(sed '1s;^;\n;; s/:/;:/' "$tpyfile")"
60
61 VCF(){ pdi_value "$vcf" "$@"; }
62 MPX(){ pdi_value "$mpx" "$@"; }
63 TPY(){ pdi_value "$tpy" "$@"; }
64
65 . $_EXEC/therapies/page.sh \
66 | yield_page therapy /therapies/therapy.css