cc1550af2246 lisp

Final tweaks
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Thu, 09 Jan 2020 19:24:38 -0800
parents b98008bc3c58
children 780fc1cefb32
branches/tags lisp
files generate.lisp nginx.conf static/css/print.css static/css/style.css watch.sh

Changes

--- a/generate.lisp	Wed Jan 08 22:27:57 2020 -0800
+++ b/generate.lisp	Thu Jan 09 19:24:38 2020 -0800
@@ -13,6 +13,9 @@
 (in-package :stevelosh.com)
 
 ;;;; State and Configuration --------------------------------------------------
+(defparameter *generate-timestamp* (file-write-date "generate.lisp"))
+(defparameter *header-number* 0)
+
 (setf 3bmd-code-blocks:*code-blocks* t)
 
 
@@ -59,8 +62,6 @@
 
 
 ;;;; Tables of Contents -------------------------------------------------------
-(defparameter *header-number* 0)
-
 (defun subheaderp (node)
   (and (plump:element-p node)
        (member (plump:tag-name node) '("h2" "h3" "h4" "h5" "h6") :test #'string=)))
@@ -110,24 +111,11 @@
 
   The result will be a tree of `(node &rest children)`, e.g.:
 
-      h2               ((h2 (h3)
-        h3                  (h3))
-        h3              (h2 (h3 (h4)
-      h2                        (h4))
-        h3        →         (h3 (h4
-          h4                      (h5)
-          h4                      (h5))))
-        h3              (h2 (nil (h4)
-          h4                     (h4))
-            h5              (h3))
-            h5
-      h2
-          h4
-          h4
-        h3
+  2 3 3 2 3 4 4 → ((h2 (h3) (h3))
+                   (h2 (h3 (h4) (h4))))
 
-  Note the addition of dummy headers when the level jumps unexpectedly, to keep
-  the proper TOC structure even when the source is borked.
+  This will add dummy headers when the level jumps unexpectedly, to keep the
+  proper TOC structure even when the source is borked.
 
   "
   (labels
@@ -141,6 +129,7 @@
              (values first-header head tail))))
        (section (level header children)
          "Handle a single section (i.e. one header and its children)."
+         ;; (node . …recur…)
          (list* (cdr header) (sections (1+ level) children)))
        (sections (level headers)
          "Split `headers` into sibling sections, expecting to be at `level`."
@@ -148,8 +137,11 @@
            nil
            (let ((l (car (first headers))))
              (if (< level l)
-               (sections level (cons (cons (1- l) nil) headers))
+               (sections level (cons (cons (1- l) nil) headers)) ; dummy
                (multiple-value-bind (header children remaining) (split headers)
+                 ;;  2 3 3 4 3  2 3 3 2 3 4 4
+                 ;; [2 3 3 4 3] 2 3 3 2 3 4 4
+                 ;;  section    recur
                  (list*
                    (section level header children)
                    (sections level remaining))))))))
@@ -179,7 +171,6 @@
     (plump:serialize root nil)))
 
 
