]> git.plutz.net Git - shellwiki/blob - macros/newpage
bugfix: include translations
[shellwiki] / macros / newpage
1 #!/bin/sh
2
3 . "$_EXEC/cgilite/cgilite.sh"
4 . "$_EXEC/acl.sh"
5 . "$_EXEC/tools.sh"
6
7 _(){ printf %s\\n "$*"; }
8 [ "${LANGUAGE}" -a -r "${_EXEC}/l10n/${LANGUAGE}.sh" ] && . "${_EXEC}/l10n/${LANGUAGE}.sh"
9
10 pattern=./%%s
11 template=''
12 label='New Page'
13
14 while [ $# -gt 0 ]; do case $1 in
15   template=*) template="${1#*=}"; shift 1;;
16   --template) template="$2"; shift 2;;
17   label=*) label="${1#*=}"; shift 1;;
18   --label) label="$2"; shift 2;;
19   *) pattern="$1"; shift 1;;
20 esac; done
21
22 if acl_write "$(page_abs "$pattern")"; then
23   cat <<-EOF
24         <form class="macro newpage" method=POST action="[newpage]">
25           <input type=hidden name=pattern value="$(HTML "$pattern")">
26           <input type=hidden name=template value="$(HTML "$template")">
27           $([ ! "${pattern##*%%s*}" ] \
28             && printf '<input autocomplete=off name=page placeholder="%s">' "$(_ "page name")"
29           )<button type=submit name=action value=newpage>$(HTML "$label")</button>
30         </form>
31         EOF
32 fi