actually handle more common errors. Check date format
This commit is contained in:
parent
1ef23de96f
commit
c38b7b543e
35
generate.fnl
35
generate.fnl
|
@ -140,13 +140,14 @@
|
|||
(f:write html-index)))
|
||||
|
||||
(fn generate-logs []
|
||||
"generates the log index pages and feeds from the posts index"
|
||||
(table.sort posts (fn [a b]
|
||||
(> (. a :date) (. b :date))))
|
||||
(generate-gemini-log)
|
||||
(generate-html-log)
|
||||
(generate-ass-feeds)
|
||||
(generate-rss-feeds))
|
||||
"generates the log index pages and feeds from the posts index (if there are any posts)"
|
||||
(when (not= 0 (length posts))
|
||||
(table.sort posts (fn [a b]
|
||||
(> (. a :date) (. b :date))))
|
||||
(generate-gemini-log)
|
||||
(generate-html-log)
|
||||
(generate-ass-feeds)
|
||||
(generate-rss-feeds)))
|
||||
|
||||
; index-post adds a log post to the post index
|
||||
(fn index-post [f]
|
||||
|
@ -154,12 +155,20 @@
|
|||
(io.input (.. content-dir f)) ; open file
|
||||
(let [post {}]
|
||||
(tset post :path f)
|
||||
(let [line (io.read) ; read first line, match title
|
||||
title (line:match "^#%s*([^\n]+)%s*$")]
|
||||
(tset post :title title))
|
||||
(let [line (io.read) ; read second line, match date
|
||||
date (line:match "^%s*(.+)%s*")]
|
||||
(tset post :date date))
|
||||
(let [line (io.read)] ; read first line, match title
|
||||
(if (not= line nil)
|
||||
(let [title (line:match "^#%s*([^\n]+)%s*$")]
|
||||
(if (not= title nil)
|
||||
(tset post :title title)
|
||||
(error (.. "cannot read title from file " f ". Is it misformatted?"))))
|
||||
(error (.. "cannot read title from file " f ". Is it missing?" ))))
|
||||
(let [line (io.read)] ; read second line, match date
|
||||
(if (not= line nil)
|
||||
(let [date (line:match "^%s*(%d%d%d%d%-%d%d%-%d%d)%s*")]
|
||||
(if (not= date nil)
|
||||
(tset post :date date)
|
||||
(error (.. "cannot read date from file " f ". Is it misformatted?"))))
|
||||
(error (.. "cannot read date from file " f ". It is missing?"))))
|
||||
(table.insert posts post))
|
||||
(io.close))
|
||||
|
||||
|
|
Reference in New Issue