. "${_EXEC}/cgilite/session.sh"
. "${_EXEC}/cgilite/file.sh"
. "${_EXEC}/cgilite/users.sh"
+. "${_EXEC}/tools.sh"
. "${_EXEC}/acl.sh"
-mdfile(){
- local page="$(PATH "$1")"
-
- if [ -f "$_DATA/pages/$page/#page.md" ]; then
- printf %s\\n "$_DATA/pages/$page/#page.md"
- elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
- printf %s\\n "$_EXEC/pages/$page/#page.md"
- else
- return 1
- fi
-}
-
wiki_text() {
# Print source text of a wiki page
# Get page from data or underlay dir
#!/bin/sh
+if [ "$(which awk)" ]; then
+ md() { awk -f "$_EXEC/md_macros.awk" -f "$_EXEC/cgilite/markdown.awk"; }
+elif [ "$(which busybox)" ]; then
+ md() { busybox awk -f "$_EXEC/md_macros.awk" -f "$_EXEC/cgilite/markdown.awk"; }
+else
+ md() { cat; }
+fi
+
+mdfile(){
+ local page="$(PATH "$1")"
+
+ if [ -f "$_DATA/pages/$page/#page.md" ]; then
+ printf %s\\n "$_DATA/pages/$page/#page.md"
+ elif [ -f "$_EXEC/pages/$page/#page.md" ]; then
+ printf %s\\n "$_EXEC/pages/$page/#page.md"
+ else
+ return 1
+ fi
+}
+
size_human(){
local size="$1"
}
page_glob(){
- local pattern="$1" IFS=''
+ local pattern="${1%/}/" IFS=''
local glob page pagedir
case $pattern in