]> gitweb.factorcode.org Git - factor.git/commitdiff
Improve planet date handling
authorSlava Pestov <slava@factorcode.org>
Sat, 8 Dec 2007 22:18:34 +0000 (17:18 -0500)
committerSlava Pestov <slava@factorcode.org>
Sat, 8 Dec 2007 22:18:34 +0000 (17:18 -0500)
extra/webapps/planet/planet.factor
extra/webapps/planet/planet.furnace

index 9a3a4c2f8e98a899c7c876edec07e8011fda92ba..75440816be77bbeadbe824d90f96d3cd68acafc4 100644 (file)
@@ -24,15 +24,7 @@ IN: webapps.planet
     </ul> ;
 
 : format-date ( date -- string )
-    10 head "-" split [ string>number ] map
-    first3 0 0 0 0 <timestamp>
-    [
-        dup timestamp-day #
-        " " %
-        dup timestamp-month month-abbreviations nth %
-        ", " %
-        timestamp-year #
-    ] "" make ;
+    rfc3339>timestamp timestamp>string ;
 
 : print-posting ( posting -- )
     <h2 "posting-title" =class h2>
@@ -53,8 +45,11 @@ IN: webapps.planet
 SYMBOL: default-blogroll
 SYMBOL: cached-postings
 
+: safe-head ( seq n -- seq' )
+    over length min head ;
+
 : mini-planet-factor ( -- )
-    cached-postings get 4 head print-posting-summaries ;
+    cached-postings get 4 safe-head print-posting-summaries ;
 
 : planet-factor ( -- )
     serving-html [ "planet" render-template ] with-html-stream ;
@@ -64,7 +59,7 @@ SYMBOL: cached-postings
 : planet-feed ( -- feed )
     "[ planet-factor ]"
     "http://planet.factorcode.org"
-    cached-postings get 30 head <feed> ;
+    cached-postings get 30 safe-head <feed> ;
 
 : feed.xml ( -- )
     "text/xml" serving-content
@@ -130,7 +125,7 @@ SYMBOL: last-update
     { "Kio M. Smallwood"
     "http://sekenre.wordpress.com/feed/atom/"
     "http://sekenre.wordpress.com/" }
-    { "Phil Dawes" "http://www.phildawes.net/blog/category/factor/feed/atom" "http://www.phildawes.net/blog/" }
+    { "Phil Dawes" "http://www.phildawes.net/blog/category/factor/feed/atom" "http://www.phildawes.net/blog/" }
     { "Samuel Tardieu" "http://www.rfc1149.net/blog/tag/factor/feed/atom/" "http://www.rfc1149.net/blog/tag/factor/" }
     { "Slava Pestov" "http://factor-language.blogspot.com/atom.xml" "http://factor-language.blogspot.com/" }
 } default-blogroll set-global
index d8640f8271a121a4ab72c16dfab8083278aba434..4c6676c0a245525712952e07013c6e492dfce1a5 100644 (file)
@@ -17,7 +17,7 @@ furnace ; %>
     <h1 class="planet-title">[ planet-factor ]</h1>
     <table width="100%" cellpadding="10">
         <tr>
-            <td> <% cached-postings get 20 head print-postings %> </td>
+            <td> <% cached-postings get 20 safe-head print-postings %> </td>
             <td valign="top" width="25%" class="infobox">
                 <p>
                     <b>planet-factor</b> is an Atom/RSS aggregator that collects the