3 # Copyright 2022 Paul Hänsch
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
12 # SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15 # IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . "$_EXEC/cgilite/cgilite.sh"
23 if [ "${page#/}" = "$page" ]; then
24 page="$(PATH "${PATH_INFO}/$page")"
27 acl_read "$page" || exit 0
29 printf %s\\n '<ul class="macro attachment list">'
31 for file in "$_EXEC/pages/$page/#attachments"/* "$_DATA/pages/$page/#attachments"/*; do
32 [ "$file" = "$_EXEC/pages/$page/#attachments/${file##*/}" \
33 -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
34 stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
35 size="${stat% *}" date="${stat#* }"
37 printf '<li><a class=name href="[attachment]/%s">%s</a>
38 <span class=size>%s</span><span class=date>%s</span></li>' \
39 "$(HTML "${file##*/}")" "$(HTML "${file##*/}")" \
40 "$(size_human "$size")" "$(date -d @"$date" +"%F %T")"