]> git.jsancho.org Git - blog.git/blob - haunt.scm
Merge branch 'master' into english
[blog.git] / haunt.scm
1 (use-modules (haunt asset)
2              (haunt builder blog)
3              (haunt builder atom)
4              (haunt builder assets)
5              (haunt html)
6              (haunt page)
7              (haunt reader)
8              (haunt reader texinfo)
9              (haunt site)
10              (haunt post)
11              (srfi srfi-1)
12              (srfi srfi-19))
13
14 (define (stylesheet name)
15   `(link (@ (rel "stylesheet")
16             (href ,(string-append "css/" name ".css")))))
17
18 (define (static-page title file-name body)
19   (lambda (site posts)
20     (make-page file-name
21                (with-layout flex-theme site title body)
22                sxml->html)))
23
24 (define flex-theme
25   (theme #:name "Flex"
26          #:layout
27          (lambda (site title body)
28            `((doctype "html")
29              (html
30               (head
31                (meta (@ (charset "utf-8")))
32                (title ,(string-append title " - " (site-title site)))
33                (link (@ (rel "stylesheet") (href "//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic")))
34                ,(stylesheet "style.min")
35                ,(stylesheet "monokai.min")
36                ,(stylesheet "font-awesome.min")
37                ,(stylesheet "custom")
38                (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0"))))
39               (body
40                ,(let ((metadata (site-default-metadata site)))
41                   `(aside
42                     (div
43                      (a (@ (href "index.html")) (img (@ (src ,(assoc-ref metadata 'picture)))))
44                      (h1 (a (@ (href "index.html")) ,(assoc-ref metadata 'author)))
45                      (p ,(assoc-ref metadata 'description))
46                      (nav
47                       (ul (@ (class "list"))
48                           ,@(map (lambda (page)
49                                    `(li (a (@ (href ,(cdr page))) ,(car page))))
50                                  (assoc-ref metadata 'pages))))
51                      (ul (@ (class "social"))
52                          (li (a (@ (class "sc-twitter") (target "_blank") (href "https://twitter.com/jsancho_gpl")) (i (@ (class "fa fa-twitter")))))
53                          " "
54                          (li (a (@ (class "sc-rss") (target "_blank") (href "feed.xml")) (i (@ (class "fa fa-rss")))))))))
55                (main ,body)))))
56
57          #:post-template
58          (lambda (post)
59            (define (get-tags post)
60              (or (assoc-ref (post-metadata post) 'tags) '()))
61
62            `((article (@ (class "single"))
63                       (header
64                        (h1 ,(post-ref post 'title))
65                        (p "Posted on " ,(date->string (post-date post) "~B ~d, ~Y")))
66                       ,(post-sxml post)
67                       (div (@ (class "tag-cloud"))
68                            (p
69                             ,@(map (lambda (tag)
70                                      `((a (@ (href "")) ,tag) " "))
71                                    (get-tags post)))))))
72
73          #:collection-template
74          (lambda (site title posts prefix)
75            (define (post-uri post)
76              (string-append (or prefix "")
77                             (site-post-slug site post) ".html"))
78
79            (define (get-paragraphs sxml count)
80              (let ((pars (filter
81                           (lambda (e) (and (pair? e) (eq? (car e) 'p)))
82                           sxml)))
83                (list-head pars (min count (length pars)))))
84                      
85            (define (post-summary post)
86              (or (post-ref post 'summary)
87                  (get-paragraphs (cdr (post-sxml post)) 3)))
88
89            `(
90              ,@(map (lambda (post)
91                       `(article
92                         (header
93                          (h2
94                           (a (@ (href ,(post-uri post)))
95                              ,(post-ref post 'title)))
96                          (p "Posted on " ,(date->string (post-date post) "~B ~d, ~Y")))
97                         (div ,(post-summary post)
98                              (br)
99                              (a (@ (class "btn") (href ,(post-uri post))) " Continue reading "))
100                         (hr)))
101                     (posts/reverse-chronological posts))))))
102
103 (define about-page
104   (static-page
105    "About me"
106    "about.html"
107    `((div
108       (article
109        (header (h2 "About me"))
110        (p "I met GNU/Linux and free software while I was studying Computer Science at " (a (@ (href "http://www.uji.es/")) "Universitat Jaume I") " and, since then, my commitment with these ideas hasn't stopped growing.")
111        (p "It was in 2003 when I started as an activist, participating in events related with free software, demonstrations against software patents, talks and information sessions at install parties, schools, etc.")
112        (p "I enjoy programming and I use the programming language that better fits my needs (Python, PHP, Golang, Erlang, ...). For many years my favorite language was C, although over time that privileged place has been occupied by Lisp y Scheme. I'm in love with the functional paradigm.")
113        (p "I'm married with a wonderful woman and we have a kid that amaze us every day. They are the best of my life."))))))
114
115 (define %collections
116   `(("Home" "index.html" ,posts/reverse-chronological)))
117
118 (site #:title "Javier Sancho"
119       #:domain "jsancho.org"
120       #:default-metadata
121       '((author . "Javier Sancho")
122         (description . "Free Software Evangelist - Programmer")
123         (email . "jsf@jsancho.org")
124         (picture . "images/jsancho.jpg")
125         (pages . (("about" . "about.html")
126                   ("projects" . "http://git.jsancho.org/"))))
127       #:readers (list sxml-reader html-reader)
128       #:builders (list (blog #:theme flex-theme #:collections %collections)
129                        (atom-feed)
130                        (atom-feeds-by-tag)
131                        about-page
132                        (static-directory "images")
133                        (static-directory "fonts")
134                        (static-directory "css")))