--- /dev/null
+#!/bin/sh
+
+if acl_read ${PATH_INFO%/*}; then
+ mdfile="$(mdfile "${PATH_INFO%/*}")"
+else
+ PAGE_TITLE="${SITE_TITLE}"
+ return 1
+fi
+
+if [ "$mdfile" ]; then
+ PAGE_TITLE="$(
+ sed -nE '
+ s;^%title[ \t]+([[:graph:]][[:print:]]+)\r?$;\1;p; tQ;
+ b; :Q q;
+ ' "$mdfile"
+ )"
+ [ ! "${PAGE_TITLE}" ] && PAGE_TITLE="$(
+ MD_MACROS="" md <"$mdfile" \
+ | sed -nE '
+ s;^.*<h1[^>]*>(.*>)?([^<]+)(<.*)?</h1>.*$;\2;p; tQ;
+ s;^.*<h2[^>]*>(.*>)?([^<]+)(<.*)?</h2>.*$;\2;p; tQ;
+ b; :Q q;
+ '
+ )"
+else
+ PAGE_TITLE="${SITE_TITLE}"
+ return 1
+fi
+
+case $PATH_INFO in
+ *"/[attachment]")
+ PAGE_TITLE="${PAGE_TITLE} (Attachments)"
+ ;;
+ *"/[revision]")
+ PAGE_TITLE="${PAGE_TITLE} (Revisions)"
+ ;;
+esac
+
+[ "$PAGE_TITLE" ] \
+&& PAGE_TITLE="${PAGE_TITLE}${SITE_TITLE:+ - ${SITE_TITLE}}" \
+|| PAGE_TITLE="${SITE_TITLE}"
+
+return 1
theme_page(){
local page="$1" title="$2"
- title="$(HTML "${title:-"${page}"}")"
+ title="$(HTML "${title:-"${PAGE_TITLE:-"${page}"}"}")"
# Important! Web Server response including newline
printf "%s\r\n" "Content-Type: text/html; charset=utf-8" ""