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