;;; Harmonic Flow web site (define-module (apps media templates components) #:use-module (apps aux lists) #:use-module (apps aux web) #:use-module (apps base templates components) #:use-module (apps base utils) #:use-module (apps i18n) #:use-module (apps media types) #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:export (screenshot->shtml screenshots-box)) ;;; ;;; Components. ;;; (define (screenshot->shtml shot) "Return an SHTML representation of the given screenshot object. SHOT () A screenshot object as defined in (apps media types)." `(div (@ (class "screenshot-preview")) (a (@ (href ,(hfweb-url (url-path-join "screenshots" (screenshot-slug shot) "")))) (img (@ (class "responsive-image") (src ,(screenshot-preview shot)) (alt ""))) (span (@ (class "screenshot-inset-shadow")) "")) (p ,(screenshot-caption shot) (span (@ (class "hidden")) ".")))) (define* (screenshots-box screenshots #:optional (n 6) #:key shadow) "Return SHTML for a box displaying up to N many SCREENSHOTS randomly chosen at build time. If SHADOW is true, a shadow is displayed at the top." `(div (@ (class ,(string-join `("screenshots-box" ,@(if shadow '("top-shadow-bg") '()))))) ,@(map screenshot->shtml (take-random screenshots n))))