guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: Fix the RSS feed.


From: Mathieu Othacehe
Subject: branch master updated: Fix the RSS feed.
Date: Wed, 11 Aug 2021 02:50:10 -0400

This is an automated email from the git hooks/post-receive script.

mothacehe pushed a commit to branch master
in repository guix-cuirass.

The following commit(s) were added to refs/heads/master by this push:
     new b210fcc  Fix the RSS feed.
b210fcc is described below

commit b210fcc963865acd820078e705132cd2b5f339a7
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Wed Aug 11 08:48:10 2021 +0200

    Fix the RSS feed.
    
    Fixes: <https://issues.guix.gnu.org/49744>.
    
    * src/cuirass/http.scm (respond-xml): Rename it to ...
    (respond-rss): ... this procedure and fix the content-type.
    (url-handler): Adapt it.
    * src/cuirass/rss.scm (build->rss-item, rss-feed): Adapt to respect the W3C
    guidelines.
---
 src/cuirass/http.scm |  7 +++----
 src/cuirass/rss.scm  | 23 ++++++++++++++++++-----
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index c4976ae..03a6b80 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -523,15 +523,14 @@ passed, only display JOBS targeting this SYSTEM."
        (format port "<!DOCTYPE html>")
        (sxml->xml body port))))
 
-  (define* (respond-xml body #:key code)
+  (define* (respond-rss body #:key code)
     (respond
-     (let ((content-type '((content-type . (application/xhtml+xml)))))
+     (let ((content-type '((content-type . (application/rss+xml)))))
        (if code
            (build-response #:headers content-type #:code code)
            content-type))
      #:body
      (lambda (port)
-       (format port "<?xml version=\"1.0\" encoding=\"utf-8\"?>")
        (sxml->xml body port))))
 
   (define* (respond-file file)
@@ -1065,7 +1064,7 @@ passed, only display JOBS targeting this SYSTEM."
      (let* ((params (request-parameters request))
             (specification (and params
                                 (assq-ref params 'specification))))
-       (respond-xml
+       (respond-rss
         (rss-feed
          (db-get-builds `((weather . new)
                           (jobset . ,specification)
diff --git a/src/cuirass/rss.scm b/src/cuirass/rss.scm
index 1be3d37..6a64d06 100644
--- a/src/cuirass/rss.scm
+++ b/src/cuirass/rss.scm
@@ -137,6 +137,7 @@ list ATTRS and the child nodes in BODY."
 (define* (build->rss-item build)
   "Convert BUILD into an RSS <item> node."
   (let* ((url (build-details-url build))
+         (id (assq-ref build #:id))
          (job-name (assq-ref build #:job-name))
          (specification (assq-ref build #:specification))
          (weather  (assq-ref build #:weather))
@@ -147,10 +148,11 @@ list ATTRS and the child nodes in BODY."
                          "broken")))
          (stoptime (assq-ref build #:stoptime)))
     `(item
+      (guid ,url)
       (title
        ,(format #f "Build ~a on ~a is ~a."
                 job-name specification weather-text))
-      (author "Cuirass")
+      (author "cuirass@gnu.org (Cuirass)")
       (pubDate ,(date->rfc822-str
                  (time-utc->date
                   (make-time time-utc 0 stoptime))))
@@ -165,11 +167,22 @@ You can find the detailed information about this build "
              "."))))))
 
 (define* (rss-feed builds #:key params)
-  (let ((specification (and params
-                            (assq-ref params 'specification))))
-    `(rss (@ (version "2.0"))
+  (let* ((specification (and params
+                             (assq-ref params 'specification)))
+         (cuirass-url (or (%cuirass-url)
+                          "https://cuirass.org";))
+         (url (format #f "~a/events/rss/~a"
+                      cuirass-url
+                      (if specification
+                          (string-append "?specification=" specification)
+                          ""))))
+    `(rss (@ (version "2.0")
+             (xmlns:atom "http://www.w3.org/2005/Atom";))
           (channel
            (title "GNU Guix continuous integration system build events.")
+           (atom:link (@ (href ,url)
+                         (rel "self")
+                         (type "application/rss+xml")))
            (description
             ,(string-append
               "Build events for "
@@ -177,5 +190,5 @@ You can find the detailed information about this build "
                   (string-append "specification " specification ".")
                   "all specifications.")))
            (pubDate ,(date->rfc822-str (current-date)))
-           (link (@ (href "/")))
+           (link ,cuirass-url)
            ,@(map build->rss-item builds)))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]