haunt.scm 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ;;; Test site
  2. (use-modules (ice-9 match)
  3. (srfi srfi-19)
  4. (srfi srfi-26)
  5. (haunt asset)
  6. (haunt site)
  7. (haunt page)
  8. (haunt post)
  9. (haunt html)
  10. (haunt utils)
  11. (haunt builder blog)
  12. (haunt builder atom)
  13. (haunt builder assets)
  14. (haunt reader)
  15. (haunt reader skribe)
  16. (syntax-highlight)
  17. (syntax-highlight scheme))
  18. ;;; Utilities
  19. (define %site-prefix (make-parameter ""))
  20. (define (prefix-url url)
  21. (string-append (%site-prefix) url))
  22. ;;; Templates
  23. (define (stylesheet name)
  24. `(link (@ (rel "stylesheet")
  25. (href ,(prefix-url (string-append "/css/" name ".css"))))))
  26. (define (base-image image alt)
  27. `(img (@ (src ,(prefix-url (string-append "/images/" image)))
  28. (alt ,alt))))
  29. (define* (base-layout site body #:key title)
  30. `((doctype "html")
  31. (head
  32. (meta (@ (charset "utf-8")))
  33. (title ,(if title title
  34. (site-title site))))
  35. ;; css
  36. (link (@ (rel "stylesheet")
  37. (href ,(prefix-url "/css/main.css"))))
  38. (link (@ (rel "stylesheet")
  39. (href ,(prefix-url "/css/code.css"))))
  40. (body
  41. (div (@ (class "main-wrapper"))
  42. (div (@ (class "site-main-content"))
  43. ,body))
  44. (div (@ (class "footer"))
  45. (a (@ (href "https://notabug.org/sapientech/stlog"))
  46. "Site contents")
  47. " dual licensed under "
  48. (a (@ (href "https://creativecommons.org/licenses/by-sa/4.0/"))
  49. "Creative Commons 4.0 International")
  50. " and "
  51. (a (@ (href "http://www.gnu.org/licenses/gpl-3.0.en.html"))
  52. "the GNU GPL, version 3 or any later version")
  53. ". Images by "
  54. (a (@ (href "https://snapjudgemints.wordpress.com/"))
  55. "tea4tori")
  56. ", Powered by "
  57. (a (@ (href "http://haunt.dthompson.us/"))
  58. "Haunt")
  59. "."))))
  60. (define (banner-content)
  61. `(div (@ (class "banner-wrapper"))
  62. (center (a (@ (href ,(prefix-url "/"))
  63. (class "stlog-banner"))
  64. ,(base-image "banner.png"
  65. "stlog banner")))))
  66. (define (post-template post)
  67. `((a (@(href ,(prefix-url "/"))) "top")
  68. (center (h2 ,(post-ref post 'title)))
  69. (center (h4 ,(date->string* (post-date post))))
  70. (div ,(post-sxml post))))
  71. (define (collection-template site title posts prefix)
  72. (define (post-uri post)
  73. (string-append (or prefix "") "/"
  74. (site-post-slug site post) ".html"))
  75. `(,(banner-content)
  76. (div (@ (class "posts-header"))
  77. (h1 "Recent posts:"))
  78. (ul
  79. ,@(map (lambda (post)
  80. `(li
  81. (a (@ (href ,(post-uri post)))
  82. ,(post-ref post 'title)
  83. " — "
  84. ,(date->string* (post-date post)))))
  85. posts))))
  86. (define stlog-theme
  87. (theme #:name "stlog"
  88. #:layout
  89. (lambda (site title body)
  90. (base-layout site body
  91. #:title "stlog"))
  92. #:post-template post-template
  93. #:collection-template collection-template))
  94. (site #:title "stlog"
  95. #:domain "stlog.sapientech.guile.cc"
  96. #:default-metadata
  97. '((author . "Dylan Jeffers")
  98. (email . "sapientech@openmailbox.org"))
  99. #:readers (list (make-skribe-reader
  100. #:modules '((haunt skribe utils)
  101. (skribe-utils))))
  102. #:builders (list (blog #:theme stlog-theme)
  103. (atom-feed)
  104. (atom-feeds-by-tag)
  105. (static-directory "static/images" "images")
  106. (static-directory "static/css" "css")))