summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Wurmus <rekado@elephly.net>2020-05-15 13:02:58 +0200
committerRicardo Wurmus <rekado@elephly.net>2020-05-15 13:02:58 +0200
commit758d6d307fe6afcc4488360e7db03162103974f5 (patch)
tree339c2b4c540d1c64a8af6b07ad74611b7ca92bc1
parent99b5470f7fdec2cf923ad055e85bc1a65cd53aa7 (diff)
view/utils: Show attachment size.
-rw-r--r--mumi/web/view/utils.scm11
1 files changed, 10 insertions, 1 deletions
diff --git a/mumi/web/view/utils.scm b/mumi/web/view/utils.scm
index 27cd2de..3c95644 100644
--- a/mumi/web/view/utils.scm
+++ b/mumi/web/view/utils.scm
@@ -18,6 +18,7 @@
;;; <http://www.gnu.org/licenses/>.
(define-module (mumi web view utils)
+ #:use-module (ice-9 format)
#:use-module (ice-9 rdelim)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
@@ -250,7 +251,15 @@ BUG-NUM), even when it is a multipart message."
((or html? hide-attachment?)
`(div (@ (class "attachment"))
"Attachment: "
- (a (@ (href ,(attachment-url))) ,attachment-name)))
+ (a (@ (href ,(attachment-url))) ,attachment-name)
+ ,(or (and=> (assoc-ref headers 'content-disposition)
+ (lambda (disposition)
+ (and=> (assoc-ref disposition 'size)
+ (lambda (bytes)
+ (format #f " (~1,2f MiB)"
+ (exact->inexact
+ (/ bytes 1024 1024)))))))
+ "")))
((string-suffix? ".scm" attachment-name)
`(div (@ (class "multipart scheme"))
(div (@ (class "download-part"))