guix-commits
[Top][All Lists]
Advanced

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

01/01: website: Atom feed: Add full content to entries.


From: Luis Felipe López Acevedo
Subject: 01/01: website: Atom feed: Add full content to entries.
Date: Sun, 10 Dec 2017 16:06:00 -0500 (EST)

lfla pushed a commit to branch master
in repository guix-artwork.

commit e6507ce34ee60ecd58cb20f856b98f39d247ef9e
Author: sirgazil <address@hidden>
Date:   Sun Dec 10 15:58:11 2017 -0500

    website: Atom feed: Add full content to entries.
    
    With this change, news aggregators can display the full content of
    blog posts or a summary, depending on their configuration.
    
    * website/apps/blog/builder.scm (blog-feed-builder): Limit feed
      entries to 10 posts.
    
    * website/apps/blog/templates/feed.scm (atom-feed-t): Add `content`
      element to the feed.
---
 website/apps/blog/builder.scm        | 7 ++++++-
 website/apps/blog/templates/feed.scm | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/website/apps/blog/builder.scm b/website/apps/blog/builder.scm
index 96e3c35..44c9f18 100644
--- a/website/apps/blog/builder.scm
+++ b/website/apps/blog/builder.scm
@@ -57,13 +57,18 @@
 (define (blog-feed-builder site posts)
   "Return a Haunt page representing the atom feed of the blog."
   (let* ((domain (site-domain site))
+        (sorted-posts (posts/reverse-chronological posts))
+        (max-posts 10) ; Number of posts to add to the feed.
         (context
          (list
           (cons "domain" domain)
           (cons "title" "GuixSD — Blog")
           (cons "id" (url-path-join domain "feeds" "blog.atom"))
           (cons "alternate" (url-path-join domain "blog" ""))
-          (cons "posts" (posts/reverse-chronological posts)))))
+          (cons "posts"
+                (if (> (length sorted-posts) max-posts)
+                    (list-head sorted-posts max-posts)
+                    sorted-posts)))))
     (make-page (path-join "feeds" "blog.atom")
               (atom-feed-t context)
               sxml->xml)))
diff --git a/website/apps/blog/templates/feed.scm 
b/website/apps/blog/templates/feed.scm
index 0720ea2..8713ade 100644
--- a/website/apps/blog/templates/feed.scm
+++ b/website/apps/blog/templates/feed.scm
@@ -10,6 +10,7 @@
   #:use-module (apps base types)
   #:use-module (apps base utils)
   #:use-module (apps blog utils)
+  #:use-module (haunt html)
   #:use-module (haunt post)
   #:use-module (srfi srfi-19)
   #:export (atom-feed-t))
@@ -50,5 +51,6 @@
                (lambda (tag)
                  `(category (@ (term ,tag))))
                (post-ref post 'tags))
-            (summary ,(string-summarize (sxml->string* (post-sxml post)) 100) 
"…")))
+            (summary ,(string-summarize (sxml->string* (post-sxml post)) 100) 
"…")
+            (content (@ (type "html")) ,(sxml->html-string (post-sxml post)))))
         posts))))



reply via email to

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