]> git.plutz.net Git - shellwiki/blob - macros/wikiform
be6e4be0dae26c19e0122f82f34417d279b86aa9
[shellwiki] / macros / wikiform
1 #!/bin/sh
2
3 # Copyright 2022 - 2023 Paul Hänsch
4
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
8
9 # THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15 # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
17 action="$1"
18
19 . "$_EXEC/cgilite/cgilite.sh"
20 . "$_EXEC/cgilite/users.sh"
21
22 _(){ printf %s\\n "$*"; }
23 [ "${LANGUAGE}" -a -r "${_EXEC}/l10n/${LANGUAGE}.sh" ] && . "${_EXEC}/l10n/${LANGUAGE}.sh"
24
25 case $action in
26   login)
27     w_user_login |"$_EXEC/cgilite/html-sh.sed"
28     ;;
29   register)
30     w_user_register |"$_EXEC/cgilite/html-sh.sed"
31     ;;
32   invite)
33     w_user_invite |"$_EXEC/cgilite/html-sh.sed"
34     ;;
35   settings)
36     w_user_update |"$_EXEC/cgilite/html-sh.sed"
37     ;;
38   search)
39     if [ "$LANGUAGE_DEFAULT" ]; then
40       printf '<form class="search" method="GET" action="./:%s/[search]">
41         <input class="search" placeholder="%s" name="q" value=""><button type="submit" class="search">%s</button>
42       </form>' "$LANGUAGE" "$(_ Search)" "$(_ Search)"
43     else
44       printf '<form class="search" method="GET" action="./[search]">
45         <input class="search" placeholder="%s" name="q" value=""><button type="submit" class="search">%s</button>
46       </form>' "$(_ Search)" "$(_ Search)"
47     fi
48     ;;
49 esac