about summary refs log tree commit diff
path: root/blog/src
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2020-01-31T16·13+0000
committerWilliam Carroll <wpcarro@gmail.com>2020-01-31T16·13+0000
commit265d2029088a1f49c5716bcb3d96f71dd0845d7e (patch)
tree65122f462dcf7ba51a9c14236d6decfeadda25d0 /blog/src
parent837cfe07c76df5e464e3cfc7e9a1f0e64a91c4b5 (diff)
Render pandoc output to index.html
Using index.html allows us to use the Google AdSense script and extend the
styling by adding a CSS stylesheet.
Diffstat (limited to 'blog/src')
-rw-r--r--blog/src/index.html8
-rw-r--r--blog/src/server.lisp21
2 files changed, 16 insertions, 13 deletions
diff --git a/blog/src/index.html b/blog/src/index.html
index a9d9cf7eaa25..2ea07d35ade6 100644
--- a/blog/src/index.html
+++ b/blog/src/index.html
@@ -3,14 +3,12 @@
   <head>
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1" />
-    <meta name="description" content="Showcase of AI bots at DeepMind" />
-    <link rel="stylesheet" href="/index.css">
-    <title>AI Showcase</title>
+    <meta name="description" content="wpcarro.dev | blog" />
+    <title>wpcarro.dev | blog</title>
     <script data-ad-client="ca-pub-6018268443649487" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
   </head>
   <body>
     <noscript>You need to enable JavaScript to run this app.</noscript>
-    <h1>Welcome</h1>
-    <p>To my blog!</p>
+    {{ blog }}
   </body>
 </html>
diff --git a/blog/src/server.lisp b/blog/src/server.lisp
index ad8169fa1af9..d2633a2dbd7b 100644
--- a/blog/src/server.lisp
+++ b/blog/src/server.lisp
@@ -2,6 +2,7 @@
 (defpackage #:server
   (:documentation "Robot condemned to a life of admin work for my blog.")
   (:use #:cl)
+  (:use #:cl-ppcre)
   (:import-from #:cl-arrows #:->>)
   (:export :main))
 (in-package #:server)
@@ -10,25 +11,29 @@
 ;; Nix-injected dependencies
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-;; TODO: Wrap this in an assert or ensure that there's a trailing slash so it's
-;; treated as a directory.
 (defvar *path-to-posts* "/tmp/"
   "File path pointing to the posts directory.")
 
 (defvar *pandoc-bin* "/usr/bin/pandoc")
 
+(defvar *html-template* "./index.html"
+  "The path to the HTML template used for the blog posts.")
+
+(defvar *posts* (uiop:directory-files *path-to-posts*)
+  "List of the paths to the blog posts.")
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Library
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
+;; TODO: Support properly indenting the output from pandoc to nest within the
+;; template. Or just use a proper templating library.
 (defun render-post (path)
   "Render the markdown file stored at PATH to HTML using pandoc."
-  (uiop:run-program (list *pandoc-bin* path "--to" "html")
-                    :output :string))
-
-;; TODO: Figure out how to handle this with Nix.
-(defvar *posts* (uiop:directory-files *path-to-posts*)
-  "List of the paths to the blog posts.")
+  (cl-ppcre:regex-replace-all
+   "{{ blog }}"
+   (uiop:read-file-string *html-template*)
+   (uiop:run-program (list *pandoc-bin* path "--to" "html") :output :string)))
 
 (hunchentoot:define-easy-handler
     (get-latest :uri "/latest") ()