blog: Make a drafts page
authorLucian Mogosanu <lucian.mogosanu@gmail.com>
Mon, 18 Feb 2019 20:17:19 +0000 (22:17 +0200)
committerLucian Mogosanu <lucian.mogosanu@gmail.com>
Mon, 18 Feb 2019 20:17:19 +0000 (22:17 +0200)
blog.lisp
templates/drafts.lisp [new file with mode: 0644]

index 71b9f98..cd64966 100644 (file)
--- a/blog.lisp
+++ b/blog.lisp
@@ -39,6 +39,7 @@
 (load (concatenate 'string *lbs-base* "templates/post.lisp"))
 (load (concatenate 'string *lbs-base* "templates/index.lisp"))
 (load (concatenate 'string *lbs-base* "templates/archive.lisp"))
+(load (concatenate 'string *lbs-base* "templates/drafts.lisp"))
 (load (concatenate 'string *lbs-base* "templates/rss.lisp"))
 
 ;; TLBS functions
              (in-path (gethash "in-path" blist))
              (out-path (gethash "out-path" blist)))
         ;; process tags
-        (tlbs-make-tagids blist)
+        (when (not draft) (tlbs-make-tagids blist))
         (when (file-modified in-path out-path)
             (format t "[proc] ~s~%" x)
             ;; markdown -> html
                       (make-pathname :name "archive" :type "html"))
                      (tlbs-make-archive)))
 
+(defun tlbs-process-drafts-page ()
+  (tlbs-process-page (merge-pathnames
+                      (pathname *lbs-site*)
+                      (make-pathname :name "drafts" :type "html"))
+                     (tlbs-make-drafts-page)))
+
 (defun tlbs-process-index ()
   (tlbs-process-page (merge-pathnames
                       (pathname *lbs-site*)
     (tlbs-process-markdown-page page))
   ; archive
   (tlbs-process-archive)
+  ; drafts page
+  (tlbs-process-drafts-page)
   ; index
   (tlbs-process-index))
 
   (tlbs-process-index))
 
 (defun tlbs-deploy-site ()
-  (uiop:run-program (format nil "rsync -avz --exclude 'drafts/' -e '~a' ~a/* ~a"
+  (uiop:run-program (format nil "rsync -avz ~a -e '~a' ~a/* ~a"
+                            "--exclude 'drafts/' --exclude drafts.html"
                             "ssh -p 2200"
                             *lbs-site*
                             "mogosanu.ro:/virtual/sites/thetarpit.org")
diff --git a/templates/drafts.lisp b/templates/drafts.lisp
new file mode 100644 (file)
index 0000000..d173d70
--- /dev/null
@@ -0,0 +1,20 @@
+;; Tarpit Lisp Blog Scaffolding -- drafts template
+;;
+;; TODO: Make a macro to obtain general forms such as the ones below
+
+;; This uses some of the generic functionality from archive.lisp
+
+(defun tlbs-out-drafts (output-stream)
+  (cl-who:with-html-output (output-stream nil :indent nil)
+    (:h2 "Drafts from The Tar Pit")
+    (make-post-list *drafts*))
+  nil)
+
+(defun tlbs-make-drafts-page ()
+  (let ((str-out (make-string-output-stream))
+        (blist (make-hash-table :test 'equal)))
+    (tlbs-out-drafts str-out)
+    (setf (gethash "title" blist) "Drafts")
+    (setf (gethash "body" blist) (get-output-stream-string str-out))
+    (setf (gethash "uri" blist) #p"/drafts.html")
+    blist))