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 ,(string-append "/" lang "/"))) "何?")) |
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 ,(string-append "/" lang "/index.html"))) |
49 | ,(_ "Features"))) |
50 | (li (a (@ (href ,(string-append "/" lang "/documentation.html"))) |
51 | ,(_ "Documentation"))) |
52 | (li (a (@ (href "https://framagit.org/nani-project/nani-app")) |
53 | ,(_ "Build it"))) |
54 | (li (@ (id "lang-selector")) |
55 | (p ,(_ "Language")) |
56 | (ul ,@(map |
57 | (lambda (ll) |
58 | (site-locale ll) |
59 | (let ((li |
60 | `(li |
61 | (a (@ (href ,(string-append |
62 | "/" ll "/" |
63 | (basename page) |
64 | ".html"))) |
65 | ;; TRANSLATORS: translate this with the name of your language. |
66 | ,(_ "English"))))) |
67 | (site-locale lang) |
68 | li)) |
69 | '("en" "fr" "uk" "zh_CN")) |
70 | (li (a (@ (href "https://translate.fedoraproject.org/projects/nani/")) |
71 | ,(_ "Translate")))))))) |
72 | (div (@ (id "page")) |
73 | (div (@ (id "content-block")) (div (@ (id "content")) ,body))) |
74 | (footer |
75 | (div (@ (class "footer-flex")) |
76 | (p "© Copyright Julien Lepiller 2019") |
77 | (p (a (@ (href ,(string-append "/" lang "/mentions.html"))) |
78 | ,(_ "Legal notices")))) |
79 | (p ,(_ "The source of this website can be seen at |
80 | <a href=\"~a\">framagit</a>. This website is free software; you can redistribute |
81 | it and/or modify it under the terms of the GNU Affero General Public License |
82 | as published by the Free Software Foundation; either version 3 of the License, |
83 | or (at your option) any later version." |
84 | "https://framagit.org/nani-project/nani-website")))))) |
85 | #:post-template |
86 | (lambda (post) |
87 | `((article |
88 | (h1 ,(post-ref post 'title)) |
89 | (p (@ (class "date")) ,(_ "by ~a — ~a" (post-ref post 'author) (date->string* (post-date post)))) |
90 | (div ,(post-sxml post))))) |
91 | #:collection-template |
92 | (lambda (site title posts prefix) |
93 | (define (post-uri post) |
94 | (string-append "/" (or prefix "") |
95 | (site-post-slug site post) ".html")) |
96 | `(div |
97 | (p (a (@ (href "/blog-complete.html")) ,(_ "View posts for every language"))) |
98 | (div (@ (id "post-list")) |
99 | ,@(map (lambda (post) |
100 | (let ((language (fold (lambda (key acc) (if (member key (post-ref post 'tags)) key acc)) "" languages))) |
101 | `(div (@ (class ,(string-append "post " language))) |
102 | (p (@ (class "title")) |
103 | (a (@ (href ,(post-uri post))) |
104 | ,(post-ref post 'title))) |
105 | (p (@ (class "post-content")) |
106 | ,(post-ref post 'summary)) |
107 | (p (@ (class "date")) |
108 | (span |
109 | (a (@ (href ,(post-uri post))) |
110 | ,(_ "Read"))) |
111 | (span (@ (class ,language)) ,language) |
112 | ,(date->string* (post-date post)))))) |
113 | posts)))))) |
114 |