# HG changeset patch # User Steve Losh # Date 1578626678 28800 # Node ID cc1550af22462145f1ffe4c1b6376179803407ba # Parent b98008bc3c586ffd26e5f9bb006ae325bbfe6ad3 Final tweaks diff -r b98008bc3c58 -r cc1550af2246 generate.lisp --- 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 ""))) + (who "")) (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 "")) (:xml (write-line ""))) - (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))) diff -r b98008bc3c58 -r cc1550af2246 nginx.conf --- 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/; - } -} - diff -r b98008bc3c58 -r cc1550af2246 static/css/print.css --- 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; } diff -r b98008bc3c58 -r cc1550af2246 static/css/style.css --- 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; diff -r b98008bc3c58 -r cc1550af2246 watch.sh --- /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