From 9c44f6e4d62339c929012be63a1e512b44e89645 Mon Sep 17 00:00:00 2001 From: Lucian Mogosanu Date: Thu, 15 Aug 2019 14:16:57 +0300 Subject: [PATCH] blog: Use double-semicolons for comments This is a purely aesthetical change, it just makes our life easier. --- blog.lisp | 95 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 48 insertions(+), 47 deletions(-) diff --git a/blog.lisp b/blog.lisp index 32acf0e..32ce8b9 100644 --- a/blog.lisp +++ b/blog.lisp @@ -38,14 +38,14 @@ (asdf:load-system :hunchentoot) (asdf:load-system :lbs-utils)) -; TLBS global variables +;; TLBS global variables (defvar *posts* nil) ; list of post blists (defvar *drafts* nil) ; list of draft post blists (defvar *pages* nil) (defvar *tags* nil) (defvar *busybox-process* nil) -; Load template definitions +;; Load template definitions (load (concatenate 'string *lbs-base* "templates/default.lisp")) (load (concatenate 'string *lbs-base* "templates/post.lisp")) (load (concatenate 'string *lbs-base* "templates/index.lisp")) @@ -59,12 +59,12 @@ (defun get-plain-text (path) (let ((blist (make-hash-table :test 'equal))) (with-open-file (stream path) - ; First read the header: ignore everything until the first line - ; with three dashes + ;; First read the header: ignore everything until the first line + ;; with three dashes (do ((line (read-line stream) (read-line stream))) ((equal line "---"))) - ; Now read variables and add them to the blist + ;; Now read variables and add them to the blist (do ((line (read-line stream) (read-line stream))) ((equal line "---")) (let ((pair (cl-ppcre:split ":\\s*" line :limit 2))) @@ -72,15 +72,15 @@ (format t "Error parsing line: ~a" line) (setf (gethash (car pair) blist) (cadr pair))))) - ; Now all that's left to read is the page body - ; - ; Note that we build a new string with the length exactly equal to - ; the file's length minus what we have read so far. + ;; Now all that's left to read is the page body + ;; + ;; Note that we build a new string with the length exactly equal to + ;; the file's length minus what we have read so far. (let ((body (make-string (file-length stream)))) (read-sequence body stream) (setf (gethash "body" blist) (string-trim '(#\Nul) body))) - ; Return the new blist + ;; Return the new blist blist))) (defun tlbs-make-blist (relative-pathname) @@ -107,7 +107,7 @@ (defun tlbs-process-posts (relative-wildcard &key (draft nil)) (format t "Processing~a posts...~%" (if draft " draft" "")) - ; clean up old posts first... + ;; clean up old posts first... (if draft (setq *drafts* nil) (setq *posts* nil @@ -145,17 +145,17 @@ (defun tlbs-process-page (out-path blist) (format t "[proc] ~s~%" out-path) - ; out path + ;; out path (setf (gethash "out-path" blist) out-path) - ; default page template + ;; default page template (tlbs-make-default blist) - ; write to file + ;; write to file (tlbs-write-blist blist) - ; erase body + ;; erase body (setf (gethash "body" blist) nil) - ; maybe add to page list - ; XXX: this should replace the old page with the new one - ; XXX: use adjoin + ;; maybe add to page list + ;; XXX: this should replace the old page with the new one + ;; XXX: use adjoin (if (not (member blist *pages* :test #'(lambda (blist1 blist2) ; XXX: should actually use postid @@ -166,9 +166,9 @@ (defun tlbs-process-markdown-page (relative-pathname) (let ((blist (tlbs-make-blist relative-pathname))) - ; markdown -> html + ;; markdown -> html (pipe-through-pandoc blist) - ; continue with normal page processing + ;; continue with normal page processing (tlbs-process-page (gethash "out-path" blist) blist))) (defun tlbs-process-archive () @@ -192,18 +192,18 @@ (defun tlbs-process-tags () (format t "Processing tags...~%") (dolist (tlist *tags*) - ; set out path + ;; set out path (setf (gethash "out-path" tlist) (concat-pathnames (pathname *lbs-site*) (gethash "uri" tlist))) (format t "[proc] ~s~%" (gethash "out-path" tlist)) - ; generate page body + ;; generate page body (tlbs-make-tag tlist) - ; apply default page template + ;; apply default page template (tlbs-make-default tlist) - ; write to file + ;; write to file (tlbs-write-blist tlist) - ; optionally, set body to nil + ;; optionally, set body to nil (setf (gethash "body" tlist) nil)) nil) @@ -221,9 +221,9 @@ :element-type element-type))))) (defun tlbs-copy-recursively (in-path out-base-dir) - ; Check if file is a directory. We assume that pathname-name returns - ; NIL in this case. - ;(format t "~s~%" (pathname-name (probe-file in-path))) + ;; Check if file is a directory. We assume that pathname-name returns + ;; NIL in this case. + ;; (format t "~s~%" (pathname-name (probe-file in-path))) (if (pathname-name (probe-file in-path)) (let* ((relative-pathname (post-relative-pathname in-path)) (out-path (concat-pathnames out-base-dir @@ -251,55 +251,56 @@ (defun tlbs-process-rss () (let ((blist (tlbs-make-rss))) - ; out path + ;; out path (setf (gethash "out-path" blist) (concat-pathnames (pathname *lbs-site*) #p"rss.xml")) - ; late processing message + ;; late processing message (format t "[proc] ~s~%" (gethash "out-path" blist)) - ; write rss + ;; write rss (tlbs-write-blist blist)) nil) (defun tlbs-process-everything () - ; posts: needed for everything, so process them first + ;; posts: needed for everything, so process them first (tlbs-process-posts "posts/**/*.markdown") - ; process drafts + ;; process drafts (tlbs-process-posts "drafts/*.markdown" :draft t) - ; tags + ;; tags (tlbs-process-tags) - ; other files + ;; other files (tlbs-process-other-files) - ; RSS + ;; RSS (tlbs-process-rss) (format t "Processing everything else...~%") - ; markdown pages: about, 403, 404, etc. + ;; markdown pages: about, 403, 404, etc. (dolist (page '(#p"about.markdown" #p"403.markdown" #p"404.markdown")) (tlbs-process-markdown-page page)) - ; archive + ;; archive (tlbs-process-archive) - ; drafts page + ;; drafts page (tlbs-process-drafts-page) - ; index + ;; index (tlbs-process-index)) (defun tlbs-process-postid (idstr) - ; we shouldn't need to process all the posts in order to have - ; references updated, but we're too lazy to keep track of dependencies + ;; we shouldn't need to process all the posts in order to have + ;; references updated, but we're too lazy to keep track of + ;; dependencies (tlbs-process-posts (concatenate 'string "posts/**/" idstr "-*.markdown")) - ; tags + ;; tags (tlbs-process-tags) - ; other files + ;; other files (tlbs-process-other-files) - ; RSS + ;; RSS (tlbs-process-rss) (format t "Processing everything else...~%") - ; archive + ;; archive (tlbs-process-archive) - ; index + ;; index (tlbs-process-index)) (defun tlbs-deploy-site () -- 1.7.10.4