|
40 | 40 | "Create list that contains the data from each JSON file combined with the body of every post."
|
41 | 41 | (let* ((json (uiop:read-file-string (car (cdr post))))
|
42 | 42 | (list-json (json:decode-json-from-string json)))
|
43 |
| - `(,@list-json (:content . ,(post-for-slug (cdr (assoc :slug list-json))))))) |
| 43 | + `(,@list-json |
| 44 | + (:published_pretty . ,(pretty-date (cdr (assoc :published list-json)))) |
| 45 | + (:modified_pretty . ,(pretty-date (cdr (assoc :modified list-json)))) |
| 46 | + (:content . ,(post-for-slug (cdr (assoc :slug list-json))))))) |
| 47 | + |
| 48 | +(defun pretty-date (date) |
| 49 | + "Returns a pretty date given a date from a JSON file." |
| 50 | + (local-time:format-timestring nil |
| 51 | + (local-time:parse-timestring date) |
| 52 | + :format '(:LONG-MONTH " " :DAY ", " :YEAR))) |
44 | 53 |
|
45 | 54 | (defun full-path-as-string (dir)
|
46 | 55 | (namestring (truename dir)))
|
|
60 | 69 | (ensure-directories-exist (concat (full-path-as-string "site/") folder)))
|
61 | 70 | folder)))
|
62 | 71 |
|
63 |
| -(defun parse-date (date) |
64 |
| - (let ((month (local-time:format-timestring nil (local-time:parse-timestring date) :format '(:month))) |
65 |
| - (year (local-time:format-timestring nil (local-time:parse-timestring date) :format '(:year))) |
66 |
| - (day (local-time:format-timestring nil (local-time:parse-timestring date) :format '(:day)))) |
67 |
| - (concat year "-" month "-" day))) |
68 |
| - |
69 | 72 | (defun write-file (contents file)
|
70 | 73 | "Write CONTENTS to FILE."
|
71 | 74 | (with-open-file (stream file
|
|
92 | 95 | (setf post `((:content . ,(cdr (assoc :content pair)))
|
93 | 96 | (:pub_date . ,(cdr (assoc :published pair)))
|
94 | 97 | (:mod_date . ,(cdr (assoc :modified pair)))
|
95 |
| - (:modifiedDate . ,(parse-date (cdr (assoc :modified pair)))) |
96 |
| - (:formattedDate . ,(parse-date (cdr (assoc :published pair)))) |
| 98 | + (:modifiedDate . ,(pretty-date (cdr (assoc :modified pair)))) |
| 99 | + (:formattedDate . ,(pretty-date (cdr (assoc :published pair)))) |
97 | 100 | (:link . ,(cdr (assoc :link pair)))
|
98 | 101 | (:description . ,(cdr (assoc :excerpt pair)))
|
99 | 102 | (:slug . ,(concat "/writing/"
|
|
215 | 218 | (date-as-rfc-822 (local-time:format-timestring nil (local-time:now))))
|
216 | 219 |
|
217 | 220 | (defun date-as-rfc-822 (date)
|
218 |
| - (let ((year (local-time:format-timestring nil (local-time:parse-timestring date) :format '(:year))) |
219 |
| - (month (local-time:format-timestring nil |
220 |
| - (local-time:parse-timestring date) |
221 |
| - :format '(:short-month))) |
222 |
| - (day (local-time:format-timestring nil |
223 |
| - (local-time:parse-timestring date) |
224 |
| - :format '(:short-weekday))) |
225 |
| - (date (return-leading-zero-as-string |
226 |
| - (read-from-string |
227 |
| - (local-time:format-timestring nil |
228 |
| - (local-time:parse-timestring date) |
229 |
| - :format '(:day))))) |
230 |
| - (hour (return-leading-zero-as-string |
231 |
| - (read-from-string |
232 |
| - (local-time:format-timestring nil |
233 |
| - (local-time:parse-timestring date) |
234 |
| - :format '(:hour))))) |
235 |
| - (minute (return-leading-zero-as-string |
236 |
| - (read-from-string |
237 |
| - (local-time:format-timestring nil |
238 |
| - (local-time:parse-timestring date) |
239 |
| - :format '(:min))))) |
240 |
| - (seconds (return-leading-zero-as-string |
241 |
| - (read-from-string |
242 |
| - (local-time:format-timestring nil |
243 |
| - (local-time:parse-timestring date) |
244 |
| - :format '(:sec))))) |
245 |
| - (tz (local-time:format-timestring nil |
246 |
| - (local-time:parse-timestring date) |
247 |
| - :format '(:gmt-offset-hhmm)))) |
248 |
| - (concat day ", " date " " month " " year " " hour ":" minute ":" seconds " " tz))) |
| 221 | + (local-time:format-timestring nil |
| 222 | + (local-time:parse-timestring date) |
| 223 | + :format '(:short-weekday ", " :day " " :short-month " " :year " " :hour ":" :min ":" (:sec 2) " " :gmt-offset-hhmm))) |
249 | 224 |
|
250 | 225 | (defun format-data-for-rss(post)
|
251 | 226 | (let ((slug (cdr (assoc :slug post))))
|
|
0 commit comments