]> git.jsancho.org Git - blog.git/blobdiff - haunt.scm
Fix issue reading posts body with Haunt 0.2.5
[blog.git] / haunt.scm
index a7dfad07b15b10b5a05393e0f5e05da1255ea92e..89b8e7edd2ab4336fd4aa0abf934837c900da218 100644 (file)
--- a/haunt.scm
+++ b/haunt.scm
               (with-layout flex-theme site title body)
               sxml->html)))
 
+(define (get-tags post)
+  (or (assoc-ref (post-metadata post) 'tags) '()))
+
+(define (post-date-and-tags date tags)
+  (let ((div `(div (@ (class "date-and-tags"))
+                  (time (@ (datetime ,(date->string date "~Y-~m-~dT~H:~M:~S")))
+                        ,(date->string date "~Y-~m-~d")))))
+    (cond ((> (length tags) 0)
+          (append div
+                  `(" "
+                    (span (@ (style "margin: 0 3px")) ⦿)
+                    (span (@ (class "tags"))
+                          ,@(drop-right
+                              (apply
+                               append
+                               (map (lambda (tag)
+                                      `((a (@ (href ,(format #f "tags/~a.html" tag))) ,tag) ", "))
+                                    tags))
+                              1)))))
+         (else
+          div))))
+
 (define flex-theme
   (theme #:name "Flex"
          #:layout
               (head
                (meta (@ (charset "utf-8")))
                (title ,(string-append title " - " (site-title site)))
-               (link (@ (rel "stylesheet") (href "//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic")))
-               ,(stylesheet "style.min")
-               ,(stylesheet "monokai.min")
-               ,(stylesheet "font-awesome.min")
+               (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")))
+               ,(stylesheet "application.min")
+               ,(stylesheet "pygments.min")
                ,(stylesheet "custom")
                (meta (@ (name "viewport") (content "width=device-width, initial-scale=1.0"))))
               (body
                ,(let ((metadata (site-default-metadata site)))
-                  `(aside
-                    (div
-                     (a (@ (href "index.html")) (img (@ (src ,(assoc-ref metadata 'picture)))))
-                     (h1 (a (@ (href "index.html")) ,(assoc-ref metadata 'author)))
-                     (p ,(assoc-ref metadata 'description))
-                     (nav
-                      (ul (@ (class "list"))
-                          ,@(map (lambda (page)
-                                   `(li (a (@ (href ,(cdr page))) ,(car page))))
-                                 (assoc-ref metadata 'pages))))
-                     (ul (@ (class "social"))
-                         (li (a (@ (class "sc-twitter") (target "_blank") (href "https://twitter.com/jsancho_gpl")) (i (@ (class "fa fa-twitter")))))
-                         " "
-                         (li (a (@ (class "sc-rss") (target "_blank") (href "feed.xml")) (i (@ (class "fa fa-rss")))))))))
-               (main ,body)))))
+                  `(div (@ (id "page-content"))
+                       (header
+                        (nav (@ (role "navigation") (class "navigation-bar"))
+                             (ul (@ (class "navigation-items left"))
+                                 (li (@ (id "blog-title-header"))
+                                     (a (@ (href "index.html"))
+                                        (h1 ,(assoc-ref metadata 'author)))))
+                             (ul (@ (class "navigation-items center")))
+                             (ul (@ (class "navigation-items right"))
+                                 ,@(map (lambda (page)
+                                          `(li (a (@ (href ,(cdr page))) ,(car page))))
+                                        (assoc-ref metadata 'pages)))))
+                       (section (@ (role "main"))
+                                (div (@ (class "content") (class "col-md-12")) ,body))))))))
 
         #:post-template
         (lambda (post)
-          (define (get-tags post)
-            (or (assoc-ref (post-metadata post) 'tags) '()))
-
-          `((article (@ (class "single"))
+          `((article (@ (class "inline"))
                      (header
-                      (h1 ,(post-ref post 'title))
-                      (p "Posted on " ,(date->string (post-date post) "~B ~d, ~Y")))
-                     ,(post-sxml post)
-                     (div (@ (class "tag-cloud"))
-                          (p
-                           ,@(map (lambda (tag)
-                                    `((a (@ (href "")) ,tag) " "))
-                                  (get-tags post)))))))
+                      (h1 (@ (class "title")) ,(post-ref post 'title))
+                      ,(post-date-and-tags (post-date post) (get-tags post)))
+                     ,(post-sxml post))))
 
          #:collection-template
          (lambda (site title posts prefix)
                             (site-post-slug site post) ".html"))
 
           (define (get-paragraphs sxml count)
-            (let ((pars (filter
-                         (lambda (e) (and (pair? e) (eq? (car e) 'p)))
-                         sxml)))
-              (list-head pars (min count (length pars)))))
+             (define (getp sxml count res)
+               (cond ((or (= count 0) (null? sxml))
+                      res)
+                     ((and (pair? (car sxml)) (eq? (caar sxml) 'p))
+                      (getp (cdr sxml) (- count 1) (cons (car sxml) res)))
+                     (else
+                      (getp (cdr sxml) count (cons (car sxml) res)))))
+             (reverse (getp sxml count '())))
                     
            (define (post-summary post)
              (or (post-ref post 'summary)
-                (get-paragraphs (cdr (post-sxml post)) 3)))
+                (get-paragraphs (cdar (post-sxml post)) 3)))
 
            `(
             ,@(map (lambda (post)
-                     `(article
-                       (header
-                        (h2
-                         (a (@ (href ,(post-uri post)))
-                            ,(post-ref post 'title)))
-                        (p "Posted on " ,(date->string (post-date post) "~B ~d, ~Y")))
-                       (div ,(post-summary post)
-                            (br)
-                            (a (@ (class "btn") (href ,(post-uri post))) " Continue reading "))
-                       (hr)))
+                     `(article (@ (class "inline"))
+                               (header
+                                (h2 (@ (class "title"))
+                                    (a (@ (href ,(post-uri post)))
+                                       ,(post-ref post 'title)))
+                                ,(post-date-and-tags (post-date post) (get-tags post)))
+                               ,(post-summary post)
+                               (footer (@ (class "read-more"))
+                                          (a (@ (href ,(post-uri post))) "...read more..."))))
                    (posts/reverse-chronological posts))))))
 
 (define about-page
         (description . "Free Software Evangelist - Programmer")
         (email . "jsf@jsancho.org")
         (picture . "images/jsancho.jpg")
-        (pages . (("about" . "about.html")
-                  ("projects" . "http://git.jsancho.org/"))))
+        (pages . (("projects" . "http://git.jsancho.org/")
+                 ("about me" . "about.html"))))
       #:readers (list sxml-reader html-reader)
       #:builders (list (blog #:theme flex-theme #:collections %collections)
                        (atom-feed)