]> 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                            ,@(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                               (ul (@ (class "navigation-items right"))
67                                   ,@(map (lambda (page)
68                                            `(li (a (@ (href ,(cdr page))) ,(car page))))
69                                          (assoc-ref metadata 'pages)))))
70                         (section (@ (role "main"))
71                                  (div (@ (class "content") (class "col-md-12")) ,body))))))))
72
73          #:post-template
74          (lambda (post)
75            `((article (@ (class "inline"))
76                       (header
77                        (h1 (@ (class "title")) ,(post-ref post 'title))
78                        ,(post-date-and-tags (post-date post) (get-tags post)))
79                       ,(post-sxml post))))
80
81          #:collection-template
82          (lambda (site title posts prefix)
83            (define (post-uri post)
84              (string-append (or prefix "")
85                             (site-post-slug site post) ".html"))
86
87            (define (get-paragraphs sxml count)
88              (let ((pars (filter
89                           (lambda (e) (and (pair? e) (eq? (car e) 'p)))
90                           sxml)))
91                (list-head pars (min count (length pars)))))
92                      
93            (define (post-summary post)
94              (or (post-ref post 'summary)
95                  (get-paragraphs (cdr (post-sxml post)) 3)))
96
97            `(
98              ,@(map (lambda (post)
99                       `(article (@ (class "inline"))
100                                 (header
101                                  (h2 (@ (class "title"))
102                                      (a (@ (href ,(post-uri post)))
103                                         ,(post-ref post 'title)))
104                                  ,(post-date-and-tags (post-date post) (get-tags post)))
105                                 ,(post-summary post)
106                                 (footer (@ (class "read-more"))
107                                            (a (@ (href ,(post-uri post))) "...seguir leyendo..."))))
108                     (posts/reverse-chronological posts))))))
109
110 (define about-page
111   (static-page
112    "Sobre mi"
113    "about.html"
114    `((div
115       (article
116        (header (h2 "Sobre mi"))
117        (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.")
118        (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.")
119        (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.")
120        (p "Estoy casado con una mujer maravillosa y tengo un hijo que no deja de sorprenderme cada día. Son mi mayor alegría."))))))
121
122 (define %collections
123   `(("Home" "index.html" ,posts/reverse-chronological)))
124
125 (site #:title "Javier Sancho"
126       #:domain "jsancho.org"
127       #:build-directory "site-spanish"
128       #:default-metadata
129       '((author . "Javier Sancho")
130         (description . "Evangelizador del software libre - Programador")
131         (email . "jsf@jsancho.org")
132         (picture . "images/jsancho.jpg")
133         (pages . (("proyectos" . "http://git.jsancho.org/")
134                   ("sobre mi" . "about.html"))))
135       #:readers (list sxml-reader html-reader)
136       #:builders (list (blog #:theme flex-theme #:collections %collections)
137                        (atom-feed)
138                        (atom-feeds-by-tag)
139                        about-page
140                        (static-directory "images")
141                        (static-directory "fonts")
142                        (static-directory "css")))