summaryrefslogtreecommitdiffstats
path: root/apps/media/templates/components.scm
diff options
context:
space:
mode:
Diffstat (limited to 'apps/media/templates/components.scm')
-rw-r--r--apps/media/templates/components.scm48
1 files changed, 48 insertions, 0 deletions
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 (<screenshot>)
+ 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