guix-hpc.scm 3.78 KB
Newer Older
Ludovic Courtès's avatar
Ludovic Courtès committed
1 2 3 4 5 6 7
;;; 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

(define-module (guix-hpc)
  #:use-module (haunt page)
8
  #:use-module (haunt site)
Ludovic Courtès's avatar
Ludovic Courtès committed
9
  #:use-module (haunt html)
Ludovic Courtès's avatar
Ludovic Courtès committed
10 11
  #:use-module (haunt reader)
  #:use-module (haunt reader commonmark)
Ludovic Courtès's avatar
Ludovic Courtès committed
12
  #:use-module (srfi srfi-11)
13 14 15 16
  #:export (base-url
            image-url
            css-url
            post-url
Ludovic Courtès's avatar
Ludovic Courtès committed
17

Ludovic Courtès's avatar
Ludovic Courtès committed
18 19
            base-layout

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
            static-pages))

(define (base-url . location)
  (string-concatenate (cons "" location)))

(define (image-url location)
  (base-url "static/images" location))

(define (css-url location)
  (base-url "static/css" location))

(define (post-url post site)
  "Return the URL of POST, a Haunt blog post, for SITE."
  (base-url (site-post-slug site post) ".html"))

Ludovic Courtès's avatar
Ludovic Courtès committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54

(define* (base-layout body #:key (title "Guix-HPC"))
  `((doctype "html")
    (html (@ (lang "en"))
          (head
           (meta (@ (http-equiv "Content-Type")
                    (content "text/html; charset=utf-8")))
           (link (@ (rel "icon")
                    (type "image/x-icon")
                    (href ,(image-url "/favicon.png"))))
           (link (@ (rel "stylesheet")
                    (href ,(css-url "/main.css"))
                    (type "text/css")
                    (media "screen")))
           (title ,title))
	  (body
           (div (@ (id "header"))
                (div (@ (id "header-inner")
                        (class "width-control"))
                     (img (@ (class "logo")
55 56 57
                             (src ,(image-url "/logo.png"))))
                     (div (@ (class "baseline"))
                          "Reproducible software deployment for high-performance computing.")))
Ludovic Courtès's avatar
Ludovic Courtès committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
           (div (@ (id "menubar")
                   (class "width-control"))
                (ul
                 (li (a (@ (href ,(base-url "about.html")))
                        "About"))
                 (li (a (@ (href ,(base-url "/news/feed.xml")))
                        (img (@ (alt "Atom feed")
                                (src ,(image-url "/feed.png"))))))))

           (div (@ (id "content")
                   (class "width-control"))
                (div (@ (id "content-inner"))
                     (article ,body)))

           (div (@ (id "collaboration"))
                (div (@ (id "collaboration-inner")
                        (class "width-control"))
                     (div (@ (class "members"))
                          (ul
                           (li (img (@ (alt "MDC")
                                       (src ,(image-url "/mdc.png")))))
                           (li (img (@ (alt "Inria")
                                       (src ,(image-url "/inria.png")))))
81 82
                           (li (img (@ (alt "UBC")
                                       (src ,(image-url "/ubc.png")))))))))
Ludovic Courtès's avatar
Ludovic Courtès committed
83 84
           (div (@ (id "footer-box")
                   (class "width-control"))
85 86
                (p (a (@ (href "https://gitlab.inria.fr/guix-hpc/website"))
                      "Source of this site")))))))
Ludovic Courtès's avatar
Ludovic Courtès committed
87

88

Ludovic Courtès's avatar
Ludovic Courtès committed
89 90 91 92 93 94 95
(define %cwd
  (and=> (assq-ref (current-source-location) 'filename)
         dirname))

(define read-markdown
  (reader-proc commonmark-reader))

Ludovic Courtès's avatar
Ludovic Courtès committed
96 97 98 99 100 101 102 103 104 105
(define (read-markdown-page file)
  "Read the CommonMark page from FILE.  Return its final SXML
representation."
  (let-values (((meta body)
                (read-markdown (string-append %cwd "/" file))))
    (base-layout `(div (@ (class "post"))
                       (div (@ (class "post-body")) ,body))
                 #:title (string-append "Guix-HPC — "
                                        (assoc-ref meta 'title)))))

Ludovic Courtès's avatar
Ludovic Courtès committed
106
(define (about-page)
Ludovic Courtès's avatar
Ludovic Courtès committed
107
  (read-markdown-page "about.md"))
Ludovic Courtès's avatar
Ludovic Courtès committed
108 109

(define (static-pages)
Ludovic Courtès's avatar
Ludovic Courtès committed
110
  (list (make-page "about.html" (about-page) sxml->html)))