1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
;;; GuixSD website --- GNU's advanced distro website
;;; Copyright © 2015 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GuixSD website.
;;;
;;; GuixSD website is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or
;;; (at your option) any later version.
;;;
;;; GuixSD website is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;;; General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GuixSD website. If not, see <http://www.gnu.org/licenses/>.
;; This is a build file for Haunt.
(use-modules (haunt site)
(haunt reader)
(haunt reader commonmark)
(haunt page)
(haunt html)
(haunt utils)
(haunt builder assets)
(haunt builder blog)
(haunt builder atom)
(ice-9 match)
(srfi srfi-1)
(www)
(www utils)
(www news))
(define %local-test?
;; True when we're testing locally, as opposed to producing things to
;; install to gnu.org.
(or (getenv "GUIX_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.
(format #t "~%Producing Web pages for local tests *only*!~%~%"))
(define-syntax-rule (with-url-parameters body ...)
"Run BODY in a context where URL parameters honor %LOCAL-TEST?."
(parameterize ((current-url-root (if %local-test?
""
(current-url-root)))
(gnu.org-root (if %local-test?
"https://www.gnu.org"
(gnu.org-root))))
body ...))
(define (parameterized-procedure proc)
(lambda args
(with-url-parameters
(apply proc args))))
(define (parameterized-theme thm)
(theme #:name (theme-name thm)
#:layout (parameterized-procedure (theme-layout thm))
#:post-template (parameterized-procedure (theme-post-template thm))
#:collection-template (parameterized-procedure
(theme-collection-template thm))))
(site #:title "GNU's advanced distro and transactional package manager"
#:domain "//www.gnu.org/software/guix"
#:default-metadata
'((author . "GuixSD Contributors")
(email . "guix-devel@gnu.org"))
#:readers (list sxml-reader html-reader commonmark-reader)
#:builders
`(,(lambda (site posts) ;the main page
(with-url-parameters
(make-page "guix.html" `((doctype "html") ,(main-page site posts))
sxml->html)))
,@(filter-map (match-lambda
(("guix.html" _) ;handled above
#f)
((file-name contents)
(lambda (site posts)
(with-url-parameters
(make-page file-name
`((doctype "html") ,(contents))
sxml->html)))))
%web-pages)
,(blog #:theme (parameterized-theme %news-haunt-theme)
#:prefix "news")
;; Apparently the <link> tags of Atom entries must be absolute URLs,
;; hence this #:blog-prefix.
,(atom-feed #:file-name "news/feed.xml"
#:blog-prefix "https://www.gnu.org/software/guix/news")
,(static-directory "static")))
|