Add XHTML and US English dates
This commit is contained in:
parent
d5301833eb
commit
836a7030e8
|
@ -41,10 +41,15 @@
|
|||
(h1 ,title)
|
||||
,@(map
|
||||
(lambda (entries)
|
||||
(let ((date (entry-iso-date (first entries))))
|
||||
`(section
|
||||
(h2 ,date)
|
||||
,@(map entry->html entries))))
|
||||
(h2 ,(entry-us-english-date (first entries)))
|
||||
,@(map (lambda (entry)
|
||||
`(article
|
||||
(h3 ,(entry-title entry))
|
||||
,(or (entry-content-xhtml entry)
|
||||
`(div))
|
||||
(p "by " ,(entry-author entry))))
|
||||
entries)))
|
||||
(planet-group-entries-by-date
|
||||
(planet-n-newest-entries 10 feeds cache-directory))))))
|
||||
|
||||
|
|
42
planet.sld
42
planet.sld
|
@ -3,9 +3,11 @@
|
|||
feed-id
|
||||
feed-title
|
||||
feed-url
|
||||
entry-author
|
||||
entry-title
|
||||
entry-content-xhtml
|
||||
entry-iso-date
|
||||
entry->html
|
||||
entry-us-english-date
|
||||
planet-refresh-feed
|
||||
planet-all-entries-ever
|
||||
planet-n-newest-entries
|
||||
|
@ -29,10 +31,13 @@
|
|||
(only (traversal)
|
||||
group-by)
|
||||
(only (atom)
|
||||
read-atom-feed
|
||||
feed-entries
|
||||
content-xhtml
|
||||
entry-author
|
||||
entry-content
|
||||
entry-title
|
||||
entry-updated
|
||||
entry-title))))
|
||||
feed-entries
|
||||
read-atom-feed))))
|
||||
(begin
|
||||
|
||||
(define (take-at-most list n)
|
||||
|
@ -104,19 +109,42 @@
|
|||
(let ((cache-file (feed-cache-file feed cache-directory)))
|
||||
(call-with-port (open-binary-input-file cache-file) read-atom-feed)))
|
||||
|
||||
(define (entry-content-xhtml entry)
|
||||
(content-xhtml (entry-content entry)))
|
||||
|
||||
(define (entry-iso-date entry)
|
||||
(let ((rfc3339 (entry-updated entry)))
|
||||
(if (and rfc3339 (>= (string-length rfc3339) 10))
|
||||
(substring rfc3339 0 10)
|
||||
(error "No date"))))
|
||||
|
||||
(define (entry-us-english-date entry)
|
||||
(define month-names
|
||||
(vector
|
||||
"January"
|
||||
"February"
|
||||
"March"
|
||||
"April"
|
||||
"May"
|
||||
"June"
|
||||
"July"
|
||||
"August"
|
||||
"September"
|
||||
"October"
|
||||
"November"
|
||||
"December"))
|
||||
(let* ((yyyy-mm-dd (entry-iso-date entry))
|
||||
(year (string->number (substring yyyy-mm-dd 0 4)))
|
||||
(month (string->number (substring yyyy-mm-dd 5 7)))
|
||||
(month-name (vector-ref month-names (- month 1)))
|
||||
(day-of-month (string->number (substring yyyy-mm-dd 8 10))))
|
||||
(string-append (number->string day-of-month) " "
|
||||
month-name " " (number->string year))))
|
||||
|
||||
(define (entry-iso-date<? entry1 entry2)
|
||||
(string<? (entry-iso-date entry1)
|
||||
(entry-iso-date entry2)))
|
||||
|
||||
(define (entry->html entry)
|
||||
`(h3 ,(entry-title entry)))
|
||||
|
||||
(define (planet-all-entries-ever feeds cache-directory)
|
||||
(let ((entries (append-map feed-entries
|
||||
(map (lambda (feed)
|
||||
|
|
Loading…
Reference in New Issue