website: Move screenshots code to new media module.

Suggested by sirgazil <sirgazil@zoho.com>.

* website/static/base/css/screenshots.css: Rename file to ...
* website/static/media/css/screenshots.css: ... this.
* website/apps/base/templates/screenshot.scm: Rename file to ...
* website/apps/media/templates/screenshot.scm: ... this.
(screenshot-t): Adapt path to CSS.
* website/apps/base/builder.scm (builder, screenshots-builder):
Move code for and references to screenshots-builder from here to ...
* website/apps/media/builder.scm: ... this new file.
* website/apps/base/data.scm (screenshots): Move from here to ...
* website/apps/media/data.scm: ... this new file.
* website/apps/base/templates/components.scm (screenshot->shtml):
Move from here to ...
* website/apps/media/templates/components.scm: ... this new file.
* website/apps/base/types.scm (<screenshot>, screenshot):
Move from here to ...
* website/apps/media/types.scm: ... this new file.
* website/apps/base/templates/home.scm: Adapt module references.
* website/haunt.scm (site): Add media builder.
This commit is contained in:
Florian Pelz 2019-10-24 15:02:17 +02:00
parent 08b152d4b6
commit 3e25cce32c
No known key found for this signature in database
GPG Key ID: 300888CB39C63817
12 changed files with 217 additions and 141 deletions

View File

