Skip to content

Instantly share code, notes, and snippets.

@shegeley
Created February 6, 2022 16:52
Show Gist options
  • Save shegeley/3526e14abb4d55eae34aaee3b236153d to your computer and use it in GitHub Desktop.
Save shegeley/3526e14abb4d55eae34aaee3b236153d to your computer and use it in GitHub Desktop.
Example of the source code of the haunt-generated website.
(use-modules (haunt asset)
(haunt builder blog)
(srfi srfi-19)
(haunt builder atom)
(haunt builder assets)
(haunt builder rss)
(haunt reader)
(ice-9 vlist)
(haunt reader skribe)
(haunt reader texinfo)
(haunt reader commonmark)
(haunt i18n)
(haunt post)
(haunt page)
(haunt html)
(haunt site))
(define (with-language lang x)
(cdr (vhash-assoc lang x)))
(define %cc-by-sa-link
'(a (@ (href "https://creativecommons.org/licenses/by-sa/4.0/"))
"Creative Commons Attribution Share-Alike 4.0 International"))
(define (anchor content uri)
`(a (@ (href ,uri)) ,content))
(define (stylesheet name)
`(link (@ (rel "stylesheet")
(href ,(string-append "/css/" name ".css")))))
(define (date->string* date)
"Convert DATE to human readable string."
(date->string date "~H:~M ~d.~m.~Y"))
(define (translated-post-template post)
`((h2 ,(post-ref post 'title))
(h3 ,(->multilang #:en "authored by " #:ru "автор — ")
,(with-language #:ru (post-ref post 'author))
,(->multilang #:ru ", опубликовано "
#:rn ", published ")
,(date->string* (post-date post)))
(div ,(post-sxml post))))
(define about-me
`(div (@ (class "grid"))
(div (h1 "🤳")
(article
(img (@
(src "https://avatars.githubusercontent.com/u/8594472?v=4")))
(img (@
(style "padding-top: 20px;")))))
(div
(h1 "🇷🇺")
(h2 "Обо мне")
(ul "Где я живу"
(li "Россия, Белгород"))
(ul "Кто я"
(li "математик - по диплому (почти закончил)")
(li "clojure/clojurescript разраб по профессии")
(li "энтузиаст lisp-языков и опен-сурса"))
(ul "Чем я занимаюсь"
(li "заканчиваю бакалавриат по математике")
(li "пишу код на clojure/clojurescript")
(li "лениво поддерживаю движение за свободное ПО")
(li "иногда прохожу видеокурсы")
(li "изредка пишу посты в этом блоге")
(li "читаю разную литературу")
(li "спорт на-минималках, просто поддерживаю себя в форме, бегаю"))
(ul "Сетап"
(li "Текстовый редактор: " (a (@ (href "https://github.com/hlissner/doom-emacs")) "Doom Emacs"))
(li "ОСь: " (a (@ (href "https://guix.gnu.org/")) "GNU Guix"))
(li "Ноутбук: Thinkpad")))
(div
(h1 "🇬🇧")
(h2 "About me")
(ul "Where am I from"
(li "Russia, Belgorod"))
(ul "Who I am"
(li "almost mathematician (last year bachelor student)")
(li "working as clojure/clojurescript developer")
(li "enthusiast of Lisps and open-source"))
(ul "What do I do"
(li "finishing my bachelor degree")
(li "programming on clojure/clojurescript")
(li "lazily supporting the Free Software movement")
(li "sometimes watching online-courses")
(li "read different books")
(li "rarely write some posts on this website")
(li "do sports (some general excercies and running)"))
(ul "Setup"
(li "Text editor: " (a (@ (href "https://github.com/hlissner/doom-emacs")) "Doom Emacs"))
(li "OS: " (a (@ (href "https://guix.gnu.org/")) "GNU Guix"))
(li "Laptop: Thinkpad")))))
(define (translated-collection-template site title posts prefix)
(define* (post-uri site post #:key (prefix "/"))
(string-append prefix (site-post-slug site post) ".html"))
`(,about-me
(h3 ,title)
(ul
,@(map (lambda (post)
`(li
(a (@ (href ,(post-uri site post)))
,(post-ref post 'title)
" — "
,(date->string* (post-date post)))))
posts))))
(define* *theme*
(theme
#:name "Pico"
#:languages '(#:ru #:en)
#:layout
(lambda (site title body)
`((doctype "html")
(head
(meta (@ (charset "utf-8")))
(meta (@ (name "viewport")
(content "width=device-width, initial-scale=1")))
(link (@ (rel "icon")
(href "https://images.emojiterra.com/google/noto-emoji/v2.028/128px/1f468-1f4bb.png")))
(title ,(string-append (site-title site) " — " title))
,(stylesheet "pico"))
(body
(nav
(@ (class "container"))
(ul
(li ,(anchor "🏠" "/"))
(li ,(anchor "Github" "https://github.com/shegeley"))
(li ,(anchor "Sourcehut" "https://git.sr.ht/~shegeley"))))
(main (@ (class "container"))
,body
(footer
(@ (class "text-center"))
(div
(@ (class "grid"))
(div
(p
(small "Текст и изображения на этом сайте доступны по лицензии " ,%cc-by-sa-link "."))
(
(small "Этот статический сайт сделан на языке " (a (@ (href "https://www.gnu.org/software/guile/")) "Guile") " библиотекой " (a (@ (href "https://dthompson.us/projects/haunt.html") ) "Haunt"))))
(div
(p
(small "The text and images on this site are free
culture works available under the " ,%cc-by-sa-link " license."))
(p
(small "This static website is written with " (a (@ (href "https://www.gnu.org/software/guile/")) "Guile") " using the " (a (@ (href "https://dthompson.us/projects/haunt.html") ) "Haunt") " libriary")))))))))
#:post-template translated-post-template
#:collection-template translated-collection-template))
(define (%collections title language)
(list (list
title
"index.html"
(lambda (posts)
(posts-by-lang
(posts/reverse-chronological posts)
language)))))
(define *site*
(site #:title "Григорий Шепелев (@shegeley) | Личный блог"
#:domain "shegeley.github.io"
#:build-directory "site"
#:scheme 'https
#:default-metadata
`((author .
,(alist->vhash '((#:en . "Grigory Shepelev")
(#:ru . "Григорий Шепелев"))))
(email . "shegeley@gmail.com"))
#:readers (list
commonmark-reader
texinfo-reader
skribe-reader
sxml-reader
html-reader)
#:builders (list
(blog #:theme *theme*
#:collections (%collections "Свежие записи" #:ru)
#:language #:ru)
(static-directory "css"))))
*site*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment