summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/reader.scm61
1 files changed, 57 insertions, 4 deletions
diff --git a/src/reader.scm b/src/reader.scm
index 90d90eb..222a9f9 100644
--- a/src/reader.scm
+++ b/src/reader.scm
@@ -1,4 +1,5 @@
(define-module (src reader)
+ #:use-module (srfi srfi-1)
#:use-module (srfi srfi-19)
#:use-module (ice-9 match)
#:use-module (ice-9 regex)
@@ -6,6 +7,7 @@
#:use-module (commonmark)
#:use-module (haunt reader)
#:use-module (haunt post)
+ #:use-module (sxml simple)
#:use-module (src date-utils)
#:use-module (src urls)
#:export (post-reader
@@ -41,6 +43,23 @@ related to Guix, please submit it for the next issue!"))
(vector))))
string<=?))
+(define (lookup-news-text target-locale news-entry name type)
+ (cdr
+ (xml->sxml
+ (peek
+ (any (lambda (locale)
+ (assoc-ref
+ (assoc-ref
+ (assoc-ref news-entry name)
+ locale)
+ type))
+ (list target-locale
+ (first (string-split target-locale #\_))
+ "en")))
+ #:entities '((nbsp . "\xa0")
+ (hellip . "…")))))
+
+
;;; Post reader
(define post-reader
@@ -79,13 +98,47 @@ related to Guix, please submit it for the next issue!"))
(date->string start-date "~1")
" to "
(date->string end-date "~1")))))))
- (let ((compare-data
- (lookup-compare-data-for-week year week)))
+ (let* ((compare-data
+ (lookup-compare-data-for-week year week))
+ (news
+ (and=> (assoc-ref compare-data "channel-news")
+ (lambda (news)
+ (if (eq? 0 (vector-length news))
+ #f
+ news)))))
(append
(let ((content (commonmark->sxml port)))
(if (null? content)
- %placeholder-content
- content))
+ (if news
+ `((h3 "News")
+ ,@(map (lambda (news-entry)
+ `(div
+ (h4
+ ,(lookup-news-text locale
+ news-entry
+ "title-text"
+ "html"))
+ ,(peek (lookup-news-text locale
+ news-entry
+ "body-text"
+ "html"))))
+ (vector->list news)))
+ %placeholder-content)
+ `(,@content
+ ,@(if news
+ (map (lambda (news-entry)
+ `(div
+ (h4
+ ,(lookup-news-text locale
+ news-entry
+ "title-text"
+ "html"))
+ ,(peek (lookup-news-text locale
+ news-entry
+ "body-text"
+ "html"))))
+ (vector->list news))
+ '()))))
`((h3 "Package changes")
(h4 "New packages")
,@(match (get-compare-data-packages-list compare-data