guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/05: website: Move screenshots code to new media module.


From: Florian Pelz
Subject: 01/05: website: Move screenshots code to new media module.
Date: Sat, 26 Oct 2019 09:23:49 -0400 (EDT)

pelzflorian pushed a commit to branch master
in repository guix-artwork.

commit 3e25cce32c9f31abcec1bbe089a43724349f2637
Author: Florian Pelz <address@hidden>
Date:   Thu Oct 24 15:02:17 2019 +0200

    website: Move screenshots code to new media module.
    
    Suggested by sirgazil <address@hidden>.
    
    * 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.
---
 website/apps/base/builder.scm                      | 19 +------
 website/apps/base/data.scm                         | 49 +-----------------
 website/apps/base/templates/components.scm         | 21 +-------
 website/apps/base/templates/home.scm               |  1 +
 website/apps/base/types.scm                        | 53 +------------------
 website/apps/media/builder.scm                     | 56 ++++++++++++++++++++
 website/apps/media/data.scm                        | 57 ++++++++++++++++++++
 website/apps/media/templates/components.scm        | 33 ++++++++++++
 .../apps/{base => media}/templates/screenshot.scm  |  7 +--
 website/apps/media/types.scm                       | 60 ++++++++++++++++++++++
 website/haunt.scm                                  |  2 +
 website/static/{base => media}/css/screenshots.css |  0
 12 files changed, 217 insertions(+), 141 deletions(-)

diff --git a/website/apps/base/builder.scm b/website/apps/base/builder.scm
index f34ec87..3433fcc 100644
--- a/website/apps/base/builder.scm
+++ b/website/apps/base/builder.scm
@@ -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))
diff --git a/website/apps/base/data.scm b/website/apps/base/data.scm
index a1428c8..5837efb 100644
--- a/website/apps/base/data.scm
+++ b/website/apps/base/data.scm
@@ -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")))
diff --git a/website/apps/base/templates/components.scm 
b/website/apps/base/templates/components.scm
index d3f6af1..d5d0a90 100644
--- a/website/apps/base/templates/components.scm
+++ b/website/apps/base/templates/components.scm
@@ -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")) "."))))
diff --git a/website/apps/base/templates/home.scm 
b/website/apps/base/templates/home.scm
index 5cb3bf5..e5f9cc0 100644
--- a/website/apps/base/templates/home.scm
+++ b/website/apps/base/templates/home.scm
@@ -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))
 
 
diff --git a/website/apps/base/types.scm b/website/apps/base/types.scm
index 3976fdf..d58155c 100644
--- a/website/apps/base/types.scm
+++ b/website/apps/base/types.scm
@@ -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))
diff --git a/website/apps/media/builder.scm b/website/apps/media/builder.scm
new file mode 100644
index 0000000..eb4643a
--- /dev/null
+++ b/website/apps/media/builder.scm
@@ -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))
diff --git a/website/apps/media/data.scm b/website/apps/media/data.scm
new file mode 100644
index 0000000..40eea61
--- /dev/null
+++ b/website/apps/media/data.scm
@@ -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")))
diff --git a/website/apps/media/templates/components.scm 
b/website/apps/media/templates/components.scm
new file mode 100644
index 0000000..825ac37
--- /dev/null
+++ b/website/apps/media/templates/components.scm
@@ -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")) "."))))
diff --git a/website/apps/base/templates/screenshot.scm 
b/website/apps/media/templates/screenshot.scm
similarity index 87%
rename from website/apps/base/templates/screenshot.scm
rename to website/apps/media/templates/screenshot.scm
index 41a3a07..9f480de 100644
--- a/website/apps/base/templates/screenshot.scm
+++ b/website/apps/media/templates/screenshot.scm
@@ -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
diff --git a/website/apps/media/types.scm b/website/apps/media/types.scm
new file mode 100644
index 0000000..020b89c
--- /dev/null
+++ b/website/apps/media/types.scm
@@ -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))
diff --git a/website/haunt.scm b/website/haunt.scm
index 9f66920..0cb7177 100644
--- a/website/haunt.scm
+++ b/website/haunt.scm
@@ -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")))
diff --git a/website/static/base/css/screenshots.css 
b/website/static/media/css/screenshots.css
similarity index 100%
rename from website/static/base/css/screenshots.css
rename to website/static/media/css/screenshots.css



reply via email to

[Prev in Thread] Current Thread [Next in Thread]