3 . "$_EXEC/cgilite/cgilite.sh"
4 . "$_EXEC/cgilite/users.sh"
12 path_info="$PATH_INFO"
14 while [ $# -gt 0 ]; do case $1 in
15 --from) from="$2"; shift 2;;
16 from=*) from="${1#*=}"; shift 1;;
17 --to) to="$2"; shift 2;;
18 to=*) to="${1#*=}"; shift 1;;
19 --items) items="$2"; shift 2;;
20 items=*) items="${1#*=}"; shift 1;;
21 --rev|--reverse) rev="-r"; shift 1;;
22 *) page="$1"; shift 1;;
25 if ! printf %s\\n "$from" |grep -qEx '[0-9]+|/([^/\\]|\\/|\\.)*/'; then
26 debug 'Include macro invalid argument: "from"'
29 if ! printf %s\\n "$to" |grep -qEx '[0-9]+|/([^/\\]|\\/|\\.)*/'; then
30 debug 'Include macro Invalid argument: "to"'
33 if ! printf %s\\n "$items" |grep -qEx '\$|[0-9]+'; then
34 debug 'Include macro Invalid argument: "items"'
43 /*) export PATH_INFO="$(PATH "$glob")";;
44 *) export PATH_INFO="$(PATH "$path_info/$glob")";;
47 if [ -f "$_DATA/pages/$PATH_INFO/#page.md" ]; then
48 mdfile="$_DATA/pages/$PATH_INFO/#page.md"
49 elif [ -f "$_EXEC/pages/$PATH_INFO/#page.md" ]; then
50 mdfile="$_EXEC/pages/$PATH_INFO/#page.md"
54 printf '<div class="macro include" page="%s">' "$(HTML "$glob")"
55 ( cd -- "${mdfile%/*}"
56 sed -n "${from},${to}p" <"$mdfile" \
60 s;(<[^>]+ )(href|src)="([^#/"][^"]*)"([^>]*>);\1\2="'"$(HTML "$glob")"'\3"\4;g