--- /dev/null
+#!/bin/sh
+
+. "$_EXEC/cgilite/cgilite.sh"
+
+page="$1"
+
+if [ "${page#/}" = "$page" ]; then
+ page="$(PATH "${PATH_INFO}/$page")"
+fi
+
+printf %s\\n '<ul class="attachment list">'
+
+for file in "$_EXEC/pages/$page/#attachments"/* "$_DATA/pages/$page/#attachments"/*; do
+ [ "$file" = "$_EXEC/pages/$page/#attachments/${file##*/}" \
+ -a -f "$_DATA/pages/$page/#attachments/${file##*/}" ] && continue
+ stat="$(stat -c '%s %Y' -- "$file" 2>&-)" || continue
+ size="${stat% *}" date="${stat#* }"
+
+ if [ $size -gt $((1024 * 1024 * 1024)) ]; then
+ size=$((size / 1024 / 1024 / 1024 * 10 + size / 1024 / 1024 % 1024 / 100))
+ size="$((size / 10)).$((size % 10)) GB"
+
+ elif [ $size -gt $((1024 * 1024)) ]; then
+ size=$((size / 1024 / 1024 * 10 + size / 1024 % 1024 / 100))
+ size="$((size / 10)).$((size % 10)) MB"
+
+ elif [ $size -gt $((1024)) ]; then
+ size=$((size / 1024 * 10 + size % 1024 / 100))
+ size="$((size / 10)).$((size % 10)) KB"
+
+ else
+ size="${size} B"
+ fi
+
+ printf '<li><span class=name>%s</span>
+ <span class=size>%s</span><span class=date>%s</span></li>' \
+ "$(HTML "${file##*/}")" "$size" "$(date -d @"$date" +"%F %T")"
+done
+
+printf %s\\n '</ul>'