|
@@ -47,6 +47,10 @@
|
47
|
47
|
(update-symlink prev (truename curr)))
|
48
|
48
|
(update-symlink curr new-build))))
|
49
|
49
|
|
|
50
|
+(defun update-symlink (path target)
|
|
51
|
+ "Update the symlink at PATH to point to TARGET."
|
|
52
|
+ (run-program "ln -sfn ~a ~a" target path))
|
|
53
|
+
|
50
|
54
|
(defun preview (path &optional (content-type 'post))
|
51
|
55
|
"Render the content at PATH under user's configured repo and save it to
|
52
|
56
|
~/tmp.html. Load the user's config and theme if necessary."
|
|
@@ -58,39 +62,12 @@
|
58
|
62
|
(content (construct content-type (read-content file))))
|
59
|
63
|
(write-file "tmp.html" (render-page content)))))
|
60
|
64
|
|
61
|
|
-(defgeneric render-text (text format)
|
62
|
|
- (:documentation "Render TEXT of the given FORMAT to HTML for display.")
|
63
|
|
- (:method (text (format (eql :html)))
|
64
|
|
- text)
|
65
|
|
- (:method (text (format (eql :md)))
|
66
|
|
- (let ((3bmd-code-blocks:*code-blocks* t))
|
67
|
|
- (with-output-to-string (str)
|
68
|
|
- (3bmd:parse-string-and-print-to-stream text str)))))
|
69
|
|
-
|
70
|
|
-(defun make-pubdate ()
|
71
|
|
- "Make a RFC1123 pubdate representing the current time."
|
72
|
|
- (local-time:format-rfc1123-timestring nil (local-time:now)))
|
73
|
|
-
|
74
|
|
-(defun page-path (object)
|
75
|
|
- "The path to store OBJECT at once rendered."
|
76
|
|
- (rel-path (staging-dir *config*) (namestring (page-url object))))
|
77
|
|
-
|
78
|
65
|
(defun render-page (content &optional theme-fn &rest render-args)
|
79
|
|
- "Render the given CONTENT to disk using THEME-FN if supplied.
|
|
66
|
+ "Render the given CONTENT to HTML using THEME-FN if supplied.
|
80
|
67
|
Additional args to render CONTENT can be passed via RENDER-ARGS."
|
81
|
68
|
(funcall (or theme-fn (theme-fn 'base))
|
82
|
69
|
(list :config *config*
|
83
|
70
|
:content content
|
84
|
71
|
:raw (apply 'render content render-args)
|
85
|
|
- :pubdate (make-pubdate)
|
|
72
|
+ :pubdate (format-rfc1123-timestring nil (local-time:now))
|
86
|
73
|
:injections (find-injections content))))
|
87
|
|
-
|
88
|
|
-(defun write-file (filepath page)
|
89
|
|
- "Write the given PAGE to FILEPATH."
|
90
|
|
- (ensure-directories-exist filepath)
|
91
|
|
- (with-open-file (out filepath
|
92
|
|
- :direction :output
|
93
|
|
- :if-exists :supersede
|
94
|
|
- :if-does-not-exist :create
|
95
|
|
- :external-format '(:utf-8))
|
96
|
|
- (write page :stream out :escape nil)))
|