X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=macros%2Finclude;h=f6b3a34ced7f4c22b700b9b4886e1070c8c2f421;hb=6ffedaf820cebb10be3eb89746f88e375c806858;hp=5eb613aa4659ec96128a0a6da670fc71a17719ac;hpb=1b8f9a660793917c33769e345500814f5b5cdd60;p=shellwiki diff --git a/macros/include b/macros/include index 5eb613a..f6b3a34 100755 --- a/macros/include +++ b/macros/include @@ -1,10 +1,24 @@ #!/bin/sh +# Copyright 2022 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. + . "$_EXEC/cgilite/cgilite.sh" . "$_EXEC/acl.sh" . "$_EXEC/tools.sh" -from='1'; to='$'; rev=''; items='$' +from='1'; to='$'; rev=''; items='$'; link='true' while [ $# -gt 0 ]; do case $1 in --from) from="$2"; shift 2;; @@ -14,6 +28,7 @@ while [ $# -gt 0 ]; do case $1 in --items) items="$2"; shift 2;; items=*) items="${1#*=}"; shift 1;; --rev|--reverse) rev="-r"; shift 1;; + --nolink) link=""; shift 1;; *) page="$1"; shift 1;; esac; done @@ -21,7 +36,7 @@ if ! printf %s\\n "$from" |grep -qEx '[0-9]+|/([^/\\]|\\/|\\.)*/'; then debug 'Include macro invalid argument: "from"' exit 1 fi -if ! printf %s\\n "$to" |grep -qEx '[0-9]+|/([^/\\]|\\/|\\.)*/'; then +if ! printf %s\\n "$to" |grep -qEx '\$|[0-9]+|/([^/\\]|\\/|\\.)*/'; then debug 'Include macro Invalid argument: "to"' exit 1 fi @@ -39,10 +54,14 @@ page_glob "$page" \ mdfile="$(mdfile "$page")" || continue hglob="$(HTML "$glob")" refpfx="$(printf %s\\n "$hglob" |sed 's;[\;&\;];\\&;g')" - printf '
- %s -
' \ - "${hglob}" "${hglob}" "${hglob}" + [ "$link" ] \ + && printf '
+ %s +
' \ + "${hglob}" "${hglob}" "${hglob}" \ + || printf '
+
' \ + "${hglob}" ( # PATH_INFO may be used by macros in the included page export PATH_INFO="$page" cd -- "${mdfile%/*}/"