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/builder.scm | 69 +++++++++++++++++++++++++++ apps/media/data.scm | 59 +++++++++++++++++++++++ apps/media/templates/components.scm | 48 +++++++++++++++++++ apps/media/templates/screenshot.scm | 43 +++++++++++++++++ apps/media/templates/screenshots-overview.scm | 28 +++++++++++ apps/media/types.scm | 60 +++++++++++++++++++++++ 6 files changed, 307 insertions(+) create mode 100644 apps/media/builder.scm create mode 100644 apps/media/data.scm create mode 100644 apps/media/templates/components.scm create mode 100644 apps/media/templates/screenshot.scm create mode 100644 apps/media/templates/screenshots-overview.scm create mode 100644 apps/media/types.scm (limited to 'apps/media') diff --git a/apps/media/builder.scm b/apps/media/builder.scm new file mode 100644 index 0000000..a1a74a1 --- /dev/null +++ b/apps/media/builder.scm @@ -0,0 +1,69 @@ +;;; Harmonic Flow web site + +(define-module (apps media builder) + #:use-module (apps aux system) + #:use-module (apps base utils) + #:use-module (apps media data) + #:use-module (apps media templates screenshot) + #:use-module (apps media templates screenshots-overview) + #:use-module (apps media types) + #:use-module (haunt artifact) + #:use-module (haunt html) + #:use-module (haunt utils) + #:use-module (apps aux web) + #:use-module (srfi srfi-19) + #:export (builder)) + + +;;; +;;; Application builder. +;;; + +(define (builder site posts) + "Return the list of web resources that compose the app. + + This procedure is a Haunt builder procedure. + + SITE () + A site object that defines all the properties of the website. See + Haunt objects for more information. + + POSTS (list of ) + A list of post objects that represent articles from the blog. See + Haunt objects for more information. + + RETURN (list of and ) + A list of objects that represent the web resources of the + application. See Haunt and objects for more + information." + (flatten + (list (screenshots-overview-builder) + (screenshots-builder) + ))) + + +;;; +;;; Helper builders. +;;; + + +(define (screenshots-builder) + "Return a list of Haunt pages representing screenshot pages." + (map + (lambda (shot) + (let ((context + (list (cons "screenshot" shot) + (cons "screenshots" screenshots)))) + (serialized-artifact (path-join "screenshots" + (screenshot-slug shot) + "index.html") + (screenshot-t context) + sxml->html))) + screenshots)) + + +(define (screenshots-overview-builder) + "Return a Haunt page representing the screenshots overview page." + (serialized-artifact "screenshots/index.html" + (screenshots-overview-t screenshots) + sxml->html)) \ No newline at end of file diff --git a/apps/media/data.scm b/apps/media/data.scm new file mode 100644 index 0000000..9f54a43 --- /dev/null +++ b/apps/media/data.scm @@ -0,0 +1,59 @@ +;;; Harmonic Flow web site + +(define-module (apps media data) + #:use-module (apps base utils) + #:use-module (apps i18n) + #:use-module (apps media types) + #:use-module (srfi srfi-19) + #:export (screenshots)) + + +;;; +;;; Data. +;;; + + +(define screenshots + (list + (screenshot + #:title (C_ "screenshot title" "HFGE example: Basic 2D") + #:slug "hfge-screenshot-basic2d" + #:image (hfweb-url "static/media/img/hfge_screenshot_big_1.png") + #:preview (hfweb-url "static/media/img/hfge_screenshot_min_1.png") + #:caption (G_ "HFGE example: Basic 2D")) + + (screenshot + #:title (C_ "screenshot title" "HFGE example: Basic 3D (minimal convex hull in green)") + #:slug "hfge-screenshot-basic3d" + #:image (hfweb-url "static/media/img/hfge_screenshot_big_2.png") + #:preview (hfweb-url "static/media/img/hfge_screenshot_min_2.png") + #:caption (G_ "HFGE example: Basic 3D (minimal convex hull in green)")) + + (screenshot + #:title (C_ "screenshot title" "HFGE example: glTF skinning") + #:slug "hfweb-screenshot-gltf-skinning" + #:image (hfweb-url "static/media/img/hfge_screenshot_big_3.png") + #:preview (hfweb-url "static/media/img/hfge_screenshot_min_3.png") + #:caption (G_ "HFGE example: glTF skinning")) + + (screenshot + #:title (C_ "screenshot title" "HFGE example: Deferred rendering") + #:slug "hfge-screenshot-deferred-rendering" + #:image (hfweb-url "static/media/img/hfge_screenshot_big_4.png") + #:preview (hfweb-url "static/media/img/hfge_screenshot_min_4.png") + #:caption (G_ "HFGE example: Deferred rendering")) + + (screenshot + #:title (C_ "screenshot title" "HFGE example: Collision 3D") + #:slug "hfge-screenshot-collision3d" + #:image (hfweb-url "static/media/img/hfge_screenshot_big_5.png") + #:preview (hfweb-url "static/media/img/hfge_screenshot_min_5.png") + #:caption (G_ "HFGE example: Collision 3D")) + + (screenshot + #:title (C_ "screenshot title" "HFGE example: Collision 2D") + #:slug "hfge-screenshot-collision2d" + #:image (hfweb-url "static/media/img/hfge_screenshot_big_6.png") + #:preview (hfweb-url "static/media/img/hfge_screenshot_min_6.png") + #:caption (G_ "HFGE example: Collision 2D")) + )) \ No newline at end of file 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 diff --git a/apps/media/templates/screenshot.scm b/apps/media/templates/screenshot.scm new file mode 100644 index 0000000..5a32016 --- /dev/null +++ b/apps/media/templates/screenshot.scm @@ -0,0 +1,43 @@ +;;; Harmonic Flow web site + +(define-module (apps media templates screenshot) + #:use-module (apps base templates theme) + #:use-module (apps base types) + #:use-module (apps base utils) + #:use-module (apps media templates components) + #:use-module (apps media types) + #:use-module (apps i18n) + #:export (screenshot-t)) + + +(define (screenshot-t context) + "Return an SHTML page for the screenshot in the CONTEXT." + (let ((shot (context-datum context "screenshot")) + (shots (context-datum context "screenshots"))) + (theme + #:title (list (screenshot-title shot) (C_ "webpage title" "screenshot |")) + #:description (screenshot-caption shot) + #:keywords + (string-split ;TRANSLATORS: |-separated list of webpage keywords + (G_ "Harmonic Flow|HFGE|Screenshot") #\|) + #:active-menu-item (C_ "website menu" "Screenshots") + #:css (list (hfweb-url "static/base/css/index.css") + (hfweb-url "static/media/css/screenshots.css")) + #:crumbs (list (crumb (C_ "website menu" "Screenshots") (hfweb-url "screenshots/")) + (crumb (screenshot-title shot) "./")) + #:content + `(main + (section + (@ (class "light-text centered-text noise-bg")) + (h2 + (@ (class "a11y-offset")) + ,(screenshot-title shot)) + + (div + (@ (class "screenshot-viewer")) + (img + (@ (class "responsive-image centered-block") + (src ,(screenshot-image shot)) + (alt ,(screenshot-caption shot))))) + + ,(screenshots-box shots #:shadow #t)))))) diff --git a/apps/media/templates/screenshots-overview.scm b/apps/media/templates/screenshots-overview.scm new file mode 100644 index 0000000..fee601b --- /dev/null +++ b/apps/media/templates/screenshots-overview.scm @@ -0,0 +1,28 @@ +;;; Harmonic Flow web site + +(define-module (apps media templates screenshots-overview) + #:use-module (apps base templates theme) + #:use-module (apps base types) + #:use-module (apps base utils) + #:use-module (apps i18n) + #:use-module (apps media templates components) + #:export (screenshots-overview-t)) + + +(define (screenshots-overview-t screenshots) + "Return an SHTML page for all SCREENSHOTS." + (theme + #:title (C_ "webpage title" '("Overview of all available screenshots |")) + #:description (G_ "Overview of all available screenshots.") + #:keywords + (string-split ;TRANSLATORS: |-separated list of webpage keywords + (G_ "Harmonic Flow|HFGE|Screenshots|Overview") #\|) + #:active-menu-item (C_ "website menu" "Screenshots") + #:css (list (hfweb-url "static/base/css/index.css")) + #:crumbs (list (crumb (C_ "website menu" "Screenshots") "./")) + #:content + `(main + (section + (@ (class "light-text centered-text noise-bg")) + + ,(screenshots-box screenshots (length screenshots) #:shadow #t))))) diff --git a/apps/media/types.scm b/apps/media/types.scm new file mode 100644 index 0000000..072684e --- /dev/null +++ b/apps/media/types.scm @@ -0,0 +1,60 @@ +;;; Harmonic Flow web site + +(define-module (apps media types) + #:use-module (srfi srfi-9) + #:export (screenshot + screenshot? + screenshot-caption + screenshot-image + screenshot-preview + screenshot-slug + screenshot-title + )) + + +;;; +;;; Data types. +;;; + + +;;; Screenshot (record type) +;;; ------------------------ +;;; +;;; A screenshot object represents an image of a software view seen +;;; on a screen. +;;; +;;; Objects of this type can be created with the "screenshot" +;;; procedure (see Helper procedures below). +;;; +;;; Fields: +;;; +;;; title (string) +;;; A title for the screenshot. +;;; +;;; slug (string) +;;; Slug-like URL name for the screenshot. For example: +;;; gnome-3-desktop. +;;; +;;; image (string) +;;; A URL to the full size image of the screenshot. +;;; +;;; preview (string) +;;; A URL to a small size image of the screenshot. +;;; +;;; caption (string) +;;; A short text describing the screenshot. +;;; +(define-record-type + (make-screenshot title slug image preview caption) + screenshot? + (title screenshot-title) + (slug screenshot-slug) + (image screenshot-image) + (preview screenshot-preview) + (caption screenshot-caption)) + +;;; Helper procedures. + +(define* (screenshot #:key title slug image preview caption) + "Return a object with the given attributes." + (make-screenshot title slug image preview caption)) -- cgit v1.2.3-54-g00ecf