]> git.plutz.net Git - shcgi/blobdiff - page.sh
allow dot in parameter keys
[shcgi] / page.sh
diff --git a/page.sh b/page.sh
index ef9df2e3def9271c49ec455cf3d251df17ed4e68..cb1b87ffd85b5438c2e46a439c92f947e721e165 100755 (executable)
--- a/page.sh
+++ b/page.sh
@@ -1,6 +1,6 @@
 #!/bin/zsh
 
-# Copyright 2014,2015 Paul Hänsch
+# Copyright 2014 - 2016 Paul Hänsch
 #
 # This file is part of shcgi.
 # 
 
 printf "Content-Type: text/html;charset=utf-8\n\n"
 
-PAGE="$(printf %s "${_GET[p]}" |egrep '^[a-zA-Z0-9_-]+$')"
-PAGE="${_EXEC}/pages/${PAGE}.sh"
-[ -x "$PAGE" ] || PAGE="${_EXEC}/pages/error.sh"
+PAGE=$(validate "${PAGE:-${_GET[page]}}" '[a-zA-Z0-9_-]+' error)
+[ -x "${_EXEC}/pages/${PAGE}.sh" ] || PAGE="error"
 
-NAVIGATION() {
-  for each in "${_EXEC}"/pages/*.sh; do
-    link="$(printf %s "$each" |sed -r "s:^.*/([^/]*)\.sh$:\1:")"
-    title="$($each title)"
-    [ -n "$title" ] && printf '%s\n' "?p=$link $title"
-  done
-}
+[ -z "$NAVIGATION" ] && NAVIGATION=($(printf %s\\n "${_EXEC}"/pages/*.sh |sed -r 's;^.*/([^/]*)\.sh$;\1;'))
 
-. ${_EXEC}/templates/frame.html.sh
+CSS="${CSS:-${_EXEC}/templates/${PAGE}.css.sh}"
+BODY="${BODY:-${_EXEC}/templates/${PAGE}.html.sh}"
+
+. "${_EXEC}/pages/${PAGE}.sh"
+. "${_EXEC}/templates/frame.html.sh"