;;; The GNU Assembly Web Site ;;; Copyright © 2021 Ludovic Courtès ;;; Copyright © 2021 Ricardo Wurmus ;;; ;;; This program 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. ;;; ;;; This program 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 this program. If not, see . (use-modules (haunt asset) (haunt site) (haunt page) (haunt html) (haunt builder assets) (haunt reader) (haunt reader commonmark) (srfi srfi-71) (ice-9 match)) (define %cwd (and=> (assq-ref (current-source-location) 'filename) dirname)) (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* (base-layout body #:key (title "") (meta '()) (posts '()) site) (define (menubar where) (let ((locations '(("about" "About" "/") ("software" "Software" "/en/software") ("blog" "Blog" "/en/blog")))) `(div (@ (id "menubar") (class "width-control")) (ul ,@(map (match-lambda ((key text path) (if (and where (string=? where key)) `(li (@ (class "selected")) (span ,text)) `(li (a (@ (href ,(base-url path))) ,text))))) locations) (li (a (@ (href ,(base-url "/en/blog/feed.xml"))) (img (@ (alt "Atom feed") (src ,(image-url "/feed.png")))))))))) (define front-page? (assoc-ref meta 'frontpage)) `((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.svg")))) (link (@ (rel "stylesheet") (href ,(css-url "/main.css")) (type "text/css") (media "screen"))) (title ,title)) (body ,@(if front-page? '((@ (class "frontpage"))) '()) (div (@ (id "header")) (div (@ (id "header-inner") (class "width-control")) (a (@ (href ,(base-url "/")) (class ,(if front-page? "logo" "logo small"))) (img (@ (alt "The logo of the GNU Assembly") (src ,(image-url (if front-page? "/logo.svg" "/logo-small.svg")))))) ;; Add the large-font welcoming message on the ;; front page. ,@(if front-page? `((p (@ (id "heading") (class "front-page-heading")) "Welcome to the GNU Assembly! We write " (a (@ (href "/en/documents/free-software")) (emph "free software")) " — software that empowers users, " "giving them individual and collective control " "over their computing, from the operating " "system to applications.")) `(,(menubar (assoc-ref meta 'menu)))))) ,@(if front-page? `(,(menubar "about")) '()) (div (@ (id "content") (class "width-control")) (div (@ (id "content-inner")) (article ,body))) (div (@ (id "footer-box") (class "width-control")) (p (a (@ (href "https://wiki.gnu.tools/git/")) ;FIXME "Source of this site"))))))) (define read-markdown (reader-proc commonmark-reader)) (define (read-markdown-page file posts site) "Read the CommonMark page from FILE. Return its final SXML representation." (let ((meta body (read-markdown (string-append %cwd "/" file)))) (base-layout `(div (@ (class "post")) (div (@ (class "post-body")) ,body)) #:title (string-append "The GNU Assembly — " (assoc-ref meta 'title)) #:meta meta #:posts posts #:site site))) (define (static-pages) "Return the list of static web pages." (define (markdown-page html md) (lambda (site posts) (make-page html (read-markdown-page md posts site) sxml->html))) (list (markdown-page "index.html" "index.md") (markdown-page "/en/software/index.html" "software.md") (markdown-page "/en/documents/free-software/index.html" "free-software.md") (markdown-page "/en/documents/code-of-conduct/index.html" "code-of-conduct.md") (markdown-page "/en/documents/social-contract/index.html" "social-contract.md"))) (site #:title "The GNU Assembly" #:domain "gnu.tools" #:default-metadata '((author . "The GNU Assembly") (email . "assembly@lists.gnu.tools")) #:readers (list commonmark-reader) #:builders (cons (static-directory "static") (static-pages)))