Bläddra i källkod

Add ATOM feed support.

Brit Butler 12 år sedan
förälder
incheckning
d3dc6f0c5c
4 ändrade filer med 42 tillägg och 10 borttagningar
  1. 1 1
      src/coleslaw.lisp
  2. 9 9
      src/feeds.lisp
  3. 31 0
      themes/hyde/atom.tmpl
  4. 1 0
      themes/hyde/base.tmpl

+ 1 - 1
src/coleslaw.lisp

@@ -34,7 +34,7 @@ If RAW is non-nil, write the content without wrapping it in the base template."
34 34
         (run-program "cp -R ~a ." dir)))
35 35
     (render-posts)
36 36
     (render-indices)
37
-    (render-feed)))
37
+    (render-feeds)))
38 38
 
39 39
 (defgeneric deploy (staging)
40 40
   (:documentation "Deploy the STAGING dir, updating the .prev and .curr symlinks.")

+ 9 - 9
src/feeds.lisp

@@ -15,7 +15,7 @@
15 15
                        (local-time:now))))
16 16
     (local-time:format-rfc1123-timestring nil timestamp)))
17 17
 
18
-(defun render-feed ()
18
+(defun render-feeds ()
19 19
   "Render and write the feed for the site."
20 20
   (let* ((posts (subseq (by-date (hash-table-values *posts*)) 0 10))
21 21
          (content (loop for post in posts
@@ -23,11 +23,11 @@
23 23
                                    :url (post-url post)
24 24
                                    :date (make-pubdate (post-date post))
25 25
                                    :tags (post-tags post)
26
-                                   :content (post-content post)))))
27
-    (render-page "rss.xml"
28
-                 (funcall (theme-fn 'rss)
29
-                          (list :pubdate (make-pubdate)
30
-                                :title (title *config*)
31
-                                :siteroot (domain *config*)
32
-                                :author (author *config*)
33
-                                :posts content)) :raw t)))
26
+                                   :content (post-content post))))
27
+         (tmpl-args (list :pubdate (make-pubdate)
28
+                          :title (title *config*)
29
+                          :siteroot (domain *config*)
30
+                          :author (author *config*)
31
+                          :posts content)))
32
+    (render-page "rss.xml" (funcall (theme-fn 'rss) tmpl-args) :raw t)
33
+    (render-page "feed.atom" (funcall (theme-fn 'atom) tmpl-args) :raw t)))

+ 31 - 0
themes/hyde/atom.tmpl

@@ -0,0 +1,31 @@
1
+{namespace coleslaw.theme.hyde}
2
+
3
+{template atom}
4
+<?xml version="1.0"?>{\n}
5
+<feed xmlns="http://www.w3.org/2005/Atom">
6
+
7
+  <title>{$title}</title>
8
+  <link href="{$siteroot}"/>
9
+  <link type="application/atom+xml" rel="self" href="{$siteroot}/atom.xml"/>
10
+  <updated>{$pubdate}</updated>
11
+  <id>{$siteroot}@{$pubdate}</id>
12
+  <author>
13
+    <name>{$author}</name>
14
+  </author>
15
+
16
+  {foreach $post in $posts}
17
+  <entry>
18
+    <link type="text/html" rel="alternate" href="$post.url"/>
19
+    <title>{$post.title}</title>
20
+    <published>{$post.date}</published>
21
+    <updated>{$post.date}</updated>
22
+    <author>
23
+      <name>{$author}</name>
24
+      <uri>{$siteroot}</uri>
25
+    </author>
26
+    <content type="html">{$post.content}</content>
27
+  </entry>
28
+  {/foreach}
29
+
30
+</feed>
31
+{/template}

+ 1 - 0
themes/hyde/base.tmpl

@@ -10,6 +10,7 @@
10 10
     <link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css" />
11 11
     <link href= "{$siteroot}/css/style.css" rel="stylesheet" type="text/css" />
12 12
     <link rel="alternate" href="{$siteroot}/feed.atom" type="application/atom+xml" />
13
+    <link rel="alternate" href="{$siteroot}/rss.xml" type="application/rss+xml" />
13 14
     {if $headInject} {$headInject |noAutoescape} {/if}
14 15
   </head>
15 16
   <body>