more niceties

This commit is contained in:
Ray Andrew 2025-12-04 15:00:31 -06:00
parent b710162ba8
commit d0b52d9c38
Signed by: rayandrew
SSH key fingerprint: SHA256:XYrYrxF0Z3A72n8P/p6mqPRNQZT22F88XcLsG+kX4xw

View file

@ -54,11 +54,32 @@ else
echo ".toggle { position: fixed; top: 20px; right: 20px; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; cursor: pointer; background: var(--header-bg); color: var(--text); font-size: 20px; transition: all 0.2s; box-shadow: 0 2px 8px var(--shadow); }" echo ".toggle { position: fixed; top: 20px; right: 20px; width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 50%; cursor: pointer; background: var(--header-bg); color: var(--text); font-size: 20px; transition: all 0.2s; box-shadow: 0 2px 8px var(--shadow); }"
echo ".toggle:hover { transform: scale(1.05); box-shadow: 0 4px 12px var(--shadow); }" echo ".toggle:hover { transform: scale(1.05); box-shadow: 0 4px 12px var(--shadow); }"
echo ".sun { display: none; } .dark .sun { display: inline; } .dark .moon { display: none; }" echo ".sun { display: none; } .dark .sun { display: inline; } .dark .moon { display: none; }"
echo ".attachments { margin-top: 25px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }"
echo ".attachments-header { padding: 12px 20px; background: var(--header-bg); cursor: pointer; font-weight: 500; color: var(--muted); }"
echo ".attachments-header:hover { background: var(--border); }"
echo ".attachments-content { display: none; padding: 15px; background: var(--bg); }"
echo ".attachments-content.show { display: flex; flex-wrap: wrap; gap: 15px; }"
echo ".attachment { background: var(--header-bg); border-radius: 8px; padding: 10px; text-align: center; min-width: 120px; border: 1px solid var(--border); }"
echo ".attachment img { max-width: 200px; max-height: 150px; object-fit: contain; margin: 0; }"
echo ".attachment-name { margin: 8px 0 0; font-size: 0.85em; color: var(--muted); word-break: break-all; }"
echo ".attachment-icon { font-size: 2em; display: block; margin-bottom: 5px; }"
echo ".attachment img { cursor: pointer; transition: transform 0.2s; }"
echo ".attachment img:hover { transform: scale(1.05); }"
echo ".lightbox { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 1000; justify-content: center; align-items: center; cursor: zoom-out; }"
echo ".lightbox.show { display: flex; }"
echo ".lightbox img { max-width: 95%; max-height: 95%; object-fit: contain; border-radius: 8px; box-shadow: 0 4px 30px rgba(0,0,0,0.5); }"
echo ".lightbox-close { position: fixed; top: 20px; right: 20px; color: white; font-size: 30px; cursor: pointer; background: rgba(0,0,0,0.5); width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }"
echo ".lightbox-close:hover { background: rgba(0,0,0,0.8); }"
echo "</style></head><body>" echo "</style></head><body>"
echo '<div class="lightbox" onclick="closeLightbox()"><span class="lightbox-close">&times;</span><img id="lightbox-img" src="" alt=""></div>'
echo '<button class="toggle" onclick="toggleTheme()" title="Toggle theme"><span class="moon">&#9790;</span><span class="sun">&#9728;</span></button>' echo '<button class="toggle" onclick="toggleTheme()" title="Toggle theme"><span class="moon">&#9790;</span><span class="sun">&#9728;</span></button>'
echo "<script>" echo "<script>"
echo "function toggleTheme() { document.documentElement.classList.toggle('dark'); }" echo "function toggleTheme() { document.documentElement.classList.toggle('dark'); }"
echo "function toggleQuote(el) { var c = el.nextElementSibling; c.classList.toggle('show'); el.textContent = c.classList.contains('show') ? '▼ Hide quoted text' : '▶ Show quoted text'; }" echo "function toggleQuote(el) { var c = el.nextElementSibling; c.classList.toggle('show'); el.textContent = c.classList.contains('show') ? '▼ Hide quoted text' : '▶ Show quoted text'; }"
echo "function toggleAttachments(el) { var c = el.nextElementSibling; c.classList.toggle('show'); var n = el.textContent.match(/\\d+/)[0]; el.textContent = c.classList.contains('show') ? '▼ Attachments (' + n + ')' : '▶ Attachments (' + n + ')'; }"
echo "function openLightbox(src) { document.getElementById('lightbox-img').src = src; document.querySelector('.lightbox').classList.add('show'); document.body.style.overflow = 'hidden'; }"
echo "function closeLightbox() { document.querySelector('.lightbox').classList.remove('show'); document.body.style.overflow = ''; }"
echo "document.addEventListener('keydown', function(e) { if (e.key === 'Escape') closeLightbox(); });"
echo "</script>" echo "</script>"
# Extract and display headers (handles multi-line headers) # Extract and display headers (handles multi-line headers)
@ -240,6 +261,20 @@ else
sub(/[.,;:!?)]+$/, "", url) sub(/[.,;:!?)]+$/, "", url)
result = before "<a href=\"" url "\" target=\"_blank\">" url "</a>" after result = before "<a href=\"" url "\" target=\"_blank\">" url "</a>" after
} }
# Sixth: Handle [cid:image] inline images
while (match(result, /\[cid:[^\]]+\]/)) {
before = substr(result, 1, RSTART-1)
# Extract image name from cid reference
cid = substr(result, RSTART+5, RLENGTH-6)
after = substr(result, RSTART+RLENGTH)
# Extract just the filename part (before @)
if (match(cid, /@/)) {
imgname = substr(cid, 1, RSTART-1)
} else {
imgname = cid
}
result = before "<img src=\"" imgname "\" alt=\"" imgname "\" style=\"max-width:100%;height:auto;\">" after
}
return result return result
} }
{ {
@ -267,10 +302,28 @@ else
' '
echo "</div>" echo "</div>"
# Show extracted images # Show attachments in collapsible section
find "$tmpdir" -maxdepth 1 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif" \) 2>/dev/null | while read -r img; do attachments=$(find "$tmpdir" -maxdepth 1 -type f \( -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif" -o -iname "*.pdf" -o -iname "*.doc*" -o -iname "*.xls*" -o -iname "*.zip" -o -iname "*.tar*" \) 2>/dev/null)
echo "<p><img src=\"$(basename "$img")\"></p>" if [[ -n $attachments ]]; then
count=$(echo "$attachments" | wc -l | tr -d ' ')
echo '<div class="attachments">'
echo "<div class=\"attachments-header\" onclick=\"toggleAttachments(this)\">▶ Attachments ($count)</div>"
echo '<div class="attachments-content">'
echo "$attachments" | while read -r file; do
basename=$(basename "$file")
ext="${basename##*.}"
ext_lower=$(echo "$ext" | tr '[:upper:]' '[:lower:]')
case "$ext_lower" in
png | jpg | jpeg | gif)
echo "<div class=\"attachment\"><img src=\"$basename\" alt=\"$basename\" onclick=\"openLightbox('$basename')\"><p class=\"attachment-name\">$basename</p></div>"
;;
*)
echo "<div class=\"attachment\"><span class=\"attachment-icon\">📎</span><p class=\"attachment-name\">$basename</p></div>"
;;
esac
done done
echo "</div></div>"
fi
echo "</body></html>" echo "</body></html>"
} >"$tmpfile" } >"$tmpfile"