From 1b2b7c3eb939724696894f31ff27db97b0cac84c Mon Sep 17 00:00:00 2001 From: Andreas Widen Date: Sat, 25 Nov 2023 17:21:37 +0100 Subject: Initial commit. Signed-off-by: Andreas Widen --- apps/media/templates/components.scm | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 apps/media/templates/components.scm (limited to 'apps/media/templates/components.scm') diff --git a/apps/media/templates/components.scm b/apps/media/templates/components.scm new file mode 100644 index 0000000..880d69f --- /dev/null +++ b/apps/media/templates/components.scm @@ -0,0 +1,48 @@ +;;; 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)))) \ No newline at end of file -- cgit v1.2.3-54-g00ecf