@ -3,7 +3,6 @@
;;; copyright interest on this file.
(define-module (apps base builder)
#:use-module (apps aux system)
#:use-module (apps base data)
#:use-module (apps base templates about)
#:use-module (apps base templates contact)
@ -14,10 +13,10 @@
#:use-module (apps base templates help)
#:use-module (apps base templates home)
#:use-module (apps base templates menu)
#:use-module (apps base templates screenshot)
#:use-module (apps base templates security)
#:use-module (apps base types)
#:use-module (apps blog utils)
#:use-module (apps media data)
#:use-module (haunt html)
#:use-module (haunt page)
#:use-module (haunt post)
@ -48,7 +47,6 @@
(flatten
(list (menu-builder)
(home-builder site posts)
(screenshots-builder)
(help-builder)
(donate-builder)
(about-builder)
@ -115,21 +113,6 @@
(make-page "menu/index.html" (menu-t) sxml->html))
(define (screenshots-builder)
"Return a list of Haunt page representing screenshot pages."
(map
(lambda (shot)
(let ((context
(list (cons "screenshot" shot)
(cons "screenshots" screenshots))))
(make-page (path-join "screenshots"
(screenshot-slug shot)
"index.html")
(screenshot-t context)
sxml->html)))
screenshots))
(define (security-builder)
"Return a Haunt page representing the Security page of the website."
(make-page "security/index.html" (security-t) sxml->html))

View File

@ -5,8 +5,7 @@
(define-module (apps base data)
#:use-module (apps base types)
#:use-module (apps base utils)
#:export (contact-media
screenshots))
#:export (contact-media))
;;;
@ -187,49 +186,3 @@ het Nederlands.")
'(p "GNU software announcements.")
#:url "https://lists.gnu.org/mailman/listinfo/info-gnu"
#:log "https://lists.gnu.org/archive/html/info-gnu/")))
(define screenshots
(list
(screenshot
#:title "Graphical log-in"
#:slug "slim"
#:image (guix-url "static/media/img/gdm-sessions.png")
#:preview (guix-url "static/media/img/gdm-sessions.mini.png")
#:caption "Graphical log-in screen")
(screenshot
#:title "GNOME"
#:slug "gnome"
#:image (guix-url "static/media/img/gnome-totem-epiphany.png")
#:preview (guix-url "static/media/img/gnome-totem-epiphany.mini.png")
#:caption "Control your computer with the GNOME desktop environment")
(screenshot
#:title "Xfce"
#:slug "xfce"
#:image (guix-url "static/media/img/guixsd-xfce-icecat-emacs.png")
#:preview (guix-url "static/media/img/guixsd-xfce-icecat-emacs.mini.png")
#:caption "The Xfce desktop environment with GNU Emacs and IceCat")
(screenshot
#:title "Virtual machine"
#:slug "virtual-machine"
#:image (guix-url "static/media/img/guix-system-vm.png")
#:preview (guix-url "static/media/img/guix-system-vm.mini.png")
#:caption "Virtual machine started with 'guix system vm'")
(screenshot
#:title "Sway"
#:slug "sway"
#:image (guix-url "static/media/img/sway.png")
#:preview (guix-url "static/media/img/sway.mini.png")
#:caption "Sway window manager running wayland")
(screenshot
#:title "Enlightenment"
#:slug "enlightenment"
#:image (guix-url "static/media/img/enlightenment-inkscape.png")
#:preview (guix-url "static/media/img/enlightenment-inkscape.mini.png")
#:caption "Enlightenment, Inkscape, and Serbian text")))

View File

@ -25,8 +25,7 @@
link-yellow
navbar
page-indicator
page-selector
screenshot->shtml))
page-selector))
;;;
@ -359,21 +358,3 @@
" ")) ; NOTE: Force space for readability in non-CSS browsers.
(iota pages 1))
"")))
(define (screenshot->shtml shot)
"Return an SHTML representation of the given screenshot object.
SHOT (<screenshot>)
A screenshot object as defined in (apps base types)."
`(div
(@ (class "screenshot-preview"))
(a
(@ (href ,(guix-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")) "."))))

View File

@ -8,6 +8,7 @@
#:use-module (apps base types)
#:use-module (apps base utils)
#:use-module (apps blog templates components)
#:use-module (apps media templates components)
#:export (home-t))

View File

@ -14,14 +14,7 @@
crumb
crumb?
crumb-label
crumb-url
screenshot
screenshot?
screenshot-caption
screenshot-image
screenshot-preview
screenshot-slug
screenshot-title))
crumb-url))
;;;
@ -131,47 +124,3 @@
(define (crumb label url)
"Return a <crumb> object with the given attributes."
(make-crumb label url))
;;; 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 <screenshot>
(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 <screenshot> object with the given attributes."
(make-screenshot title slug image preview caption))

View File

@ -0,0 +1,56 @@
;;; GNU Guix web site
;;; Initially written by sirgazil who waives all
;;; copyright interest on this file.
(define-module (apps media builder)
#:use-module (apps aux system)
#:use-module (apps media data)
#:use-module (apps media templates screenshot)
#:use-module (apps media types)
#:use-module (haunt html)
#:use-module (haunt page)
#:use-module (haunt utils)
#: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 (<site>)
A site object that defines all the properties of the website. See
Haunt <site> objects for more information.
POSTS (list of <post>)
A list of post objects that represent articles from the blog. See
Haunt <post> objects for more information.
RETURN (list of <page>)
A list of page objects that represent the web resources of the
application. See Haunt <page> objects for more information."
(flatten
(list (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))))
(make-page (path-join "screenshots"
(screenshot-slug shot)
"index.html")
(screenshot-t context)
sxml->html)))
screenshots))

View File

@ -0,0 +1,57 @@
;;; GNU Guix web site
;;; Initially written by sirgazil who waves all
;;; copyright interest on this file.
(define-module (apps media data)
#:use-module (apps base utils)
#:use-module (apps media types)
#:export (screenshots))
;;;
;;; Data.
;;;
(define screenshots
(list
(screenshot
#:title "Graphical log-in"
#:slug "slim"
#:image (guix-url "static/media/img/gdm-sessions.png")
#:preview (guix-url "static/media/img/gdm-sessions.mini.png")
#:caption "Graphical log-in screen")
(screenshot
#:title "GNOME"
#:slug "gnome"
#:image (guix-url "static/media/img/gnome-totem-epiphany.png")
#:preview (guix-url "static/media/img/gnome-totem-epiphany.mini.png")
#:caption "Control your computer with the GNOME desktop environment")
(screenshot
#:title "Xfce"
#:slug "xfce"
#:image (guix-url "static/media/img/guixsd-xfce-icecat-emacs.png")
#:preview (guix-url "static/media/img/guixsd-xfce-icecat-emacs.mini.png")
#:caption "The Xfce desktop environment with GNU Emacs and IceCat")
(screenshot
#:title "Virtual machine"
#:slug "virtual-machine"
#:image (guix-url "static/media/img/guix-system-vm.png")
#:preview (guix-url "static/media/img/guix-system-vm.mini.png")
#:caption "Virtual machine started with 'guix system vm'")
(screenshot
#:title "Sway"
#:slug "sway"
#:image (guix-url "static/media/img/sway.png")
#:preview (guix-url "static/media/img/sway.mini.png")
#:caption "Sway window manager running wayland")
(screenshot
#:title "Enlightenment"
#:slug "enlightenment"
#:image (guix-url "static/media/img/enlightenment-inkscape.png")
#:preview (guix-url "static/media/img/enlightenment-inkscape.mini.png")
#:caption "Enlightenment, Inkscape, and Serbian text")))

View File

@ -0,0 +1,33 @@
;;; GNU Guix web site
;;; Initially written by sirgazil who waves all
;;; copyright interest on this file.
;;; This module defines HTML parts related to media.
(define-module (apps media templates components)
#:use-module (apps aux web)
#:use-module (apps base utils)
#:use-module (apps media types)
#:export (screenshot->shtml))
;;;
;;; 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 ,(guix-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")) "."))))

View File

@ -2,11 +2,12 @@
;;; Initially written by sirgazil who waves all
;;; copyright interest on this file.
(define-module (apps base templates screenshot)
#:use-module (apps base templates components)
(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)
#:export (screenshot-t))
@ -24,7 +25,7 @@
"Functional package management" "Reproducibility")
#:active-menu-item "Overview"
#:css (list (guix-url "static/base/css/index.css")
(guix-url "static/base/css/screenshots.css"))
(guix-url "static/media/css/screenshots.css"))
#:content
`(main
(section

View File

@ -0,0 +1,60 @@
;;; GNU Guix web site
;;; Initially written by sirgazil who waves all
;;; copyright interest on this file.
(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 <screenshot>
(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 <screenshot> object with the given attributes."
(make-screenshot title slug image preview caption))

View File

@ -5,6 +5,7 @@
(use-modules ((apps base builder) #:prefix base:)
((apps blog builder) #:prefix blog:)
((apps download builder) #:prefix download:)
((apps media builder) #:prefix media:)
((apps packages builder) #:prefix packages:)
(haunt asset)
(haunt builder assets)
@ -20,5 +21,6 @@
#:builders (list base:builder
blog:builder
download:builder
media:builder
packages:builder
(static-directory "static")))