X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=handlers%2F20_title.sh;h=35b5d3c52d194336c2b81239b924a751c52051cf;hb=756d5e8c0adddd6ed14833cdc246c08eba3a12ae;hp=a7c98a5de47ca93fe61ec243ab9f3a4193618b7f;hpb=116a9fbba5874eec7efb4f2253844e8158fffde9;p=shellwiki diff --git a/handlers/20_title.sh b/handlers/20_title.sh index a7c98a5..35b5d3c 100755 --- a/handlers/20_title.sh +++ b/handlers/20_title.sh @@ -1,43 +1,23 @@ #!/bin/sh -if acl_read ${PATH_INFO}; then - mdfile="$(mdfile "${PATH_INFO%/*}")" -else - PAGE_TITLE="${SITE_TITLE}" - return 1 -fi +# Copyright 2023, 2024 Paul Hänsch +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -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;^.*]*>(.*>)?([^<]+)(<.*)?.*$;\2;p; tQ; - s;^.*]*>(.*>)?([^<]+)(<.*)?.*$;\2;p; tQ; - b; :Q q; - ' - )" -else - PAGE_TITLE="${SITE_TITLE}" - return 1 +if acl_read "${PATH_INFO}"; then + PAGE_TITLE="$(page_title "${PATH_INFO%/*}")" 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}" +PAGE_TITLE="${PAGE_TITLE:-${SITE_TITLE:-${PATH_INFO}}}${PAGE_TITLE:+${SITE_TITLE:+ - ${SITE_TITLE}}}" return 1