From: Paul Hänsch Date: Mon, 21 Mar 2022 13:59:12 +0000 (+0100) Subject: attachment processing, serving and overview X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=cb3cd16be2190c7e91aa1dafd22b295b641c0d32;p=shellwiki attachment processing, serving and overview --- diff --git a/attachment.sh b/attachment.sh index 68e03b9..b5e8491 100755 --- a/attachment.sh +++ b/attachment.sh @@ -60,7 +60,10 @@ attachment_convert(){ esac } -if [ "${PATH_INFO%/\[attachment\]/*}" != "${PATH_INFO}" ]; then +if [ "${PATH_INFO%/\[attachment\]/}" != "${PATH_INFO}" ]; then + theme_attachments "${PATH_INFO%\[attachment\]/}" + +elif [ "${PATH_INFO%/\[attachment\]/*}" != "${PATH_INFO}" ]; then attpath="${PATH_INFO%/\[attachment\]/*}/#attachments/${PATH_INFO##*/}" if [ -f "$_DATA/pages/$attpath" ]; then FILE "$_DATA/pages/$attpath" diff --git a/index.cgi b/index.cgi index ea78af1..9b38362 100755 --- a/index.cgi +++ b/index.cgi @@ -86,8 +86,6 @@ case "${PATH_INFO}" in if [ -f "$_DATA/pages/$PATH_INFO/#page.md" \ -o -f "$_EXEC/pages/$PATH_INFO/#page.md" ]; then theme_page "${PATH_INFO}" - else - theme_404 fi ;; */"[login]") diff --git a/themes/default.sh b/themes/default.sh index c096f82..6fa6ba1 100755 --- a/themes/default.sh +++ b/themes/default.sh @@ -1,9 +1,12 @@ #!/bin/sh +. "$_EXEC/tools.sh" + theme_head(){ printf ' + ' "$_BASE" } @@ -19,7 +22,7 @@ theme_page(){ local page="$1" title title="${page%/}"; title="${title##*/}" - # Important! Web Server response including newline newline + # Important! Web Server response including newline printf "%s\r\n" "Content-Type: text/html; charset=utf-8" "" cat <<-EOF @@ -29,7 +32,15 @@ theme_page(){ $(HTML "${title}") $(theme_header) -
$(wiki "$page" || printf 'Page not found')
+
+ +
+ $(wiki "$page" || printf 'Page not found') +
+
$(theme_footer) EOF @@ -60,6 +71,39 @@ theme_editor(){ EOF } +theme_attachments(){ + local page="$1" title + title="${page%/}"; title="${title##*/}" + + # Important! Web Server response including newline + printf "%s\r\n" "Content-Type: text/html; charset=utf-8" "" + + cat <<-EOF + + + $(theme_head) + Attachments $(HTML "${title}") + + $(theme_header) +
+ +
+ $(theme_footer) + + EOF +} + theme_login(){ theme_page '[wiki]/login/' }