]> gitweb.factorcode.org Git - factor.git/commitdiff
Syndication uses new xml.interpolate vocab
authorDaniel Ehrenberg <littledan@Macintosh-103.local>
Mon, 26 Jan 2009 05:53:02 +0000 (23:53 -0600)
committerDaniel Ehrenberg <littledan@Macintosh-103.local>
Mon, 26 Jan 2009 05:53:02 +0000 (23:53 -0600)
basis/syndication/syndication-tests.factor
basis/syndication/syndication.factor

index 1ddcbf809050653d1c561283d96b24730efac437..4fbfee03d93f185254beed11082530d076f2ef80 100644 (file)
@@ -1,5 +1,5 @@
 USING: syndication io kernel io.files tools.test io.encodings.utf8
-calendar urls ;
+calendar urls xml.writer ;
 IN: syndication.tests
 
 \ download-feed must-infer
@@ -43,3 +43,4 @@ IN: syndication.tests
         }
     }
 } ] [ "resource:basis/syndication/test/atom.xml" load-news-file ] unit-test
+[ ] [ "resource:basis/syndication/test/atom.xml" load-news-file xml>string drop ] unit-test
index c82fe4006d3a3b6e734178a2e4aea9f56790aed2..5b6efdcf063bc509eaec750d948ab51d4d7644ae 100644 (file)
@@ -4,7 +4,7 @@
 USING: xml.utilities kernel assocs xml.generator math.order
     strings sequences xml.data xml.writer
     io.streams.string combinators xml xml.entities.html io.files io
-    http.client namespaces make xml.generator hashtables
+    http.client namespaces make xml.interpolate hashtables
     calendar.format accessors continuations urls present ;
 IN: syndication
 
@@ -114,26 +114,29 @@ TUPLE: entry title url description date ;
     http-get nip string>feed ;
 
 ! Atom generation
-: simple-tag, ( content name -- )
-    [ , ] tag, ;
-
-: simple-tag*, ( content name attrs -- )
-    [ , ] tag*, ;
-
-: entry, ( entry -- )
-    "entry" [
-        {
-            [ title>> "title" { { "type" "html" } } simple-tag*, ]
-            [ url>> present "href" associate "link" swap contained*, ]
-            [ date>> timestamp>rfc3339 "published" simple-tag, ]
-            [ description>> [ "content" { { "type" "html" } } simple-tag*, ] when* ]
-        } cleave
-    ] tag, ;
+
+: entry>xml ( entry -- xml )
+    {
+        [ title>> ]
+        [ url>> present ]
+        [ date>> timestamp>rfc3339 ]
+        [ description>> ]
+    } cleave
+    [XML
+        <entry>
+            <title type="html"><-></title>
+            <link href=<-> />
+            <published><-></published>
+            <content type="html"><-></content>
+        </entry>
+    XML] ;
 
 : feed>xml ( feed -- xml )
-    "feed" { { "xmlns" "http://www.w3.org/2005/Atom" } } [
-        [ title>> "title" simple-tag, ]
-        [ url>> present "href" associate "link" swap contained*, ]
-        [ entries>> [ entry, ] each ]
-        tri
-    ] make-xml* ;
+    [ title>> ] [ url>> present ] [ entries>> [ entry>xml ] map ] tri
+    <XML
+        <feed xmlns="http://www.w3.org/2005/Atom">
+            <title><-></title>
+            <link href=<-> />
+            <->
+        </feed>
+    XML> ;