]> git.jsancho.org Git - blog.git/blob - haunt.scm
04bada489e51b58ffe5890f08a236a0bb8612dc8
[blog.git] / haunt.scm
1 (use-modules (haunt asset)
2              (haunt builder blog)
3              (haunt builder atom)
4              (haunt builder assets)
5              (haunt reader)
6              (haunt reader texinfo)
7              (haunt site)
8              (haunt post)
9              (srfi srfi-1)
10              (srfi srfi-19))
11
12 (define (stylesheet name)
13   `(link (@ (rel "stylesheet")
14             (href ,(string-append "css/" name ".css")))))
15
16 (define flex-theme
17   (theme #:name "Flex"
18          #:layout
19          (lambda (site title body)
20            `((doctype "html")
21              (html
22               (head
23                (meta (@ (charset "utf-8")))
24                (title ,(string-append title " - " (site-title site)))
25                (link (@ (rel "stylesheet") (href "//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic")))
26                ,(stylesheet "style.min")
27                ,(stylesheet "monokai.min")
28                ,(stylesheet "font-awesome.min")
29                ,(stylesheet "custom")
30                (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0"))))
31               (body
32                ,(let ((metadata (site-default-metadata site)))
33                   `(aside
34                     (div
35                      (a (@ (href "index.html")) (img (@ (src ,(assoc-ref metadata 'picture)))))
36                      (h1 (a (@ (href "index.html")) ,(assoc-ref metadata 'author)))
37                      (p ,(assoc-ref metadata 'description))
38                      (nav
39                       (ul (@ (class "list"))
40                           ,@(map (lambda (page)
41                                    `(li (a (@ (href ,(cdr page))) ,(car page))))
42                                  (assoc-ref metadata 'pages))))
43                      (ul (@ (class "social"))
44                          (li (a (@ (class "sc-linkedin") (target "_blank") (href "")) (i (@ (class "fa fa-linkedin")))))
45                          " "
46                          (li (a (@ (class "sc-github") (target "_blank") (href "")) (i (@ (class "fa fa-github")))))
47                          " "
48                          (li (a (@ (class "sc-twitter") (target "_blank") (href "")) (i (@ (class "fa fa-twitter")))))
49                          " "
50                          (li (a (@ (class "sc-rss") (target "_blank") (href "feed.xml")) (i (@ (class "fa fa-rss")))))))))
51                (main ,body)))))
52
53          #:post-template
54          (lambda (post)
55            (define (get-tags post)
56              (or (assoc-ref (post-metadata post) 'tags) '()))
57
58            `((article (@ (class "single"))
59                       (header
60                        (h1 ,(post-ref post 'title))
61                        (p "Posted on " ,(date->string (post-date post) "~B ~d, ~Y")))
62                       ,(post-sxml post)
63                       (div (@ (class "tag-cloud"))
64                            (p
65                             ,@(map (lambda (tag)
66                                      `((a (@ (href "")) ,tag) " "))
67                                    (get-tags post)))))))
68
69          #:collection-template
70          (lambda (site title posts prefix)
71            (define (post-uri post)
72              (string-append (or prefix "")
73                             (site-post-slug site post) ".html"))
74
75            (define (get-paragraphs sxml count)
76              (let ((pars (filter
77                           (lambda (e) (and (pair? e) (eq? (car e) 'p)))
78                           sxml)))
79                (list-head pars (min count (length pars)))))
80                      
81            (define (post-summary post)
82              (or (post-ref post 'summary)
83                  (get-paragraphs (cdr (post-sxml post)) 3)))
84
85            `(
86              ,@(map (lambda (post)
87                       `(article
88                         (header
89                          (h2
90                           (a (@ (href ,(post-uri post)))
91                              ,(post-ref post 'title)))
92                          (p "Posted on " ,(date->string (post-date post) "~B ~d, ~Y")))
93                         (div ,(post-summary post)
94                              (br)
95                              (a (@ (class "btn") (href ,(post-uri post))) " Continue reading "))
96                         (hr)))
97                     (posts/reverse-chronological posts))))))
98
99 (define %collections
100   `(("Home" "index.html" ,posts/reverse-chronological)))
101
102 (site #:title "Javier Sancho"
103       #:domain "jsancho.org"
104       #:default-metadata
105       '((author . "Javier Sancho")
106         (description . "Free Software Evangelist - Programmer")
107         (email . "jsf@jsancho.org")
108         (picture . "images/jsancho.jpg")
109         (pages . (("about" . "about.html")
110                   ("projects" . "http://git.jsancho.org/"))))
111       #:readers (list sxml-reader html-reader)
112       #:builders (list (blog #:theme flex-theme #:collections %collections)
113                        (atom-feed)
114                        (atom-feeds-by-tag)
115                        (static-directory "images")
116                        (static-directory "fonts")
117                        (static-directory "css")))