X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=attachment.sh;h=89b90ae2579a04dea091a01ac07de16f80454bb5;hb=f9cfcde441afed9d6db96e201935b6208903046d;hp=68e03b9b7ab9435961ca41abbaa93e2667aced7d;hpb=ad80bc2c5d655b67abea18b7b6c107896e7b3150;p=shellwiki diff --git a/attachment.sh b/attachment.sh index 68e03b9..89b90ae 100755 --- a/attachment.sh +++ b/attachment.sh @@ -17,7 +17,7 @@ attachment_convert(){ elif [ -f "$cachepath" ]; then printf %s "$attpath" return 0 - elif ! touch "$cachepath"; then + elif ! mkdir -p -- "${cachepath%/*}" && touch "$cachepath"; then printf %s "$attpath" return 0 fi @@ -60,7 +60,22 @@ attachment_convert(){ esac } -if [ "${PATH_INFO%/\[attachment\]/*}" != "${PATH_INFO}" ]; then +if [ "${PATH_INFO%/\[attachment\]/}" != "${PATH_INFO}" ]; then + . "$_EXEC/multipart.sh" + if multipart_cache; then + mkdir -p "$_DATA/pages/${PATH_INFO%/\[attachment\]/}/#attachments/" + n=1; while filename=$(multipart_filename "file" "$n"); do + filename="$(printf %s "$filename" |tr /\\0 __)" + multipart "file" "$n" >"$_DATA/pages/${PATH_INFO%/\[attachment\]/}/#attachments/$filename" + n=$((n + 1)) + done + rm -- "$multipart_cachefile" + REDIRECT "${_BASE}${PATH_INFO}" + else + theme_attachments "${PATH_INFO%\[attachment\]/}" + fi + +elif [ "${PATH_INFO%/\[attachment\]/*}" != "${PATH_INFO}" ]; then attpath="${PATH_INFO%/\[attachment\]/*}/#attachments/${PATH_INFO##*/}" if [ -f "$_DATA/pages/$attpath" ]; then FILE "$_DATA/pages/$attpath"