aboutsummaryrefslogtreecommitdiff
path: root/haunt.scm
blob: 353abeeddf49dc105505a8454c6fdda862cd9e57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
;;; Copyright © 2019 Jakob L. Kreuze <zerodaysfordays@sdf.lonestar.org>
;;;
;;; 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
;;; <http://www.gnu.org/licenses/>.

(use-modules (custom alias)
             (custom theme)
             (haunt builder atom)
             (haunt builder assets)
             (haunt builder blog)
             (haunt html)
             (haunt page)
             (haunt post)
             (haunt reader)
             (haunt site)
             (sxml simple)
             (srfi srfi-19)
             (srfi srfi-26)
             (ice-9 match))

(define (static-page title file-name body)
  (lambda (site posts)
    (make-page file-name
               (with-layout jakob-theme site title body)
               sxml->html)))

(define about-page
  (static-page
   "About Me"
   "about.html"
   `((h2 "Hi."))))

(define projects-page
  (static-page
   "Projects"
   "projects.html"
   `((h1 "Projects"))))

;; Replace Haunt's default 'string->date* function with one that recognizes the
;; date format that Org uses.
(define (org-string->date str)
  "Convert STR, a string in Org format, into a SRFI-19 date object."
  (string->date str "<~Y-~m-~d ~a>"))

(register-metadata-parser! 'date org-string->date)

(define (read-html-post-prime port)
  (values (read-metadata-headers port)
          (let loop ((ret '()))
            (catch 'parser-error
              (lambda ()
                (match (xml->sxml port)
                  (('*TOP* sxml) (loop (cons sxml ret)))))
              (lambda (key . parameters)
                (reverse ret))))))

(define html-reader-prime
  (make-reader (make-file-extension-matcher "html")
               (cut call-with-input-file <> read-html-post-prime)))

(define %collections
  `(("Recent Posts" "index.html" ,posts/reverse-chronological)))

(define %aliases
  '(("blog/post/Bad BEHAVIOR" . "/reverse-engineering-babbys-first-archive-format.html")))

(site #:title "Jakob's Personal Webpage"
      #:domain "jakob.space"
      #:default-metadata
      '((author . "Jakob L. Kreuze")
        (email  . "zerodaysfordays@sdf.lonestar.org"))
      #:readers (list html-reader-prime)
      #:builders (list (blog #:theme jakob-theme #:collections %collections)
                       (article-aliases %aliases)
                       (atom-feed)
                       about-page
                       projects-page
                       (static-directory "css")
                       (static-directory "fonts")
                       (static-directory "images")
                       (lambda (site posts)
                         (map (lambda (alist)

© 2015 - 2026 Jakob L. Kreuze