theme.scm
1 | ;;; Nani Project website |
2 | ;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu> |
3 | ;;; |
4 | ;;; This file is part of the Nani Project website. |
5 | ;;; |
6 | ;;; The Nani Project website is free software; you can redistribute it and/or modify it |
7 | ;;; under the terms of the GNU Affero General Public License as published by |
8 | ;;; the Free Software Foundation; either version 3 of the License, or (at |
9 | ;;; your option) any later version. |
10 | ;;; |
11 | ;;; The Nani Project website is distributed in the hope that it will be useful, but |
12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | ;;; GNU Affero General Public License for more details. |
15 | ;;; |
16 | ;;; You should have received a copy of the GNU Affero General Public License |
17 | ;;; along with the Nani Project website. If not, see <http://www.gnu.org/licenses/>. |
18 | |
19 | (define-module (tools theme) |
20 | #:use-module (haunt builder blog) |
21 | #:use-module (haunt post) |
22 | #:use-module (haunt site) |
23 | #:use-module (tools haunt-i18n) |
24 | #:use-module (tools i18n) |
25 | #:use-module (srfi srfi-1) |
26 | #:export (nani-theme)) |
27 | |
28 | (define (nani-theme lang page) |
29 | (theme #:name "Nani" |
30 | #:layout |
31 | (lambda (site title body) |
32 | (site-locale lang) |
33 | `((doctype "html") |
34 | (head |
35 | (meta (@ (charset "utf-8"))) |
36 | (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) |
37 | (title ,(list title " — " (site-title site))) |
38 | (link (@ (rel "stylesheet") (href "/css/nani.css"))) |
39 | (link (@ (rel "stylesheet") (href "/css/device.css")))) |
40 | (body (@ (lang ,lang)) |
41 | (header |
42 | (span (a (@ (href "/")) "何?")) |
43 | (nav (@ (id "main-menu")) |
44 | (label (@ (for "hamburger") (id "hamburger-label")) |
45 | (img (@ (alt "(open the menu)") (src "/images/hamburger.png")))) |
46 | (input (@ (id "hamburger") (type "checkbox"))) |
47 | (ul |
48 | (li (a (@ (href "/index.html")) ,(_ "Features"))) |
49 | (li (a (@ (href "/documentation.html")) ,(_ "Documentation"))) |
50 | (li (a (@ (href "https://framagit.org/nani-project/nani-app")) |
51 | ,(_ "Build it")))))) |
52 | (div (@ (id "page")) |
53 | (div (@ (id "content-block")) (div (@ (id "content")) ,body))) |
54 | (footer |
55 | (div (@ (class "footer-flex")) |
56 | (p "© Copyright Julien Lepiller 2019") |
57 | (p (a (@ (href "/mentions.html")) ,(_ "Legal notices")))) |
58 | (p ,(_ "The source of this website can be seen at |
59 | <a href=\"~a\">framagit</a>. This website is free software; you can redistribute |
60 | it and/or modify it under the terms of the GNU Affero General Public License |
61 | as published by the Free Software Foundation; either version 3 of the License, |
62 | or (at your option) any later version." |
63 | "https://framagit.org/nani-project/nani-website")))))) |
64 | #:post-template |
65 | (lambda (post) |
66 | `((article |
67 | (h1 ,(post-ref post 'title)) |
68 | (p (@ (class "date")) ,(_ "by ~a — ~a" (post-ref post 'author) (date->string* (post-date post)))) |
69 | (div ,(post-sxml post))))) |
70 | #:collection-template |
71 | (lambda (site title posts prefix) |
72 | (define (post-uri post) |
73 | (string-append "/" (or prefix "") |
74 | (site-post-slug site post) ".html")) |
75 | `(div |
76 | (p (a (@ (href "/blog-complete.html")) ,(_ "View posts for every language"))) |
77 | (div (@ (id "post-list")) |
78 | ,@(map (lambda (post) |
79 | (let ((language (fold (lambda (key acc) (if (member key (post-ref post 'tags)) key acc)) "" languages))) |
80 | `(div (@ (class ,(string-append "post " language))) |
81 | (p (@ (class "title")) |
82 | (a (@ (href ,(post-uri post))) |
83 | ,(post-ref post 'title))) |
84 | (p (@ (class "post-content")) |
85 | ,(post-ref post 'summary)) |
86 | (p (@ (class "date")) |
87 | (span |
88 | (a (@ (href ,(post-uri post))) |
89 | ,(_ "Read"))) |
90 | (span (@ (class ,language)) ,language) |
91 | ,(date->string* (post-date post)))))) |
92 | posts)))))) |
93 |