3 . "$_EXEC/cgilite/cgilite.sh"
7 from='1'; to='$'; rev=''; items='$'; link='true'
9 while [ $# -gt 0 ]; do case $1 in
10 --from) from="$2"; shift 2;;
11 from=*) from="${1#*=}"; shift 1;;
12 --to) to="$2"; shift 2;;
13 to=*) to="${1#*=}"; shift 1;;
14 --items) items="$2"; shift 2;;
15 items=*) items="${1#*=}"; shift 1;;
16 --rev|--reverse) rev="-r"; shift 1;;
17 --nolink) link=""; shift 1;;
18 *) page="$1"; shift 1;;
21 if ! printf %s\\n "$from" |grep -qEx '[0-9]+|/([^/\\]|\\/|\\.)*/'; then
22 debug 'Include macro invalid argument: "from"'
25 if ! printf %s\\n "$to" |grep -qEx '\$|[0-9]+|/([^/\\]|\\/|\\.)*/'; then
26 debug 'Include macro Invalid argument: "to"'
29 if ! printf %s\\n "$items" |grep -qEx '\$|[0-9]+'; then
30 debug 'Include macro Invalid argument: "items"'
38 page="$(page_abs "$glob")"
39 acl_read "$page" || continue
40 mdfile="$(mdfile "$page")" || continue
41 hglob="$(HTML "$glob")"
42 refpfx="$(printf %s\\n "$hglob" |sed 's;[\;&\;];\\&;g')"
44 && printf '<div class="macro include">
45 <a class="include link" href="%s">%s</a>
46 <article class="include" id="include_%s">' \
47 "${hglob}" "${hglob}" "${hglob}" \
48 || printf '<div class="macro include">
49 <article class="include" id="include_%s">' \
51 ( # PATH_INFO may be used by macros in the included page
52 export PATH_INFO="$page"
54 sed -n "${from},${to}p" <"$mdfile" \
58 s;(<[^>]+ )(href|src)="([^"]+://[^"]*|[mM][aA][iI][lL][tT][oO]:[^"]*)"([^>]*>);\1\2="/#safe/\3"\4;g
59 s;(<[^>]+ )(href|src)="([^#/"][^"]*)"([^>]*>);\1\2="'"${refpfx}"'\3"\4;g
60 s;(<[^>]+ )(href|src)="/#safe/([^"]*)"([^>]*>);\1\2="\3"\4;g
62 printf '</article></div>'