X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=acl.sh;h=1b25d5ec78c93d7c33006aad9a0a329f7f9f3cb4;hb=d75f33f647280ada400fb51f740701cdb12dd4d3;hp=74fc8dc38419f9c556ff98e3882631ca709f6d8b;hpb=6dbb9931d2ee83bce8f859c3b8e126e2860a9105;p=shellwiki diff --git a/acl.sh b/acl.sh index 74fc8dc..1b25d5e 100755 --- a/acl.sh +++ b/acl.sh @@ -1,7 +1,10 @@ #!/bin/sh +[ "$include_acl" ] && return 0 +include_acl="$0" + # ACL_OVERRIDE="${ACL_OVERRIDE:-Admin:read,write}" -ACL_DEFAULT="${ACL_DEFAULT:-All:read${BR}Known:read,write}" +ACL_DEFAULT="${ACL_DEFAULT:-Known:read,write${BR}All:read}" acl_cachepath='' acl_collection='' @@ -26,6 +29,8 @@ acl_collect(){ [ "$path" = / ] && break path="${path%/*/}/" + # Do not use `mdfile` function here because of specialties + # in translation handler (`handlers/10_translations.sh`) if [ -f "$_DATA/pages/$path/#page.md" ]; then pagefile="$_DATA/pages/$path/#page.md" elif [ -f "$_EXEC/pages/$path/#page.md" ]; then @@ -34,16 +39,21 @@ acl_collect(){ continue fi - n=20; while read -r head acl; do - if [ "$head" = "%acl" ]; then - acl_collection="${acl%${CR}}${BR}" - printf "%s\n" "${acl%${CR}}" - n=$((n+1)) - fi + acl="$(sed -En ' + s;\r$;;; + /^%acl([\t ]+.*)?$/bACL; + 20q; + b; + + :ACL + s;(%(acl)?)?[\t ]*;; + p; n; s;\r$;;; + /^(%[ \t]+|%acl[ \t]+|[ \t]+)[^ \t\r]+$/bACL; + /^(%[ \t]*|%acl[ \t]*)$/bACL; + ' <"$pagefile")" - n="$((n - 1))" - [ "$n" -eq 0 ] && break - done <"$pagefile" + printf %s\\n "${acl}" + acl_collection="${acl_collection}${acl}${BR}" done printf '%s\n' "$ACL_DEFAULT"