X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=themes%2Fdefault.sh;h=6fa6ba16566245e9e7c0b92b883a155bf9ad4a19;hb=b222bd291672e71b29ed352c3cf058d8345f342d;hp=6370166017775241ed9691cfca7c23c78b7282d7;hpb=4fb35b146e7aca6faf5945105ab36a270b7f1ad5;p=shellwiki
diff --git a/themes/default.sh b/themes/default.sh
index 6370166..6fa6ba1 100755
--- a/themes/default.sh
+++ b/themes/default.sh
@@ -1,27 +1,119 @@
#!/bin/sh
-theme_404(){
- printf "%s\r\n" "Status: 404 Not Found"
+. "$_EXEC/tools.sh"
+
+theme_head(){
+ printf '
+
+
+
+ ' "$_BASE"
+}
+
+theme_header(){
+ printf '' "$(wiki '[wiki]/header/')"
+}
- theme_page '/[404]/'
+theme_footer(){
+ printf '' "$(wiki '[wiki]/footer/' ||echo No footer)"
}
theme_page(){
local page="$1" title
title="${page%/}"; title="${title##*/}"
+ # Important! Web Server response including newline
printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
cat <<-EOF
-
-
+ $(theme_head)
$(HTML "${title}")
-
- $(wiki "$page" || printf 'Page not found')
-
+ $(theme_header)
+
+
+
+ $(wiki "$page" || printf 'Page not found')
+
+
+ $(theme_footer)
+
+ EOF
+}
+
+theme_editor(){
+ local page="$1" title
+ title="${page%/}"; title="${title##*/}"
+
+ # Important! Web Server response including newline
+ printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
+
+ cat <<-EOF
+
+
+ $(theme_head)
+ $(HTML "${title}")
+
+ $(theme_header)
+
+ $(theme_footer)
+
+ EOF
+}
+
+theme_attachments(){
+ local page="$1" title
+ title="${page%/}"; title="${title##*/}"
+
+ # Important! Web Server response including newline
+ printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""
+
+ cat <<-EOF
+
+
+ $(theme_head)
+ Attachments $(HTML "${title}")
+
+ $(theme_header)
+
+
+ $(for file in "$_EXEC/pages/$page/#attachments"/* "$_DATA/pages/$page/#attachments"/*; do
+ [ "$file" = "$_EXEC/pages/$page/#attachments/${file##*/}" \
+ -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
+ stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
+ size="${stat% *}" date="${stat#* }"
+
+ printf '- %s
+ %s%s
' \
+ "$(HTML "${file##*/}")" "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"
+ done)
+
+
+ $(theme_footer)
EOF
}
+
+theme_login(){
+ theme_page '[wiki]/login/'
+}
+
+theme_register(){
+ theme_page '[wiki]/register/'
+}
+
+theme_404(){
+ printf "%s\r\n" "Status: 404 Not Found"
+
+ theme_page '[wiki]/404/'
+}