]> git.jsancho.org Git - blog.git/blob - haunt.scm
Merge branch 'master' into spanish
[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                            ,@(drop-right
37                               (apply
38                                append
39                                (map (lambda (tag)
40                                       `((a (@ (href ,(format #f "tags/~a.html" tag))) ,tag) ", "))
41                                     tags))
42                               1)))))
43           (else
44            div))))
45
46 (define flex-theme
47   (theme #:name "Flex"
48          #:layout
49          (lambda (site title body)
50            `((doctype "html")
51              (html
52               (head
53                (meta (@ (charset "utf-8")))
54                (title ,(string-append title " - " (site-title site)))
55                (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")))
56                ,(stylesheet "application.min")
57                ,(stylesheet "pygments.min")
58                ,(stylesheet "custom")
59                (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0"))))
60               (body
61                ,(let ((metadata (site-default-metadata site)))
62                   `(div (@ (id "page-content"))
63                         (header
64                          (nav (@ (role "navigation") (class "navigation-bar"))
65                               (ul (@ (class "navigation-items left"))
66                                   (li (@ (id "blog-title-header"))
67                                       (a (@ (href "index.html"))
68                                          (h1 ,(assoc-ref metadata 'author)))))
69                               (ul (@ (class "navigation-items center"))
70                                   (li (a (@ (href "https://en.jsancho.org/")) "in english")))
71                               (ul (@ (class "navigation-items right"))
72                                   ,@(map (lambda (page)
73                                            `(li (a (@ (href ,(cdr page))) ,(car page))))
74                                          (assoc-ref metadata 'pages)))))
75                         (section (@ (role "main"))
76                                  (div (@ (class "content") (class "col-md-12")) ,body))))))))
77
78          #:post-template
79          (lambda (post)
80            `((article (@ (class "inline"))
81                       (header
82                        (h1 (@ (class "title")) ,(post-ref post 'title))
83                        ,(post-date-and-tags (post-date post) (get-tags post)))
84                       ,(post-sxml post))))
85
86          #:collection-template
87          (lambda (site title posts prefix)
88            (define (post-uri post)
89              (string-append (or prefix "")
90                             (site-post-slug site post) ".html"))
91
92            (define (get-paragraphs sxml count)
93              (define (getp sxml count res)
94                (cond ((or (= count 0) (null? sxml))
95                       res)
96                      ((and (pair? (car sxml)) (eq? (caar sxml) 'p))
97                       (getp (cdr sxml) (- count 1) (cons (car sxml) res)))
98                      ((and (pair? (car sxml)) (eq? (caar sxml) 'a))
99                       (getp (cdr sxml) count (cons (car sxml) res)))
100                      (else
101                       (getp (cdr sxml) count res))))
102              (reverse (getp sxml count '())))
103                      
104            (define (post-summary post)
105              (or (post-ref post 'summary)
106                  (get-paragraphs (cdr (post-sxml post)) 3)))
107
108            `(
109              ,@(map (lambda (post)
110                       `(article (@ (class "inline"))
111                                 (header
112                                  (h2 (@ (class "title"))
113                                      (a (@ (href ,(post-uri post)))
114                                         ,(post-ref post 'title)))
115                                  ,(post-date-and-tags (post-date post) (get-tags post)))
116                                 ,(post-summary post)
117                                 (footer (@ (class "read-more"))
118                                            (a (@ (href ,(post-uri post))) "...seguir leyendo..."))))
119                     (posts/reverse-chronological posts))))))
120
121 (define about-page
122   (static-page
123    "Sobre mi"
124    "about.html"
125    `((div
126       (article
127        (header (h2 "Sobre mi"))
128        (img (@ (src "images/jsancho.jpg") (width "150") (height "150") (align "left") (style "margin: 10px;")))
129        (p "Me llamo Javier Sancho y soy programador y defensor del software libre. Vivo en Castellón, España.")
130        (p "Conocí GNU/Linux y el software libre durante mis estudios universitarios en la " (a (@ (href "http://www.uji.es/")) "Universitat Jaume I") " y desde entonces mi compromiso con esas ideas ha ido en aumento.")
131        (p "Fue en 2003 cuando empecé como activista, participando en eventos relacionados con el software libre, manifestaciones en contra de las patentes de software, charlas y jornadas informativas en parties, institutos, etc.")
132        (p "Disfruto programando y lo hago con el lenguaje que más se ajuste a mis necesidades (Python, PHP, Golang, Erlang, ...). Durante muchos años mi lenguaje favorito fue C, aunque con el tiempo ese lugar privilegiado han pasado a ocuparlo Lisp y Scheme a partes iguales. Soy un enamorado del paradigma funcional.")
133        (p "Estoy casado con una mujer maravillosa y tengo un hijo que no deja de sorprenderme cada día. Son mi mayor alegría.")
134        (p "Aparte de este blog, a veces comparto pensamientos en " (a (@ (href "https://twitter.com/jsancho_gpl")) "Twitter") ". Puedes contactar conmigo en " (a (@ (href "mailto:jsf@jsancho.org")) "jsf@jsancho.org") "."))))))
135
136 (define %collections
137   `(("Home" "index.html" ,posts/reverse-chronological)))
138
139 (site #:title "Javier Sancho"
140       #:domain "jsancho.org"
141       #:build-directory "site-spanish"
142       #:default-metadata
143       '((author . "Javier Sancho")
144         (description . "Evangelizador del software libre - Programador")
145         (email . "jsf@jsancho.org")
146         (picture . "images/jsancho.jpg")
147         (pages . (("proyectos" . "http://git.jsancho.org/")
148                   ("sobre mi" . "about.html"))))
149       #:readers (list sxml-reader html-reader)
150       #:builders (list (blog #:theme flex-theme #:collections %collections)
151                        (atom-feed)
152                        (atom-feeds-by-tag)
153                        about-page
154                        (static-directory "images")
155                        (static-directory "fonts")
156                        (static-directory "css")))