-
 ;;;; Content ------------------------------------------------------------------
 (defclass* content ()
   (input-path output-path date modified-timestamp body
@@ -242,7 +233,7 @@
       " - " (:a :href "/projects/" "Projects")
       " - " (:a :href "/photography/" "Photography")
       " - " (:a :href "/links/" "Links")
-      " - " (:a :href "/feed/" "Feed")))))
+      " - " (:a :href "/rss.xml" "Feed")))))
 
 (defun t/footer ()
   (who
@@ -278,8 +269,8 @@
 
 ;;;; Page Templates -----------------------------------------------------------
 (defun t/mathjax ()
-  (who (str "<script type='text/javascript' async
-                     src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>")))
+  (who "<script type='text/javascript' async
+                src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>"))
 
 
 (defun t/index-item (item)
@@ -381,33 +372,29 @@
 
 
 ;;;; Generation ---------------------------------------------------------------
-(defparameter *generate-timestamp* (file-write-date "generate.lisp"))
-
-(defun needs-render-p (path times)
+(defun needs-render-p (path timestamps)
   (or (null (probe-file path))
       (let ((prev (file-write-date path)))
         (or (> *generate-timestamp* prev)
             (some (lambda (time) (> time prev))
-                  (alexandria:ensure-list times))))))
+                  (alexandria:ensure-list timestamps))))))
 
-(defun render% (path mode times thunk)
-  (if (needs-render-p path times)
+(defun render% (path mode timestamps thunk)
+  (when (needs-render-p path timestamps)
     (progn
       (format t "Rendering ~S~%" path)
       (ensure-directories-exist path)
-      (with-open-file (*standard-output* path
-                                         :direction :output
-                                         :if-exists :supersede)
+      (with-open-file (*standard-output* path :direction :output :if-exists :supersede)
         (setf (cl-who:html-mode) mode)
         (ecase mode
           (:html5 (write-line "<!DOCTYPE html>"))
           (:xml (write-line "<?xml version='1.0'?>")))
-        (who (funcall thunk))))
-    #+no (format t "Skipping ~S, file is up to date.~%" path)))
+        (who (funcall thunk))))))
 
 (defmacro render (path (&key times (mode :html5)) &body body)
   `(render% ,path ,mode ,times (lambda () ,@body)))
 
+
 (defun page/home ()
   (render "build/index.html" ()
     (t/home)))
--- a/nginx.conf	Wed Jan 08 22:27:57 2020 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-server {
-    listen   80;
-    server_name  www.stevelosh.com;
-    rewrite ^/(.*) http://stevelosh.com/$1 permanent;
-}
-server {
-    listen   80 default;
-    server_name  stevelosh.com;
-
-    access_log /tmp/stevelosh.com.access.log;
-    error_log /tmp/stevelosh.com.error.log;
-
-    location = /feed.html { return 301 /index.xml; }
-    location = /feed/ { return 301 /index.xml; }
-
-    location / {
-        root   /var/www/stevelosh.com/;
-        index  index.html;
-
-        if ($request_uri ~ ^/blog/entry/\d+/\d/\d+/[^/]*/?$) {
-            rewrite ^/blog/entry/(\d+)/(\d)/\d+/([^/]*)/?$ /blog/$1/0$2/$3/ permanent;
-            break;
-        }
-
-        if ($request_uri ~ ^/blog/entry/\d+/\d\d/\d+/[^/]*/?$) {
-            rewrite ^/blog/entry/(\d+)/(\d\d)/\d+/([^/]*)/?$ /blog/$1/$2/$3/ permanent;
-            break;
-        }
-
-        if ($request_filename ~ ^.*.html$) {
-            rewrite ^(.*).html$ $1/ permanent;
-            break;
-        }
-
-        if (-f $request_filename) {
-            break;
-        }
-
-        if ($request_filename ~ ^.+[^/]$) {
-            rewrite ^/(.*)$ /$1/ permanent;
-            break;
-        }
-
-        if (-f $request_filename/index.html) {
-            rewrite ^(.*)/$ /$1/index.html;
-            break;
-        }
-
-        if ($request_filename ~ ^.*/$) {
-            rewrite ^/(.*)/$ /$1;
-        }
-
-        if (-f $request_filename.html) {
-            rewrite ^/(.*)$ /$1.html;
-            break;
-        }
-
-        if (!-f $request_filename.html) {
-            break;
-        }
-    }
-
-    error_page 404 /404.html;
-    location = /404.html {
-        root /var/www/stevelosh.com/;
-    }
-}
-
--- a/static/css/print.css	Wed Jan 08 22:27:57 2020 -0800
+++ b/static/css/print.css	Thu Jan 09 19:24:38 2020 -0800
@@ -1,5 +1,5 @@
 body {
-  font: normal 10pt/1.25 Palatino, "Palatino Linotype", serif;
+  font: normal 10pt/1.25 serif;
   text-rendering: optimizeLegibility;
 }
 
--- a/static/css/style.css	Wed Jan 08 22:27:57 2020 -0800
+++ b/static/css/style.css	Thu Jan 09 19:24:38 2020 -0800
@@ -67,7 +67,6 @@
 
 /* Headings ---------------------------------------------------------------- */
 h1, h2, h3, h4, h5, h6 {
-    /* font-family: HoeflerText-Regular, 'Hoefler Text', 'Goudy Old Style','Palatino', 'Palatino Linotype', serif; */
     font-weight: normal;
 }
 h1 a, h2 a, h3 a, h4 a {
@@ -194,7 +193,6 @@
     background: black;
     max-width: 676px;
 }
-
 main#page-blog-entry canvas {
     display: block;
     margin: 25px auto 26px;
@@ -210,12 +208,10 @@
     margin: 0px 0px 24px 0px;
     padding: 0;
 }
-
 main#page-photography-gallery li {
     display: inline-block;
     margin: 0;
 }
-
 main#page-photography-gallery img {
     display: inline-block;
     margin: 0px 12px 12px 0px;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/watch.sh	Thu Jan 09 19:24:38 2020 -0800
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+hg files generate.lisp content static | grep -v static/images | peat ./build.sh