]> git.plutz.net Git - shellwiki/commitdiff
theme template and default theme
authorPaul Hänsch <paul@plutz.net>
Thu, 24 Feb 2022 02:42:37 +0000 (03:42 +0100)
committerPaul Hänsch <paul@plutz.net>
Thu, 24 Feb 2022 02:42:37 +0000 (03:42 +0100)
themes/default.sh [new file with mode: 0755]

diff --git a/themes/default.sh b/themes/default.sh
new file mode 100755 (executable)
index 0000000..6370166
--- /dev/null
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+theme_404(){
+  printf "%s\r\n" "Status: 404 Not Found"
+
+  theme_page '/[404]/'
+}
+
+theme_page(){
+  local page="$1" title
+  title="${page%/}"; title="${title##*/}"
+
+  printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
+
+  cat <<-EOF
+       <!DOCTYPE HTML>
+       <html><head>
+         <meta name="viewport" content="width=device-width"/>
+         <link rel="stylesheet" type="text/css" href="$_BASE/[wiki]/cgilite/common.css">
+         <title>$(HTML "${title}")</title>
+       </head><body id="$(HTML "$page")">
+         <header></header>
+         <main>$(wiki "$page" || printf 'Page not found')</main>
+         <footer></footer>
+       </body></html>
+       EOF
+}