]> git.jsancho.org Git - blog.git/blob - haunt.scm
Link to spanish version
[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 (get-tags post)
25   (or (assoc-ref (post-metadata post) 'tags) '()))
26
27 (define (post-date-and-tags date tags)
28   (let ((div `(div (@ (class "date-and-tags"))
29                    (time (@ (datetime ,(date->string date "~Y-~m-~dT~H:~M:~S")))
30                          ,(date->string date "~Y-~m-~d")))))
31     (cond ((> (length tags) 0)
32            (append div
33                    `(" "
34                      (span (@ (style "margin: 0 3px")) ⦿)
35                      (span (@ (class "tags"))
36                            ,@(map (lambda (tag)
37                                     `((a (@ (href ,(format #f "tags/~a.html" tag))) ,tag) " "))
38                                   tags)))))
39           (else
40            div))))
41
42 (define flex-theme
43   (theme #:name "Flex"
44          #:layout
45          (lambda (site title body)
46            `((doctype "html")
47              (html
48               (head
49                (meta (@ (charset "utf-8")))
50                (title ,(string-append title " - " (site-title site)))
51                (link (@ (rel "stylesheet") (href "https://fonts.googleapis.com/css?family=Merriweather+Sans:400,300,300italic,400italic,700,700italic,800,800italic|Merriweather:400,300,300italic,400italic,700,700italic,900,900italic|Source+Code+Pro:200,300,400,500,600,700,900")))
52                ,(stylesheet "application.min")
53                ,(stylesheet "pygments.min")
54                ,(stylesheet "custom")
55                (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0"))))
56               (body
57                ,(let ((metadata (site-default-metadata site)))
58                   `(div (@ (id "page-content"))
59                         (header
60                          (nav (@ (role "navigation") (class "navigation-bar"))
61                               (ul (@ (class "navigation-items left"))
62                                   (li (@ (id "blog-title-header"))
63                                       (a (@ (href "index.html"))
64                                          (h1 ,(assoc-ref metadata 'author)))))
65                               (ul (@ (class "navigation-items center"))
66                                   (li (a (@ (href "https://jsancho.org/")) "in spanish")))
67                               (ul (@ (class "navigation-items right"))
68                                   ,@(map (lambda (page)
69                                            `(li (a (@ (href ,(cdr page))) ,(car page))))
70                                          (assoc-ref metadata 'pages)))))
71                         (section (@ (role "main"))
72                                  (div (@ (class "content") (class "col-md-12")) ,body))))))))
73
74          #:post-template
75          (lambda (post)
76            `((article (@ (class "inline"))
77                       (header
78                        (h1 (@ (class "title")) ,(post-ref post 'title))
79                        ,(post-date-and-tags (post-date post) (get-tags post)))
80                       ,(post-sxml post))))
81
82          #:collection-template
83          (lambda (site title posts prefix)
84            (define (post-uri post)
85              (string-append (or prefix "")
86                             (site-post-slug site post) ".html"))
87
88            (define (get-paragraphs sxml count)
89              (let ((pars (filter
90                           (lambda (e) (and (pair? e) (eq? (car e) 'p)))
91                           sxml)))
92                (list-head pars (min count (length pars)))))
93                      
94            (define (post-summary post)
95              (or (post-ref post 'summary)
96                  (get-paragraphs (cdr (post-sxml post)) 3)))
97
98            `(
99              ,@(map (lambda (post)
100                       `(article (@ (class "inline"))
101                                 (header
102                                  (h2 (@ (class "title"))
103                                      (a (@ (href ,(post-uri post)))
104                                         ,(post-ref post 'title)))
105                                  ,(post-date-and-tags (post-date post) (get-tags post)))
106                                 ,(post-summary post)
107                                 (footer (@ (class "read-more"))
108                                            (a (@ (href ,(post-uri post))) "...read more..."))))
109                     (posts/reverse-chronological posts))))))
110
111 (define about-page
112   (static-page
113    "About me"
114    "about.html"
115    `((div
116       (article
117        (header (h2 "About me"))
118        (img (@ (src "images/jsancho.jpg") (width "150") (height "150") (align "left") (style "margin: 10px;")))
119        (p "My name is Javier Sancho, and I am a programmer and a free software evangelist. I live in Castellón, Spain.")
120        (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.")
121        (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.")
122        (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.")
123        (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.")
124        (p "Besides this blog, sometimes I share thoughts in " (a (@ (href "https://twitter.com/jsancho_gpl")) "Twitter") ". You can email me at " (a (@ (href "mailto:jsf@jsancho.org")) "jsf@jsancho.org") "."))))))
125
126 (define %collections
127   `(("Home" "index.html" ,posts/reverse-chronological)))
128
129 (site #:title "Javier Sancho"
130       #:domain "jsancho.org"
131       #:default-metadata
132       '((author . "Javier Sancho")
133         (description . "Free Software Evangelist - Programmer")
134         (email . "jsf@jsancho.org")
135         (picture . "images/jsancho.jpg")
136         (pages . (("projects" . "http://git.jsancho.org/")
137                   ("about me" . "about.html"))))
138       #:readers (list sxml-reader html-reader)
139       #:builders (list (blog #:theme flex-theme #:collections %collections)
140                        (atom-feed)
141                        (atom-feeds-by-tag)
142                        about-page
143                        (static-directory "images")
144                        (static-directory "fonts")
145                        (static-directory "css")))