haunt.scm 3.08 KB
Newer Older
Ludovic Courtès's avatar
Ludovic Courtès committed
1 2 3 4 5 6 7 8 9 10 11
;;; This module is part of Guix-HPC and is licensed under the same terms,
;;; those of the GNU GPL version 3 or (at your option) any later version.
;;;
;;; Copyright © 2017 Inria

;; This is a build file for Haunt.  Run 'haunt build' to build the web site,
;; and 'haunt serve' to serve it locally.  Alternatively, you can run
;; 'guix build -f guix.scm' to have everything built in the store.
(use-modules (haunt site)
             (haunt reader)
             (haunt reader commonmark)
Roel Janssen's avatar
Roel Janssen committed
12
             (haunt post)
Ludovic Courtès's avatar
Ludovic Courtès committed
13 14 15 16 17 18 19 20
             (haunt page)
             (haunt html)
             (haunt utils)
             (haunt builder assets)
             (haunt builder blog)
             (haunt builder atom)
             (ice-9 match)
             (srfi srfi-1)
Roel Janssen's avatar
Roel Janssen committed
21
             (srfi srfi-19)
Ludovic Courtès's avatar
Ludovic Courtès committed
22 23
             (guix-hpc))

Ludovic Courtès's avatar
Ludovic Courtès committed
24 25 26
(define %web-site-title
  "Guix-HPC — Reproducible software deployment for high-performance computing")

Roel Janssen's avatar
Roel Janssen committed
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
(define* (post->sxml post #:key post-uri)
  "Return the SXML for POST."
  `(div (@ (class "post"))
        (h2 (@ (class "title"))
            ,(if post-uri
                 `(a (@ (href ,post-uri))
                     ,(post-ref post 'title))
                 (post-ref post 'title)))
        (div (@ (class "post-about"))
             ,(post-ref post 'author)
             " — " ,(date->string (post-date post) "~B ~e, ~Y"))
        (hr)
        (div (@ (class "post-body"))
             ,(post-sxml post))))

(define (page->sxml site title posts prefix)
  "Return the SXML for the news page of SITE, containing POSTS."
  `((div (@ (class "header"))
         (div (@ (class "post-list"))
              ,@(map (lambda (post)
                       (post->sxml post #:post-uri (post-url post site)))
                     posts)))))

(define %hpc-haunt-theme
  ;; Theme for the rendering of the news pages.
Ludovic Courtès's avatar
Ludovic Courtès committed
52
  (theme #:name "Guix-HPC"
Roel Janssen's avatar
Roel Janssen committed
53
         #:layout (lambda (site title body)
Ludovic Courtès's avatar
Ludovic Courtès committed
54
                    (base-layout body #:title %web-site-title))
Roel Janssen's avatar
Roel Janssen committed
55 56 57
         #:post-template post->sxml
         #:collection-template page->sxml))

Ludovic Courtès's avatar
Ludovic Courtès committed
58 59 60 61 62 63 64 65
(define %local-test?
  ;; True when we're testing locally, as opposed to producing things to
  ;; install to gnu.org.
  (or (getenv "WEB_SITE_LOCAL")
      (member "serve" (command-line))))           ;'haunt serve' command

(when %local-test?
  ;; The URLs produced in these pages are only meant for local consumption.
Roel Janssen's avatar
Roel Janssen committed
66
  (format #t "~%Producing Web pages for local tests *only*!~%~%"))
Ludovic Courtès's avatar
Ludovic Courtès committed
67

Ludovic Courtès's avatar
Ludovic Courtès committed
68
(site #:title %web-site-title
Ludovic Courtès's avatar
Ludovic Courtès committed
69 70 71 72 73 74
      #:domain "//hpc.guixsd.org/"
      #:default-metadata
      '((author . "Guix-HPC Contributors")
        (email  . "guix-devel@gnu.org"))
      #:readers (list commonmark-reader)
      #:builders
75 76
      (cons* (blog #:theme %hpc-haunt-theme
                   #:prefix "blog")
Ludovic Courtès's avatar
Ludovic Courtès committed
77 78 79

             ;; Apparently the <link> tags of Atom entries must be absolute URLs,
             ;; hence this #:blog-prefix.
80
             (atom-feed #:file-name "blog/feed.xml"
Ludovic Courtès's avatar
Ludovic Courtès committed
81 82
                        #:blog-prefix "https://hpc.guixsd.org")

Roel Janssen's avatar
Roel Janssen committed
83
             (static-directory "static")
Ludovic Courtès's avatar
Ludovic Courtès committed
84 85 86 87 88

             (map (lambda (page)
                    (lambda (site posts)
                      page))
                  (static-pages))))