]> git.plutz.net Git - shellwiki/blob - css.sh
acl scheme for [wiki] special pages
[shellwiki] / css.sh
1 #!/bin/sh
2
3 [ "$include_css" ] && return 0
4 include_css="$0"
5
6 css(){
7   local path="${1:-${PATH_INFO}}"
8   local pagefile css=''
9   # Get directory part of PATH_INFO
10   path="${path%/*}/./"
11
12   while :; do
13     [ "$path" = / ] && break
14     path="${path%/*/}/"
15
16     if   [ -f "$_DATA/pages/$path/#page.md" ]; then
17       pagefile="$_DATA/pages/$path/#page.md"
18     elif [ -f "$_EXEC/pages/$path/#page.md" ]; then
19       pagefile="$_EXEC/pages/$path/#page.md"
20     else
21       continue
22     fi
23
24     css="$(sed -En '
25       s;\r$;;;
26       /^%css([\t ]+.*)?$/bCSS;
27       20q;
28       b;
29
30       :CSS
31       s;(%(css)?)?[\t ]*;;
32       p; n; s;\r$;;;
33       /^(%[ \t]+|%css[ \t]+|[ \t]+)[^ \t\r]+$/bCSS;
34       /^(%[ \t]*|%css[ \t]*)$/bCSS;
35     ' <"$pagefile")${BR}${css}"
36   done
37
38   printf %s\\n "${css}"
39 }